// Robot doesn't move, so return current position
pthread_mutex_unlock(&actual_trajectory_lock);
- ROBOT_LOCK(est_pos_uzv);
- pos.x = robot.est_pos_uzv.x;
- pos.y = robot.est_pos_uzv.y;
- pos.phi = robot.est_pos_uzv.phi;
- pos.v = 0;
- pos.omega = 0;
- ROBOT_UNLOCK(est_pos_uzv);
+ if (robot.localization_works) {
+ ROBOT_LOCK(est_pos_uzv);
+ pos.x = robot.est_pos_uzv.x;
+ pos.y = robot.est_pos_uzv.y;
+ pos.phi = robot.est_pos_uzv.phi;
+ pos.v = 0;
+ pos.omega = 0;
+ ROBOT_UNLOCK(est_pos_uzv);
+ } else {
+ ROBOT_LOCK(est_pos_odo);
+ pos.x = robot.est_pos_odo.x;
+ pos.y = robot.est_pos_odo.y;
+ pos.phi = robot.est_pos_odo.phi;
+ pos.v = 0;
+ pos.omega = 0;
+ ROBOT_UNLOCK(est_pos_odo);
+ }
}
}