5 * @brief Display-ORTE bridge
7 * Copyright: (c) 2010 CTU Dragons
8 * CTU FEE - Department of Control Engineering
15 #include <roboorte_robottype.h>
16 //#include <pthread.h>
22 struct sercom_data* sercom;
24 void rcv_pwr_voltage_cb (const ORTERecvInfo *info, void *vinstance,
25 void *recvCallBackParam)
27 struct robottype_orte_data *orte_data = (struct robottype_orte_data *)recvCallBackParam;
28 switch (info->status) {
30 uoled_display_voltage(&orte_data->pwr_voltage);
31 uoled_display_status(PWR, STATUS_OK);
34 printf("ORTE deadline occurred - PWR_VOLTAGE\n");
35 uoled_display_status(PWR, STATUS_FAILED);
40 void rcv_odo_data_cb(const ORTERecvInfo *info, void *vinstance,
41 void *recvCallBackParam)
43 //struct odo_data_type *instance = (struct odo_data_type *)vinstance;
44 switch (info->status) {
46 uoled_display_status(HOK, STATUS_OK);
49 printf("ORTE deadline occurred - ODO_DATA\n");
50 uoled_display_status(HOK, STATUS_FAILED);
55 void rcv_motion_irc_cb(const ORTERecvInfo *info, void *vinstance,
56 void *recvCallBackParam)
58 //struct motion_irc_type*instance = (struct motion_irc_type*)vinstance;
59 switch (info->status) {
61 uoled_display_status(MOT, STATUS_OK);
64 printf("ORTE deadline occurred - MOTION_IRC\n");
65 uoled_display_status(MOT, STATUS_FAILED);
70 void rcv_camera_result_cb(const ORTERecvInfo *info, void *vinstance,
71 void *recvCallBackParam)
73 //struct camera_result_type *instance = (struct camera_result_type *)vinstance;
74 switch (info->status) {
76 uoled_display_status(CAM, STATUS_OK);
79 printf("ORTE deadline occurred - CAMERA_RESULT\n");
80 uoled_display_status(CAM, STATUS_FAILED);
85 void rcv_ref_pos_cb (const ORTERecvInfo *info, void *vinstance,
86 void *recvCallBackParam)
88 struct robottype_orte_data *orte_data = (struct robottype_orte_data *)recvCallBackParam;
89 switch (info->status) {
91 uoled_display_position(&orte_data->ref_pos);
94 printf("ORTE deadline occurred - REF_POS\n");
99 void rcv_est_pos_odo_cb (const ORTERecvInfo *info, void *vinstance,
100 void *recvCallBackParam)
102 struct robottype_orte_data *orte_data = (struct robottype_orte_data *)recvCallBackParam;
103 switch (info->status) {
105 uoled_display_position(&orte_data->est_pos_odo);
106 uoled_display_status(ODO, STATUS_FAILED);
109 printf("ORTE deadline occurred - EST_POS_ODO\n");
110 uoled_display_status(ODO, STATUS_FAILED);
115 int main(int argc, char *argv[])
117 //fd_set read_fd_set;
118 //struct timeval timeout;
122 struct robottype_orte_data orte;
127 //struct can_frame frame;
128 tty = getenv("DISPLAY_TTY");
131 printf("displayd: enviroment variable 'DISPLAY_TTY' was not set, using default value '%s'.\n", tty);
134 sercom = uoled_init(tty, NULL);
135 if (strcmp(tty, "/dev/null") != 0) {
137 printf("displayd: init serial communication OK\n");
139 printf("displayd: init serial communication failed\n");
145 /* orte initialization */
146 if(robottype_roboorte_init(&orte)) {
147 printf("Roboorte initialization failed! Exiting...\n");
151 printf("Roboorte OK\n");
153 /* creating publishers */
154 //robottype_publisher_pwr_voltage_create(&orte, NULL, NULL);
155 //robottype_publisher_motion_status_create(&orte, NULL, NULL);
156 //robottype_publisher_odo_data_create(&orte, NULL, NULL);
157 //robottype_publisher_motion_irc_create(&orte, NULL, NULL);
158 //robottype_publisher_robot_cmd_create(&orte, NULL, NULL);
159 //robottype_publisher_corr_trig_create(&orte, NULL, NULL);
160 //robottype_publisher_corr_distances_create(&orte, NULL, NULL);
161 //robottype_publisher_actuator_status_create(&orte, NULL, NULL);
162 //printf("Publishers OK\n");
164 /* creating subscribers */
165 robottype_subscriber_odo_data_create(&orte, rcv_odo_data_cb, &orte);
166 robottype_subscriber_motion_irc_create(&orte, rcv_motion_irc_cb, &orte);
167 robottype_subscriber_pwr_voltage_create(&orte, rcv_pwr_voltage_cb, &orte);
168 robottype_subscriber_est_pos_odo_create(&orte, rcv_est_pos_odo_cb, &orte);
169 robottype_subscriber_ref_pos_create(&orte, rcv_ref_pos_cb, &orte);
170 //robottype_subscriber_pwr_alert_create(&orte, rcv_pwr_alert_cb, &orte);
171 //robottype_subscriber_motion_speed_create(&orte, rcv_motion_speed_cb, &orte);
172 //robottype_subscriber_can_msg_create(&orte, rcv_can_msg_cb, &orte);
173 //robottype_subscriber_hokuyo_pitch_create(&orte, rcv_hokuyo_pitch_cb, &orte);
174 robottype_subscriber_camera_result_create(&orte, rcv_camera_result_cb, &orte);
176 printf("subscribers created OK\n");
181 if (strcmp(tty, "/dev/null") != 0) {
183 sigwait(&sigset, &sig);
186 // spracovani serioveho portu, pri prijmu dat...