restore first circle algo + hostsim work
[aversive.git] / projects / microb2010 / tests / hostsim / cs.c
index 7fb39f5..9766ea9 100644 (file)
@@ -29,7 +29,7 @@
 
 #include <timer.h>
 #include <scheduler.h>
-#include <time.h>
+#include <clock_time.h>
 
 #include <pid.h>
 #include <quadramp.h>
@@ -43,6 +43,8 @@
 #include <rdline.h>
 
 #include "robotsim.h"
+#include "strat.h"
+#include "actuator.h"
 #include "main.h"
 
 /* called every 5 ms */
@@ -88,11 +90,11 @@ static void do_cs(void *dummy)
                 * compensation) */
                position_manage(&mainboard.pos);
        }
-#if 0
        if (mainboard.flags & DO_BD) {
                bd_manage_from_cs(&mainboard.angle.bd, &mainboard.angle.cs);
                bd_manage_from_cs(&mainboard.distance.bd, &mainboard.distance.cs);
        }
+#if 0
        if (mainboard.flags & DO_TIMER) {
                uint8_t second;
                /* the robot should stop correctly in the strat, but
@@ -113,6 +115,9 @@ static void do_cs(void *dummy)
                BRAKE_ON();
 #endif
        cpt++;
+
+       if ((cpt & 7) == 0)
+               robotsim_dump();
        //dump_cs("distance", &mainboard.distance.cs);
        //dump_cs("angle", &mainboard.angle.cs);
 }
@@ -149,8 +154,8 @@ void microb_cs_init(void)
 {
        /* ROBOT_SYSTEM */
        rs_init(&mainboard.rs);
-       rs_set_left_pwm(&mainboard.rs, robotsim_pwm, LEFT_PWM);
-       rs_set_right_pwm(&mainboard.rs,  robotsim_pwm, RIGHT_PWM);
+       rs_set_left_pwm(&mainboard.rs, pwm_set_and_save, LEFT_PWM);
+       rs_set_right_pwm(&mainboard.rs,  pwm_set_and_save, RIGHT_PWM);
        /* increase gain to decrease dist, increase left and it will turn more left */
        rs_set_left_ext_encoder(&mainboard.rs, robotsim_encoder_get,
                                LEFT_ENCODER, IMP_COEF);