From 7cbf02166022097b5a375391cb3a958e7bfc98ae Mon Sep 17 00:00:00 2001 From: Michal Sojka Date: Thu, 29 Apr 2010 22:36:46 +0200 Subject: [PATCH] cand: Publish status of robot switches --- src/cand/cand.cc | 6 ++++++ src/common/can_ids.h | 2 +- src/common/can_msg_def.h | 3 +++ src/types/robottype.idl | 5 +++++ src/types/robottype.ortegen | 3 ++- 5 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/cand/cand.cc b/src/cand/cand.cc index 12687323..12f3c6d6 100644 --- a/src/cand/cand.cc +++ b/src/cand/cand.cc @@ -182,6 +182,11 @@ void cand_parse_frame(struct robottype_orte_data *orte, struct can_frame frame) orte->robot_cmd.start_condition = frame.data[0]; ORTEPublicationSend(orte->publication_robot_cmd); break; + case CAN_ROBOT_SWITCHES: + orte->robot_switches.bumper_pressed = !!(frame.data[0] & CAN_SWITCH_BUMPER); + orte->robot_switches.team_color = (frame.data[0] & CAN_SWITCH_COLOR) ? 1 : 0; + ORTEPublicationSend(orte->publication_robot_switches); + break; /* positioning by odometry */ case CAN_ODO_DATA: @@ -377,6 +382,7 @@ int main(int argc, char *argv[]) robottype_publisher_odo_data_create(&orte, NULL, NULL); robottype_publisher_motion_irc_create(&orte, NULL, NULL); robottype_publisher_robot_cmd_create(&orte, NULL, NULL); + robottype_publisher_robot_switches_create(&orte, NULL, NULL); robottype_publisher_vidle_status_create(&orte, NULL, NULL); printf("Publishers OK\n"); diff --git a/src/common/can_ids.h b/src/common/can_ids.h index 73d2631d..fdcf1b7c 100644 --- a/src/common/can_ids.h +++ b/src/common/can_ids.h @@ -67,7 +67,7 @@ //#define CAN_ERROR to_boa(0x48) // FIXME: (F.J.) rename me, ... - +#define CAN_ROBOT_SWITCHES to_boa(0x47) #define CAN_VIDLE_STATUS to_boa(0x48) #define CAN_VIDLE_CMD to_per(0x49) diff --git a/src/common/can_msg_def.h b/src/common/can_msg_def.h index 4f561de6..73ad911f 100644 --- a/src/common/can_msg_def.h +++ b/src/common/can_msg_def.h @@ -3,3 +3,6 @@ #define CAN_VIDLE_INITIALIZING 0x01 #define CAN_VIDLE_TIMEOUT 0x02 #define CAN_VIDLE_OUT_OF_BOUNDS 0x04 + +#define CAN_SWITCH_BUMPER 0x01 +#define CAN_SWITCH_COLOR 0x02 diff --git a/src/types/robottype.idl b/src/types/robottype.idl index ea68bdde..c1c1c9d8 100644 --- a/src/types/robottype.idl +++ b/src/types/robottype.idl @@ -62,6 +62,11 @@ struct robot_cmd { boolean start_condition; }; +struct robot_switches { + boolean bumper_pressed; + octet team_color; +}; + struct can_msg { octet data[8]; octet len; diff --git a/src/types/robottype.ortegen b/src/types/robottype.ortegen index 5660ca21..b32e359f 100644 --- a/src/types/robottype.ortegen +++ b/src/types/robottype.ortegen @@ -17,7 +17,8 @@ type=pwr_alert topic=pwr_alert type=pwr_ctrl topic=pwr_ctrl type=pwr_voltage topic=pwr_voltage type=robot_pos topic=ref_pos -type=robot_cmd topic=robot_cmd +type=robot_cmd topic=robot_cmd deadline=1 +type=robot_switches topic=robot_switches deadline=1 type=camera_result topic=camera_result type=camera_control topic=camera_control type=fsm_state topic=fsm_main pubdelay=1 -- 2.39.2