5 #include <trgenconstr.h>
8 #include <roboorte_robottype.h>
10 #include <roboevent.h>
12 #include <robot_config.h>
13 #include <actuators.h>
14 #include <semaphore.h>
15 #include "movehelper.h"
16 #include "scheduler.hpp"
19 //UL_LOG_CUST(ulogd_robot_h); /* Log domain name = ulogd + name of the file */
22 * Competition parameters
25 VIOLET = 0, /* Coordinate transformation does not apply */
26 RED /* Coordinate transformation applies (in *_trans() functions) */
29 enum robot_start_state {
41 enum robot_component {
51 ROBOT_COMPONENT_NUMBER
61 void int_handler(int sig);
63 //static void trans_callback(struct robo_fsm *fsm) publication stringnames of states
66 pthread_mutex_t lock_ref_pos;
67 pthread_mutex_t lock_est_pos_odo;
68 pthread_mutex_t lock_est_pos_indep_odo;
69 pthread_mutex_t lock_meas_angles;
70 pthread_mutex_t lock_joy_data;
71 pthread_mutex_t lock_disp;
72 pthread_mutex_t lock_camera;
73 /* competition parameters */
74 team_colour team_color;
76 /** State variable used for controlling the robot by pluggin
77 * in and out start connector. */
78 robot_start_state start_state;
81 robot_pos_type ref_pos;
82 /* estimated position */
83 robot_pos_type est_pos_odo;
84 robot_pos_type est_pos_indep_odo;
85 /** True if est_pos_odo is updated according to reception of motion_irc */
87 /** True if est_pos_indep_odo is updated according to reception of motion_indep_odo */
88 bool indep_odometry_works;
90 bool use_back_bumpers;
92 bool use_right_bumper;
94 /** True iff at least one wheel rotates backward */
98 * sometimes H8S does not send queried odometry
99 * following flag has been added for EKF estimator,
100 * since is has been hardly disturbed by missing measurement
101 * (taken as sudden zero velocities)
103 bool motion_irc_received;
106 struct robottype_orte_data orte;
109 struct motion_irc_type motion_irc; /* motor odometry */
110 struct odo_data_type odo_data; /* independent odometry */
111 struct corr_distances_type corr_distances; /* ultrasound */
113 hokuyo_scan_type hokuyo;
116 //struct map *map; /* Map for pathplanning (no locking) */
118 robot_status status[ROBOT_COMPONENT_NUMBER];
120 char corns_conf_center;
121 char corns_conf_side;
122 struct corns_group *corns;
124 bool obstacle_avoidance_enabled;
126 /** is set to true in separate thread when there is short time left */
127 bool short_time_to_end;
128 bool check_turn_safety;
132 float odo_distance_a;
133 float odo_distance_b;
137 Scheduler::processor_handle MAIN;
138 Scheduler::processor_handle MOTION;
142 int init() __attribute__ ((warn_unused_result));
143 int start() __attribute__ ((warn_unused_result));
146 void set_est_pos_trans(double x, double y, double phi){set_est_pos(trans_x(x), trans_y(y), trans_angle(phi));}
147 void set_est_pos(double x, double y, double phi);
148 void get_est_pos_trans(double &x, double &y, double &phi);
149 void get_est_pos(double &x, double &y, double &phi);