]> rtime.felk.cvut.cz Git - eurobot/public.git/commitdiff
Merge remote-tracking branch 'origin/personal/pokormat/moniky_color-finder' into...
authorMichal Vokac <vokac.m@gmail.com>
Tue, 2 Oct 2012 17:51:23 +0000 (19:51 +0200)
committerMichal Vokac <vokac.m@gmail.com>
Tue, 2 Oct 2012 17:51:23 +0000 (19:51 +0200)
14 files changed:
src/cand/cand.cc
src/common/can_msg_def.h
src/display-qt/display_orte.cpp
src/display-qt/display_orte.h
src/display-qt/displayqt.cpp
src/display-qt/displayqt.ui
src/display-qt/ortesignals.cpp
src/display-qt/promene.h
src/eb_jaws_11/main.c
src/robofsm/movehelper.h
src/robofsm/robot.c
src/robofsm/robot.h
src/types/robottype.idl
src/types/robottype.ortegen

index f17073d8851a61e24250a12854bcb73cd8473848..a3dff71ee7b6786e6970030301cb5228cae04f5c 100644 (file)
@@ -165,6 +165,10 @@ void cand_parse_frame(struct robottype_orte_data *orte, struct can_frame frame)
 
        switch(frame.can_id) {
                /* robot commands (start, ..) */
+                case CAN_CL_SENSOR_STATUS:
+                        orte->cl_sensor_status.pattern_match = frame.data[0];
+                        ORTEPublicationSend(orte->publication_cl_sensor_status);
+                        break;
                case CAN_JAW_LEFT_STATUS:
                        orte->jaws_status.act_pos.left = (frame.data[0] << 8) | frame.data[1];
                        orte->jaws_status.response.left = (frame.data[2] << 8) | frame.data[3];
@@ -188,8 +192,15 @@ void cand_parse_frame(struct robottype_orte_data *orte, struct can_frame frame)
                        ORTEPublicationSend(orte->publication_robot_cmd);
                        break;
                case CAN_ROBOT_SWITCHES:
-                       orte->robot_switches.team_color = (frame.data[0] & CAN_SWITCH_COLOR) ? 1 : 0;
+                        /*
+                        char tmp_color = 0;
+                        if (frame.data[0] & CAN_SWITCH_COLOR_0) tmp_color += 1;
+                        if (frame.data[0] & CAN_SWITCH_COLOR_1) tmp_color += 2;
+                       orte->robot_switches.team_color = tmp_color;
+                        */
+                        orte->robot_switches.team_color = frame.data[0] & (CAN_SWITCH_COLOR_0 + CAN_SWITCH_COLOR);
                        orte->robot_switches.strategy = (frame.data[0] & CAN_SWITCH_STRATEGY ? 1 : 0);
+                        orte->robot_switches.home = (frame.data[0] & CAN_SWITCH_HOME ? 1 : 0);
                        ORTEPublicationSend(orte->publication_robot_switches);
                        break;
                case CAN_ROBOT_BUMPERS:
@@ -360,7 +371,23 @@ void rcv_lift_cmd_cb(const ORTERecvInfo *info, void *vinstance,
                        break;
                case DEADLINE:
                        break;
+        }
 }
+
+void rcv_cl_sensor_cmd_cb(const ORTERecvInfo *info, void *vinstance,
+                      void *recvCallBackParam)
+{
+        struct robottype_orte_data *orte_data = (struct robottype_orte_data *)recvCallBackParam;
+
+        switch (info->status) {
+                case NEW_DATA:
+                        unsigned char data[1];
+                        data[0] = orte_data->bank_nbr;
+                        can_send(CAN_CL_SENSOR_CMD, 1, data);
+                        break;
+                case DEADLINE:
+                        break;
+        }
 }
 
 int main(int argc, char *argv[])
@@ -398,6 +425,7 @@ int main(int argc, char *argv[])
        robottype_publisher_robot_bumpers_create(&orte, NULL, NULL);
        robottype_publisher_jaws_status_create(&orte, NULL, NULL);
         robottype_publisher_lift_status_create(&orte, NULL, NULL);
+        robottype_publisher_cl_sensor_status_create(&orte, NULL, NULL);
        printf("Publishers OK\n");
 
        /* creating subscribers */
