/**
- * robot.h 08/04/20
+ * robot.h 08/04/20
*
* Robot's data structures for the Eurobot 2008.
*
* Competition parameters
*/
enum team_color {
- TC_WHITE = 0, /* Coordinate transformation does not apply */
+ TC_WHITE = 0, /* Coordinate transformation does not apply */
TC_GREEN,
TC_YELLOW
};
enum robot_start_state {
- POWER_ON = 0,
- START_PLUGGED_IN,
- COMPETITION_STARTED,
+ POWER_ON = 0,
+ START_PLUGGED_IN,
+ COMPETITION_STARTED,
};
/**
#ifdef CONFIG_LOCK_CHECKING
#define LOCK_CHECK_COUNT 10
struct lock_log {
- pthread_mutex_t *locked[LOCK_CHECK_COUNT];
- int idx;
+ pthread_mutex_t *locked[LOCK_CHECK_COUNT];
+ int idx;
};
extern struct lock_log robot_lock_log;
#define __LOCK_CHECK(mutex) robot_lock_log.locked[robot_lock_log.idx++] = mutex;
-#define __UNLOCK_CHECK(mutex) \
- if (robot_lock_log.locked[--robot_lock_log.idx] != mutex || \
- robot_lock_log.idx < 0) \
- ul_logerr("!!! Locking error %s:%d\n", __FILE__, __LINE__);
+#define __UNLOCK_CHECK(mutex) \
+ if (robot_lock_log.locked[--robot_lock_log.idx] != mutex || \
+ robot_lock_log.idx < 0) \
+ ul_logerr("!!! Locking error %s:%d\n", __FILE__, __LINE__);
#else
#define __LOCK_CHECK(mutex)
#define __UNLOCK_CHECK(mutex)
* Locks the robot structure.
* @param var Field in the structure you are going to work with.
*/
-#define ROBOT_LOCK(var) \
- do { \
- pthread_mutex_lock(&robot.__robot_lock_##var); \
- __LOCK_CHECK(&robot.__robot_lock_##var); \
- } while(0)
+#define ROBOT_LOCK(var) \
+ do { \
+ pthread_mutex_lock(&robot.__robot_lock_##var); \
+ __LOCK_CHECK(&robot.__robot_lock_##var); \
+ } while(0)
/**
* Unlocks the robot structure.
* @param var Field in the structure, which was locked by ROBOT_LOCK.
*/
-#define ROBOT_UNLOCK(var) \
- do { \
- __UNLOCK_CHECK(&robot.__robot_lock_##var); \
- pthread_mutex_unlock(&robot.__robot_lock_##var); \
- } while(0)
+#define ROBOT_UNLOCK(var) \
+ do { \
+ __UNLOCK_CHECK(&robot.__robot_lock_##var); \
+ pthread_mutex_unlock(&robot.__robot_lock_##var); \
+ } while(0)
/* Mapping of robot structure fields to locks */
-//#define __robot_lock_ lock /* ROBOT_LOCK() */
-#define __robot_lock_ref_pos lock_ref_pos
-#define __robot_lock_est_pos_odo lock_est_pos_odo
-#define __robot_lock_est_pos_indep_odo lock_est_pos_indep_odo
-#define __robot_lock_joy_data lock_joy_data
-#define __robot_lock_meas_angles lock_meas_angles
-#define __robot_lock_drives lock
-#define __robot_lock_sharps lock
-#define __robot_lock_hokuyo lock
+//#define __robot_lock_ lock /* ROBOT_LOCK() */
+#define __robot_lock_ref_pos lock_ref_pos
+#define __robot_lock_est_pos_odo lock_est_pos_odo
+#define __robot_lock_est_pos_indep_odo lock_est_pos_indep_odo
+#define __robot_lock_joy_data lock_joy_data
+#define __robot_lock_meas_angles lock_meas_angles
+#define __robot_lock_drives lock
+#define __robot_lock_sharps lock
+#define __robot_lock_hokuyo lock
#define __robot_lock_sick lock
#define __robot_lock_sick551 lock
-#define __robot_lock_cmu lock
-#define __robot_lock_bumper lock
-#define __robot_lock_disp lock_disp
+#define __robot_lock_cmu lock
+#define __robot_lock_bumper lock
+#define __robot_lock_disp lock_disp
#define __robot_lock_motion_irc lock
-#define __robot_lock_odo_data lock
+#define __robot_lock_odo_data lock
#define __robot_lock_corr_distances lock
#define __robot_lock_camera_result lock_camera
enum robot_status {
- STATUS_OK,
- STATUS_WARNING,
- STATUS_FAILED,
+ STATUS_OK,
+ STATUS_WARNING,
+ STATUS_FAILED,
};
enum robot_component {
- COMPONENT_MOTOR,
- COMPONENT_ODOMETRY,
- COMPONENT_CAMERA,
- COMPONENT_POWER,
- COMPONENT_HOKUYO,
- COMPONENT_SICK,
- COMPONENT_START,
- COMPONENT_JAWS,
- COMPONENT_LIFT,
-
- ROBOT_COMPONENT_NUMBER
+ COMPONENT_MOTOR,
+ COMPONENT_ODOMETRY,
+ COMPONENT_CAMERA,
+ COMPONENT_POWER,
+ COMPONENT_HOKUYO,
+ COMPONENT_SICK,
COMPONENT_SICK551,
+ COMPONENT_START,
+ COMPONENT_JAWS,
+ COMPONENT_LIFT,
+
+ ROBOT_COMPONENT_NUMBER
};
/* robot's main data structure */
struct robot {
- pthread_mutex_t lock;
- pthread_mutex_t lock_ref_pos;
- pthread_mutex_t lock_est_pos_odo;
- pthread_mutex_t lock_est_pos_indep_odo;
- pthread_mutex_t lock_meas_angles;
- pthread_mutex_t lock_joy_data;
- pthread_mutex_t lock_disp;
- pthread_mutex_t lock_camera;
-
- /* competition parameters */
+ pthread_mutex_t lock;
+ pthread_mutex_t lock_ref_pos;
+ pthread_mutex_t lock_est_pos_odo;
+ pthread_mutex_t lock_est_pos_indep_odo;
+ pthread_mutex_t lock_meas_angles;
+ pthread_mutex_t lock_joy_data;
+ pthread_mutex_t lock_disp;
+ pthread_mutex_t lock_camera;
+
+ /* competition parameters */
enum team_color team_color;
- /** State variable used for controlling the robot by pluggin
- * in and out start connector. */
- enum robot_start_state start_state;
-
- /** Temporary storage for new trajectory. After the trajectory creation is
- * finished, this trajectory is submitted to fsmmove. */
- void *new_trajectory;
-
- unsigned char isTrajectory;
- sem_t start;
-
- struct fsm_main_loop main_loop;
-
- /* partial FSMs */
- struct {
- struct robo_fsm main;
- struct robo_fsm motion;
- struct robo_fsm act;
- } fsm;
-
- /* actual position */
- struct robot_pos_type ref_pos;
- /* estimated position */
- struct robot_pos_type est_pos_odo;
- struct robot_pos_type est_pos_indep_odo;
-
- /** True if est_pos_odo is updated according to reception of motion_irc */
- bool odometry_works;
- /** True if est_pos_indep_odo is updated according to reception of motion_indep_odo */
- bool indep_odometry_works;
-
- bool use_back_bumpers;
- bool use_left_bumper;
- bool use_right_bumper;
-
- /** True iff at least one wheel rotates backward */
- bool moves_backward;
-
- /*
- * sometimes H8S does not send queried odometry
- * following flag has been added for EKF estimator,
- * since is has been hardly disturbed by missing measurement
- * (taken as sudden zero velocities)
- */
- bool motion_irc_received;
-
- /* orte */
- struct robottype_orte_data orte;
-
- /* sensors */
- struct motion_irc_type motion_irc; /* motor odometry */
- struct odo_data_type odo_data; /* independent odometry */
- struct corr_distances_type corr_distances; /* ultrasound */
-
- struct lidar_scan_type hokuyo;
- bool ignore_hokuyo;
+ /** State variable used for controlling the robot by pluggin
+ * in and out start connector. */
+ enum robot_start_state start_state;
+
+ /** Temporary storage for new trajectory. After the trajectory creation is
+ * finished, this trajectory is submitted to fsmmove. */
+ void *new_trajectory;
+
+ unsigned char isTrajectory;
+ sem_t start;
+
+ struct fsm_main_loop main_loop;
+
+ /* partial FSMs */
+ struct {
+ struct robo_fsm main;
+ struct robo_fsm motion;
+ struct robo_fsm act;
+ } fsm;
+
+ /* actual position */
+ struct robot_pos_type ref_pos;
+ /* estimated position */
+ struct robot_pos_type est_pos_odo;
+ struct robot_pos_type est_pos_indep_odo;
+
+ /** True if est_pos_odo is updated according to reception of motion_irc */
+ bool odometry_works;
+ /** True if est_pos_indep_odo is updated according to reception of motion_indep_odo */
+ bool indep_odometry_works;
+
+ bool use_back_bumpers;
+ bool use_left_bumper;
+ bool use_right_bumper;
+
+ /** True iff at least one wheel rotates backward */
+ bool moves_backward;
+
+ /*
+ * sometimes H8S does not send queried odometry
+ * following flag has been added for EKF estimator,
+ * since is has been hardly disturbed by missing measurement
+ * (taken as sudden zero velocities)
+ */
+ bool motion_irc_received;
+
+ /* orte */
+ struct robottype_orte_data orte;
+
+ /* sensors */
+ struct motion_irc_type motion_irc; /* motor odometry */
+ struct odo_data_type odo_data; /* independent odometry */
+ struct corr_distances_type corr_distances; /* ultrasound */
+
+ struct lidar_scan_type hokuyo;
+ bool ignore_hokuyo;
struct lidar_scan_type sick;
bool ignore_sick;
int target_ang;
char target_color[3];
- struct map *map; /* Map for pathplanning (no locking) */
+ struct map *map; /* Map for pathplanning (no locking) */
+
+ enum robot_status status[ROBOT_COMPONENT_NUMBER];
- enum robot_status status[ROBOT_COMPONENT_NUMBER];
+ char corns_conf_center;
+ char corns_conf_side;
+ struct corns_group *corns;
- char corns_conf_center;
- char corns_conf_side;
- struct corns_group *corns;
+ bool obstacle_avoidance_enabled;
- bool obstacle_avoidance_enabled;
+ /** is set to true in separate thread when there is short time left */
+ bool short_time_to_end;
+ bool check_turn_safety;
- /** is set to true in separate thread when there is short time left */
- bool short_time_to_end;
- bool check_turn_safety;
-
- float odo_cal_b;
- float odo_cal_a;
- float odo_distance_a;
- float odo_distance_b;
+ float odo_cal_b;
+ float odo_cal_a;
+ float odo_distance_a;
+ float odo_distance_b;
}; /* robot */
extern struct robot robot;
#endif
/*Thread priorities*/
-#define THREAD_PRIO_TRAJ_FOLLOWER 90 /* As high as possible */
+#define THREAD_PRIO_TRAJ_FOLLOWER 90 /* As high as possible */
#define THREAD_PRIO_TRAJ_RECLAC 18
-#define OBST_FORGETING_PRIO 17 /* Priority of the thread for forgeting detected obstacles. */
+#define OBST_FORGETING_PRIO 17 /* Priority of the thread for forgeting detected obstacles. */
-#endif /* ROBOT_H */
+#endif /* ROBOT_H */