]> rtime.felk.cvut.cz Git - eurobot/public.git/blobdiff - src/robofsm/robot_orte.c
Unify ORTE initialization
[eurobot/public.git] / src / robofsm / robot_orte.c
index f627920d68154a2894fa554831a3e6f97fe2a665..abb34f54e5aa9f5338e6d77b1c9b2b9f3dfd13ed 100644 (file)
@@ -92,7 +92,11 @@ void send_match_time_cb(const ORTESendInfo *info, void *vinstance,
 {
        struct match_time_type *instance = (struct match_time_type *)vinstance;
 
-       instance->time = robot_current_time();
+        if (robot.start_state == POWER_ON || robot.start_state == START_PLUGGED_IN) {
+                instance->time = 90;
+        } else {
+                instance->time = 90 - robot_current_time();
+        }
 }
 /* ---------------------------------------------------------------------- 
  * SUBSCRIBER CALLBACKS - GENERIC
@@ -119,13 +123,15 @@ void rcv_odo_data_cb(const ORTERecvInfo *info, void *vinstance,
                                break;
                        }
                        
-                       dleft = ((robot.odo_data.left - instance->left) >> 8) * c;      // TODO >> 8 ?
-                       dright = ((instance->right - robot.odo_data.right) >> 8) * c;
+                       dleft = ((robot.odo_data.left - instance->left) >> 8) * c * robot.odo_cal_a;    // TODO >> 8 ?
+                       dright = ((instance->right - robot.odo_data.right) >> 8) * c * robot.odo_cal_b;
 
                        dtang = (dleft + dright) / 2.0;
                        dphi = (dright - dleft) / (2.0*ODOMETRY_ROTATION_RADIUS_M);
 
                        ROBOT_LOCK(est_pos_indep_odo);
+                       robot.odo_distance_a +=dleft;
+                       robot.odo_distance_b +=dright;
                        double a = robot.est_pos_indep_odo.phi;
                        robot.est_pos_indep_odo.x += dtang*cos(a);
                        robot.est_pos_indep_odo.y += dtang*sin(a);
@@ -178,7 +184,7 @@ void rcv_motion_irc_cb(const ORTERecvInfo *info, void *vinstance,
                        This was neccessary to view motor odometry correctly in robomon. */
                        dright = ((robot.motion_irc.left - instance->left) >> 8) * c;
                        dleft = ((instance->right - robot.motion_irc.right) >> 8) * c;
-
+                       
                        dtang = (dleft + dright) / 2.0;
                        dphi = (dright - dleft) / (2.0*ROBOT_ROTATION_RADIUS_M);
 
@@ -473,8 +479,6 @@ int robot_init_orte()
 {
        int rv = 0;
 
-       robot.orte.strength = 20;
-
        rv = robottype_roboorte_init(&robot.orte);
        if (rv)
                return rv;