@@ -406,8 +434,7 @@ int main(int argc, char *argv[])
        robottype_subscriber_jaws_cmd_create(&orte, rcv_jaws_cmd_cb, &orte);
         robottype_subscriber_lift_cmd_create(&orte, rcv_lift_cmd_cb, &orte);
        robottype_subscriber_can_msg_create(&orte, rcv_can_msg_cb, &orte);
-
-
+        robottype_subscriber_cl_sensor_cmd_create(&orte, rcv_cl_sensor_cmd_cb, &orte);
        printf("subscribers OK\n");
 
        /* main loop */
index 42bcc4649a0da1926a8da72dbdc42b3888543279..add5ba440e5006d2a6821cdb21d55fcb497b9275 100644 (file)
 #define CAN_JAW_OUT_OF_BOUNDS           0x04
 
 //flags sent in CAN_SWITCHES
-#define CAN_SWITCH_COLOR_0     2
+// COLOR_0 = 1, COLOR_1 = 2, see team color list in robot.h
+#define CAN_SWITCH_COLOR_0     1       
+#define CAN_SWITCH_COLOR_1      2
 #define CAN_SWITCH_STRATEGY    4
-#define CAN_SWITCH_COLOR_1     8
-#define CAN_SWITCH_HOME                16
+#define CAN_SWITCH_HOME                8
 
 //flags sent in CAN_ROBOT_BUMPERS
 #define CAN_BUMPER_REAR_LEFT           1
 #define CAN_PWR_BATT_LOW        0x20
 #define CAN_PWR_BATT_CRITICAL   0x40
 
+/* flags in CAN_CL_SENSOR_STATUS */
+#define CAN_CL_SENSOR_PATTERN_MATCH     0x01
+
+/* flags in CAN_CL_SENSOR_CMD */
+#define CAN_CL_SENSOR_BANK_1    0x01
+#define CAN_CL_SENSOR_BANK_2    0x02
+#define CAN_CL_SENSOR_BANK_3    0x03
+
 #endif
index 272b94537b5de18455a71a1ba250c406472c2b31..402393e63382fc4e595a05ba038681f195984103 100644 (file)
@@ -54,16 +54,16 @@ bool miliseconds_elapsed_since(struct timespec *t, unsigned miliseconds)
 void rcv_match_time_cb (const ORTERecvInfo *info, void *vinstance, void *recvCallBackParam)
 {
        OrteSignals *inst=(OrteSignals *)recvCallBackParam;
-       UDE_hw_status_t status = STATUS_FAILED;
+       UDE_hw_status_t status = UDE_HW_STATUS_FAILED;
        static UDE_hw_status_t last_status;
        static struct timespec last_sent;
         switch (info->status) {
                case NEW_DATA:
                        inst->time_con();
-                       status = STATUS_OK;
+                       status = UDE_HW_STATUS_OK;
                        break;
                case DEADLINE:
-                       status = STATUS_FAILED;
+                       status = UDE_HW_STATUS_FAILED;
                        break;
        }
        if (status != last_status ||
@@ -77,16 +77,16 @@ void rcv_match_time_cb (const ORTERecvInfo *info, void *vinstance, void *recvCal
 void rcv_pwr_voltage_cb (const ORTERecvInfo *info, void *vinstance, void *recvCallBackParam)
 {
        OrteSignals *inst=(OrteSignals *)recvCallBackParam;
-       UDE_hw_status_t status = STATUS_FAILED;
+       UDE_hw_status_t status = UDE_HW_STATUS_FAILED;
        static UDE_hw_status_t last_status;
        static struct timespec last_sent;
         switch (info->status) {
                case NEW_DATA:
                        inst->pwr_con();
-                       status = STATUS_OK;
+                       status = UDE_HW_STATUS_OK;
                        break;
                case DEADLINE:
-                       status = STATUS_FAILED;
+                       status = UDE_HW_STATUS_FAILED;
                        break;
        }
        if (status != last_status ||
@@ -100,15 +100,15 @@ void rcv_pwr_voltage_cb (const ORTERecvInfo *info, void *vinstance, void *recvCa
 void rcv_odo_data_cb(const ORTERecvInfo *info, void *vinstance, void *recvCallBackParam)
 {
        OrteSignals *inst=(OrteSignals *)recvCallBackParam;
-       UDE_hw_status_t status = STATUS_FAILED;
+       UDE_hw_status_t status = UDE_HW_STATUS_FAILED;
        static UDE_hw_status_t last_status;
        static struct timespec last_sent;
        switch (info->status) {
                case NEW_DATA:
-                       status = STATUS_OK;
+                       status = UDE_HW_STATUS_OK;
                        break;
                case DEADLINE:
-                       status = STATUS_FAILED;
+                       status = UDE_HW_STATUS_FAILED;
                        break;
        }
        if (status != last_status ||
@@ -122,7 +122,7 @@ void rcv_odo_data_cb(const ORTERecvInfo *info, void *vinstance, void *recvCallBa
 void rcv_robot_cmd_cb(const ORTERecvInfo *info, void *vinstance, void *recvCallBackParam)
 {
        OrteSignals *inst=(OrteSignals *)recvCallBackParam;
-       UDE_hw_status_t status = STATUS_FAILED;
+       UDE_hw_status_t status = UDE_HW_STATUS_FAILED;
        static UDE_hw_status_t last_status;
        static struct timespec last_sent;
        struct robot_cmd_type *instance = (struct robot_cmd_type *)vinstance;
@@ -130,12 +130,12 @@ void rcv_robot_cmd_cb(const ORTERecvInfo *info, void *vinstance, void *recvCallB
        switch (info->status) {
                case NEW_DATA:
                        if (instance->start_condition)
-                               status = STATUS_WARNING; /* Start plug must be plugged before competition start */
+                               status = UDE_HW_STATUS_WARNING; /* Start plug must be plugged before competition start */
                        else
-                               status = STATUS_OK;
+                               status = UDE_HW_STATUS_OK;
                        break;
                case DEADLINE:
-                       status = STATUS_FAILED;
+                       status = UDE_HW_STATUS_FAILED;
                        break;
        }
        if (status != last_status ||
@@ -150,7 +150,7 @@ void rcv_robot_cmd_cb(const ORTERecvInfo *info, void *vinstance, void *recvCallB
 void rcv_robot_swicthes_cb(const ORTERecvInfo *info, void *vinstance, void *recvCallBackParam)
 {
        OrteSignals *inst=(OrteSignals *)recvCallBackParam;
-       UDE_hw_status_t status = STATUS_FAILED;
+       UDE_hw_status_t status = UDE_HW_STATUS_FAILED;
        static char last_color;
        static struct timespec last_sent;
        struct robot_switches_type *instance = (struct robot_switches_type *)vinstance;
@@ -164,7 +164,7 @@ void rcv_robot_swicthes_cb(const ORTERecvInfo *info, void *vinstance, void *recv
                        }
                        last_color = instance->team_color;
                case DEADLINE:
-                       status = STATUS_FAILED;
+                       status = UDE_HW_STATUS_FAILED;
                        break;
        }
 }
@@ -173,18 +173,18 @@ void rcv_motion_status_cb(const ORTERecvInfo *info, void *vinstance, void *recvC
 {
        OrteSignals *inst=(OrteSignals *)recvCallBackParam;
        struct motion_status_type *m = (struct motion_status_type *)vinstance;
-       UDE_hw_status_t status = STATUS_FAILED;
+       UDE_hw_status_t status = UDE_HW_STATUS_FAILED;
        static UDE_hw_status_t last_status;
        static struct timespec last_sent;
        switch (info->status) {
                case NEW_DATA:
                        if (m->err_left == 0 && m->err_right == 0)
-                               status = STATUS_OK;
+                               status = UDE_HW_STATUS_OK;
                        else
-                               status = STATUS_WARNING;
+                               status = UDE_HW_STATUS_WARNING;
                        break;
                case DEADLINE:
-                       status = STATUS_FAILED;
+                       status = UDE_HW_STATUS_FAILED;
                        break;
        }
        if (status != last_status ||
@@ -195,48 +195,22 @@ void rcv_motion_status_cb(const ORTERecvInfo *info, void *vinstance, void *recvC
        last_status = status;
 }
 
-void rcv_lift_status_cb(const ORTERecvInfo *info, void *vinstance, void *recvCallBackParam)
-{
-       OrteSignals *inst=(OrteSignals *)recvCallBackParam;
-       struct lift_status_type *m = (struct lift_status_type *)vinstance;
-       UDE_hw_status_t status = STATUS_FAILED;
-       static UDE_hw_status_t last_status;
-       static struct timespec last_sent;
-       switch (info->status) {
-               case NEW_DATA:
-                       if (m->flags)
-                               status = STATUS_OK;
-                       else
-                               status = STATUS_WARNING;
-                       break;
-               case DEADLINE:
-                       status = STATUS_FAILED;
-                       break;
-       }
-       if (status != last_status ||
-           miliseconds_elapsed_since(&last_sent, 1000)) {
-               inst->status_con(LFT, status);
-               clock_gettime(CLOCK_MONOTONIC, &last_sent);
-       }
-       last_status = status;
-}
-
 void rcv_jaws_status_cb(const ORTERecvInfo *info, void *vinstance, void *recvCallBackParam)
 {
         OrteSignals *inst=(OrteSignals *)recvCallBackParam;
         struct jaws_status_type *m = (struct jaws_status_type *)vinstance;
-        UDE_hw_status_t status = STATUS_FAILED;
+        UDE_hw_status_t status = UDE_HW_STATUS_FAILED;
         static UDE_hw_status_t last_status;
         static struct timespec last_sent;
         switch (info->status) {
                 case NEW_DATA:
                         if (m->flags.left == 0 && m->flags.right == 0)
-                                status = STATUS_OK;
+                                status = UDE_HW_STATUS_OK;
                         else
-                                status = STATUS_WARNING;
+                                status = UDE_HW_STATUS_WARNING;
                         break;
                 case DEADLINE:
-                        status = STATUS_FAILED;
+                        status = UDE_HW_STATUS_FAILED;
                         break;
         }
         if (status != last_status ||
@@ -255,15 +229,15 @@ void rcv_camera_result_cb(const ORTERecvInfo *info, void *vinstance, void *recvC
 void rcv_hokuyo_scan_cb(const ORTERecvInfo *info, void *vinstance, void *recvCallBackParam)
 {
        OrteSignals *inst=(OrteSignals *)recvCallBackParam;
-       UDE_hw_status_t status = STATUS_FAILED;
+       UDE_hw_status_t status = UDE_HW_STATUS_FAILED;
        static UDE_hw_status_t last_status;
        static struct timespec last_sent;
        switch (info->status) {
                case NEW_DATA:
-                       status = STATUS_OK;
+                       status = UDE_HW_STATUS_OK;
                        break;
                case DEADLINE:
-                       status = STATUS_FAILED;
+                       status = UDE_HW_STATUS_FAILED;
                        break;
        }
        if (status != last_status ||
@@ -274,24 +248,46 @@ void rcv_hokuyo_scan_cb(const ORTERecvInfo *info, void *vinstance, void *recvCal
        last_status = status;
 }
 
+void rcv_sick_scan_cb(const ORTERecvInfo *info, void *vinstance, void *recvCallBackParam)
+{
+        OrteSignals *inst=(OrteSignals *)recvCallBackParam;
+        UDE_hw_status_t status = UDE_HW_STATUS_FAILED;
+        static UDE_hw_status_t last_status;
+        static struct timespec last_sent;
+        switch (info->status) {
+                case NEW_DATA:
+                        status = UDE_HW_STATUS_OK;
+                        break;
+                case DEADLINE:
+                        status = UDE_HW_STATUS_FAILED;
+                        break;
+        }
+        if (status != last_status ||
+            miliseconds_elapsed_since(&last_sent, 1000)) {
+                inst->status_con(SIC, status);
+                clock_gettime(CLOCK_MONOTONIC, &last_sent);
+        }
+        last_status = status;
+}
+
 void rcv_est_pos_best_cb (const ORTERecvInfo *info, void *vinstance, void *recvCallBackParam)
 {
        OrteSignals *inst=(OrteSignals *)recvCallBackParam;
-       UDE_hw_status_t status = STATUS_FAILED;
+       UDE_hw_status_t status = UDE_HW_STATUS_FAILED;
        static UDE_hw_status_t last_status;
        static struct timespec last_sent;
         switch (info->status) {
                case NEW_DATA:
-                       status = STATUS_OK;
+                       status = UDE_HW_STATUS_OK;
                        break;
                case DEADLINE:
-                       status = STATUS_FAILED;
+                       status = UDE_HW_STATUS_FAILED;
                        break;
        }
        if (status != last_status ||
            miliseconds_elapsed_since(&last_sent, 100)) {
                inst->status_con(APP, status);
-               if (status == STATUS_OK)
+               if (status == UDE_HW_STATUS_OK)
                        inst->position_con();
                clock_gettime(CLOCK_MONOTONIC, &last_sent);
        }
index 929b84bbb2241546a44385640e9fa256269373a8..ced9012b7d263b6a1e53beeed5c7f6441de997cf 100644 (file)
@@ -20,14 +20,14 @@ void rcv_robot_swicthes_cb(const ORTERecvInfo *info, void *vinstance, void *recv
 
 void rcv_motion_status_cb(const ORTERecvInfo *info, void *vinstance, void *recvCallBackParam);
 
-void rcv_lift_status_cb(const ORTERecvInfo *info, void *vinstance, void *recvCallBackParam);
-
 void rcv_jaws_status_cb(const ORTERecvInfo *info, void *vinstance, void *recvCallBackParam);
 
 void rcv_camera_result_cb(const ORTERecvInfo *info, void *vinstance, void *recvCallBackParam);
 
 void rcv_hokuyo_scan_cb(const ORTERecvInfo *info, void *vinstance, void *recvCallBackParam);
 
+void rcv_sick_scan_cb(const ORTERecvInfo *info, void *vinstance, void *recvCallBackParam);
+
 void rcv_est_pos_best_cb (const ORTERecvInfo *info, void *vinstance, void *recvCallBackParam);
 
 void rcv_fsm_main_cb(const ORTERecvInfo *info, void *vinstance, void *recvCallBackParam);
index 31538dc6cb73b645ee016bc30cdc3c07cd5c0324..96d96a7b2e5de21103cfde07648f3a46b68f5b84 100644 (file)
@@ -5,6 +5,7 @@
 #include <QTimer>
 #include <QString>
 #include <robomath.h>
+#include <robot.h>
 
 //backround colors for labels
 #define GREEN "background-color:rgb(27, 255, 11)"
@@ -124,17 +125,20 @@ void DisplayQT::display_time(double time)
        ui->matchTime->display(time);
 }
 
-// 0-fialova
-// 1-cervena
+
 void DisplayQT::setTeamColor(char color)
 {
-       if(color==0){
-               color=0;
-               ui->our_color->setStyleSheet("background-color: violet");
-       }else if(color==1){
-               color=1;
-               ui->our_color->setStyleSheet("background-color: red");
-       }
+       switch (color) {
+                case TC_WHITE:
+                        ui->our_color->setStyleSheet("background-color: white");
+                break;
+                case TC_GREEN:
+                        ui->our_color->setStyleSheet("background-color: green");
+                break;
+                case TC_YELLOW:
+                        ui->our_color->setStyleSheet("background-color: yellow");
+                break;
+        }
 }
 
 void DisplayQT::setPosition(double x, double y, double phi)
@@ -162,33 +166,33 @@ void DisplayQT::display_status(UDE_component_t c, UDE_hw_status_t s)
        switch(c){
                case 0:break;
                case MOT:
-                       if(s==STATUS_OK)
+                       if(s==UDE_HW_STATUS_OK)
                                ui->comp_MOT->setStyleSheet(GREEN);
-                       else if(s==STATUS_FAILED)
+                       else if(s==UDE_HW_STATUS_FAILED)
                                ui->comp_MOT->setStyleSheet(RED);
                        else
                                ui->comp_MOT->setStyleSheet(YELLOW);
                break;
                case ODO:
-                       if(s==STATUS_OK)
+                       if(s==UDE_HW_STATUS_OK)
                                ui->comp_ODO->setStyleSheet(GREEN);
-                       else if(s==STATUS_FAILED)
+                       else if(s==UDE_HW_STATUS_FAILED)
                                ui->comp_ODO->setStyleSheet(RED);
                        else
                                ui->comp_ODO->setStyleSheet(YELLOW);
                break;
                case JAW:
-                       if(s==STATUS_OK)
+                       if(s==UDE_HW_STATUS_OK)
                                ui->comp_JAW->setStyleSheet(GREEN);
-                       else if(s==STATUS_FAILED)
+                       else if(s==UDE_HW_STATUS_FAILED)
                                ui->comp_JAW->setStyleSheet(RED);
                        else
                                ui->comp_JAW->setStyleSheet(YELLOW);
                        break;
                case PWR:
-                       if(s==STATUS_OK)
+                       if(s==UDE_HW_STATUS_OK)
                                ui->comp_PWR->setStyleSheet(GREEN);
-                       else if(s==STATUS_FAILED){
+                       else if(s==UDE_HW_STATUS_FAILED){
                                ui->comp_PWR->setStyleSheet(RED);
 
                                ui->voltage_33->setText("v.33 = ?");
@@ -205,17 +209,17 @@ void DisplayQT::display_status(UDE_component_t c, UDE_hw_status_t s)
                                ui->comp_PWR->setStyleSheet(YELLOW);
                break;
                case HOK:
-                       if(s==STATUS_OK)
+                       if(s==UDE_HW_STATUS_OK)
                                ui->comp_HOK->setStyleSheet(GREEN);
-                       else if(s==STATUS_FAILED)
+                       else if(s==UDE_HW_STATUS_FAILED)
                                ui->comp_HOK->setStyleSheet(RED);
                        else
                                ui->comp_HOK->setStyleSheet(YELLOW);
                        break;
                case APP:
-                       if(s==STATUS_OK)
+                       if(s==UDE_HW_STATUS_OK)
                                ui->comp_APP->setStyleSheet(GREEN);
-                       else if(s==STATUS_FAILED){
+                       else if(s==UDE_HW_STATUS_FAILED){
                                ui->comp_APP->setStyleSheet(RED);
 
                                pos.positionIsActual=false;
@@ -227,26 +231,26 @@ void DisplayQT::display_status(UDE_component_t c, UDE_hw_status_t s)
                        else
                                ui->comp_APP->setStyleSheet(YELLOW);
                        break;
-               case LFT:
-                       if(s==STATUS_OK)
-                               ui->comp_LFT->setStyleSheet(GREEN);
-                       else if(s==STATUS_FAILED)
-                               ui->comp_LFT->setStyleSheet(RED);
+               case SIC:
+                       if(s==UDE_HW_STATUS_OK)
+                               ui->comp_SIC->setStyleSheet(GREEN);
+                       else if(s==UDE_HW_STATUS_FAILED)
+                               ui->comp_SIC->setStyleSheet(RED);
                        else
-                               ui->comp_LFT->setStyleSheet(YELLOW);
+                               ui->comp_SIC->setStyleSheet(YELLOW);
                        break;
                case STA:
-                       if(s==STATUS_OK)
+                       if(s==UDE_HW_STATUS_OK)
                                ui->comp_STA->setStyleSheet(GREEN);
-                       else if(s==STATUS_FAILED)
+                       else if(s==UDE_HW_STATUS_FAILED)
                                ui->comp_STA->setStyleSheet(RED);
                        else
                                ui->comp_STA->setStyleSheet(YELLOW);
                         break;
                 case TIM:
-                        if(s==STATUS_OK)
+                        if(s==UDE_HW_STATUS_OK)
                                 ui->matchTime->setStyleSheet(GREEN);
-                        else if(s==STATUS_FAILED)
+                        else if(s==UDE_HW_STATUS_FAILED)
                                 ui->matchTime->setStyleSheet(RED);
                         else
                                 ui->matchTime->setStyleSheet(YELLOW);
index f8e75869e1b5afbf264fc4a5fbda07a342d97e60..6ac3986c6edb45e96c6d248b05313296a3f2f5f8 100644 (file)
      </widget>
     </item>
     <item>
-     <widget class="QLabel" name="comp_APP">
+     <widget class="QLabel" name="comp_SIC">
       <property name="font">
        <font>
         <pointsize>12</pointsize>
        <string notr="true">background-color: rgb(255, 0, 0);</string>
       </property>
       <property name="text">
-       <string>APP</string>
+       <string>SIC</string>
       </property>
       <property name="alignment">
        <set>Qt::AlignCenter</set>
      </widget>
     </item>
     <item>
-     <widget class="QLabel" name="comp_LFT">
+     <widget class="QLabel" name="comp_APP">
       <property name="font">
        <font>
         <pointsize>12</pointsize>
        <string notr="true">background-color: rgb(255, 0, 0);</string>
       </property>
       <property name="text">
-       <string>LFT</string>
+       <string>APP</string>
       </property>
       <property name="alignment">
        <set>Qt::AlignCenter</set>
index 265c357531d8272a4fad71480fbcba80a1a81010..42a8a27dad364e6274fdf30315bdf71c915815d7 100644 (file)
@@ -15,11 +15,11 @@ void OrteSignals::createOrte()
        //subscribers
        robottype_subscriber_odo_data_create(&orte, rcv_odo_data_cb, this);
        robottype_subscriber_motion_status_create(&orte, rcv_motion_status_cb, this);
-       robottype_subscriber_lift_status_create(&orte, rcv_lift_status_cb, this);
         robottype_subscriber_jaws_status_create(&orte, rcv_jaws_status_cb, this);
        robottype_subscriber_pwr_voltage_create(&orte, rcv_pwr_voltage_cb, this);
        robottype_subscriber_est_pos_best_create(&orte, rcv_est_pos_best_cb, this);
        robottype_subscriber_hokuyo_scan_create(&orte, rcv_hokuyo_scan_cb, this);
+        robottype_subscriber_sick_scan_create(&orte, rcv_sick_scan_cb, this);
        robottype_subscriber_camera_result_create(&orte, rcv_camera_result_cb, &orte); //nebude uzito
        robottype_subscriber_fsm_main_create(&orte, rcv_fsm_main_cb, this);
        robottype_subscriber_fsm_act_create(&orte, rcv_fsm_act_cb, this);
index d38a988cadf62723aa692381b188dffd98efdd46..591e489da632fe5661179e2031782df9c8b4fc6b 100644 (file)
@@ -2,15 +2,15 @@
 #define PROMENE_H
 
 /**
- * 0. (neni pouzito)
- * 1. MOT - ridici jednotka motoru
- * 2. ODO - odometrie
+ * 0. (not used)
+ * 1. MOT - motor control unit
+ * 2. ODO - odometry
  * 3. JAW - jaws
- * 4. PWR - napajeci zdroje
+ * 4. PWR - power sources
  * 5. HOK - Hokuyo
- * 6. APP - ridici aplikace
- * 7. LFT - lift
- * 8. STA - startovaci tlacitko
+ * 6. SIC - Sick
+ * 6. APP - control application (strategy)
+ * 8. STA - start button
  */
 typedef enum {
         UKN = 0,
@@ -19,8 +19,8 @@ typedef enum {
         JAW = 3,
         PWR = 4,
         HOK = 5,
-        APP = 6,
-        LFT = 7,
+        SIC = 6,
+        APP = 7,
         STA = 8,
         TIM = 9
 } UDE_component_t;
@@ -31,9 +31,9 @@ typedef enum {
  * 10 = HW_STATUS_WARNING
  */
 typedef enum {
-        STATUS_FAILED = 0,
-        STATUS_OK = 1,
-        STATUS_WARNING = 2
+        UDE_HW_STATUS_FAILED = 0,
+        UDE_HW_STATUS_OK = 1,
+        UDE_HW_STATUS_WARNING = 2
 } UDE_hw_status_t;
 
 /** ID_DISPLAY_FSM + ...
index 350d07b98c1bd7beba30718103d929e3e30e6bc4..9d3251b46434230c53f9869223276bb8145ffaa0 100644 (file)
@@ -175,7 +175,8 @@ void robot_switches_handler()
                else
                        sw |= CAN_SWITCH_HOME;
                
-               if ((sw & CAN_SWITCH_COLOR_0) && (sw & CAN_SWITCH_COLOR_1)){
+                // COLOR_0 = 1, COLOR_1 = 2, see team color list in robot.h
+               if (!(sw & CAN_SWITCH_COLOR_0) && !(sw & CAN_SWITCH_COLOR_1)){
                        deb_led_off(LEDY);
                
                        send_rs_str("white\n");}
@@ -321,7 +322,7 @@ void CAN_rx(can_msg_t *msg) {
                break;
                case CAN_CL_SENSOR_CMD:
                        deb_led_on(LEDB);
-                       uint32_t option_new = ((rx_msg.data[0]<<8) | (rx_msg.data[1]));//option is from range 1-5
+                       uint32_t option_new = rx_msg.data[0];//option is from range 1-5
                        if(option == 0)
                        {
                                option = option_new;
@@ -373,8 +374,11 @@ void cl_sensor_send_status(){
        tx_msg.id = CAN_CL_SENSOR_STATUS;
        tx_msg.dlc = 5;
        tx_msg.flags = 0;
-       tx_msg.data[0] = ((IO1PIN & 1<<CL_SENSOR_OUT) != 0) & 0xFF;// 1 - pattern match 0 - no match
-       if((IO1PIN & 1<<CL_SENSOR_OUT) != 0) send_rs_str("trefa\n");
+       //tx_msg.data[0] = ((IO1PIN & 1<<CL_SENSOR_OUT) != 0) & 0xFF;// 1 - pattern match 0 - no match
+       if((IO1PIN & 1<<CL_SENSOR_OUT) != 0) {
+                tx_msg.data[0] = CAN_CL_SENSOR_PATTERN_MATCH;
+                send_rs_str("trefa\n");
+        } 
        (can_tx_msg(&tx_msg));
 }
 
index b35a3e671df3bcec51a43e66428cc5221cc61edf..3cc5b8fa7763dcbc8fb2944123dc8b50edae3a4b 100644 (file)
@@ -77,9 +77,9 @@ static inline double __trans_ang(double phi)
         double a;
 
         switch (robot.team_color) {
-        case WHITE:
-        case GREEN:
-        case YELLOW:
+        case TC_WHITE:
+        case TC_GREEN:
+        case TC_YELLOW:
                return phi;
         default:
                a = M_PI/2.0 - phi + M_PI/2.0;
@@ -93,9 +93,9 @@ static inline double __trans_ang(double phi)
 static inline struct move_target_heading __trans_heading(struct move_target_heading h)
 {
        switch (robot.team_color) {
-        case WHITE:
-        case GREEN:
-        case YELLOW:
+        case TC_WHITE:
+        case TC_GREEN:
+        case TC_YELLOW:
                return h;
        default:
                if (h.operation != TOP_DONT_TURN) {
@@ -118,9 +118,9 @@ static inline struct move_target_heading __trans_heading(struct move_target_head
 static inline double __trans_x(double x)
 {
        switch (robot.team_color) {
-        case WHITE:
-        case GREEN:
-        case YELLOW:
+        case TC_WHITE:
+        case TC_GREEN:
+        case TC_YELLOW:
                return x;
        default:
                return PLAYGROUND_WIDTH_M - x;
index 816a747477ab36c6b774f54ca2e4dad6c82f8d70..d32db701fc956d617921021512f9621dbf269118 100644 (file)
@@ -111,16 +111,16 @@ int robot_init()
        robot.fsm.act.transition_callback = trans_callback;
        robot.fsm.motion.transition_callback = trans_callback;
 
-        robot.team_color = WHITE;
+        robot.team_color = TC_WHITE;
 
         switch (robot.team_color) {
-        case WHITE:
+        case TC_WHITE:
                 ul_loginf("We are WHITE!\n");
                 break;
-        case GREEN:
+        case TC_GREEN:
                 ul_loginf("We are GREEN!\n");
                 break;
-        case YELLOW:
+        case TC_YELLOW:
                 ul_loginf("We are YELLOW!\n");
                 break;
         }
index 66ea66c0161f5453543364c8be49abe9bbc146c6..31be9afdb4bf1bdbc03125dc4e01333c1c4c51f8 100644 (file)
@@ -29,9 +29,9 @@
  * Competition parameters
  */
 enum team_color {
-        WHITE = 0,             /* Coordinate transformation does not apply */
-        GREEN,
-        YELLOW
+        TC_WHITE = 0,          /* Coordinate transformation does not apply */
+        TC_GREEN,
+        TC_YELLOW
 };
 
 enum robot_start_state {
index e3725408739a974170a8844337fba52764ff32f2..eae458802c6d4f2f3f83d104a3317f1ae86ee3ab 100644 (file)
@@ -66,6 +66,7 @@ struct robot_cmd {
 struct robot_switches {
        octet team_color;
        boolean strategy;
+        boolean home;
 };
 
 struct robot_bumpers {
@@ -113,6 +114,14 @@ struct lift_cmd {
         octet homing;
 };
 
+struct cl_sensor_cmd {
+        octet bank_nbr;
+};
+
+struct cl_sensor_status {
+        boolean pattern_match;
+};
+
 
 /** Status sent from actuators */
 struct jaws_status {
index c26a5006f1484e8610b1de813758e38681e5a41d..552809031848ca0ee9855d73556bb3a665c4c838 100644 (file)
@@ -1,5 +1,7 @@
 /* Definition of ORTE variables - input for roboortegen.pl */
 
+type=cl_sensor_status   topic=cl_sensor_status  deadline=0.5
+type=cl_sensor_cmd      topic=cl_sensor_cmd
 type=jaws_status       topic=jaws_status       deadline=0.5
 type=jaws_cmd          topic=jaws_cmd
 type=lift_status       topic=lift_status       deadline=0.5