diff --git a/install/install_on_real_UAV.sh b/install/install_on_real_UAV.sh index 159b6c2..0b6bf87 100755 --- a/install/install_on_real_UAV.sh +++ b/install/install_on_real_UAV.sh @@ -214,41 +214,8 @@ then fi ############################################################### -##################### LED Configuration ####################### -read -n 2 -p $'\e[1;32mDo you want to test the LEDs? [y/n]\e[0m\n' resp_led -response_led=`echo $resp_led | sed -r 's/(.*)$/\1=/'` -if [[ $response_led =~ ^(y|Y)=$ ]]; then - source $workspace/devel/setup.bash - - echo "####################### LED Configuration #######################" - echo $'\e[0;33mLED testing works only with a battery as the power source!\e[0m' - echo $'\e[1;32mWhich module is the UVDAR board connected to?\e[0m' - echo "Enter:" - echo "1 = /dev/MRS_MODULE1" - echo "2 = /dev/MRS_MODULE2" - echo "3 = /dev/MRS_MODULE3" - echo "4 = /dev/MRS_MODULE4" - read -n 2 resp_module - echo "Starting with LED initialization on:/dev/MRS_MODULE$resp_module... This will take about 20 seconds." - path_to_led_config=/opt/ros/noetic/share/uvdar_core/config/blinking_sequences/test_assignment.txt - roslaunch uvdar_core led_manager.launch sequence_file:=$path_to_led_config portname:=/dev/MRS_MODULE$resp_module &> $tmp_file_LED_launch & - pid_led_manager=$! - sleep 5; rosservice call /$UAV_NAME/uvdar_led_manager_node/quick_start 0 - sleep 2; rosservice call /$UAV_NAME/uvdar_led_manager_node/load_sequences - sleep 2; rosservice call /$UAV_NAME/uvdar_led_manager_node/select_sequences [0,1,2,3] - sleep 2; rosservice call /$UAV_NAME/uvdar_led_manager_node/set_frequency 1 - sleep 5 - - # kill the LED manager and remove temporary file - kill -9 "$pid_led_manager" - rm $tmp_file_LED_launch - echo "##################### LED Configuration done! ###################" - echo $'\e[1;32mPlease verify that the LEDs are correctly wired!\e[0m' - echo "Blinking Pattern: Clockwise blinking circle starting at the left front arm!" - echo $'\e[0;33mIf the blinking pattern didn\'t change: Please shutdown the NUC, detach the battery, attach it again and call this script again!\e[0m' -else - echo "OK. Exiting script..." -fi +$(rospack find uvdar_core)/install/test_leds.sh + ############################################################### exit 0 diff --git a/install/test_leds.sh b/install/test_leds.sh new file mode 100755 index 0000000..c02ebc1 --- /dev/null +++ b/install/test_leds.sh @@ -0,0 +1,37 @@ +#!/bin/bash +tmp_file_LED_launch="/tmp/led_manager.txt" +##################### LED Configuration ####################### +read -n 2 -p $'\e[1;32mDo you want to test the LEDs? [y/n]\e[0m\n' resp_led +response_led=`echo $resp_led | sed -r 's/(.*)$/\1=/'` +if [[ $response_led =~ ^(y|Y)=$ ]]; then + source $workspace/devel/setup.bash + + echo "####################### LED Configuration #######################" + echo $'\e[0;33mLED testing works only with a battery as the power source!\e[0m' + echo $'\e[1;32mWhich module is the UVDAR board connected to?\e[0m' + echo "Enter:" + echo "1 = /dev/MRS_MODULE1" + echo "2 = /dev/MRS_MODULE2" + echo "3 = /dev/MRS_MODULE3" + echo "4 = /dev/MRS_MODULE4" + read -n 2 resp_module + echo "Starting with LED initialization on:/dev/MRS_MODULE$resp_module... This will take about 20 seconds." + path_to_led_config=/opt/ros/noetic/share/uvdar_core/config/blinking_sequences/test_assignment.txt + roslaunch uvdar_core led_manager.launch sequence_file:=$path_to_led_config portname:=/dev/MRS_MODULE$resp_module &> $tmp_file_LED_launch & + pid_led_manager=$! + sleep 5; rosservice call /$UAV_NAME/uvdar_led_manager_node/quick_start 0 + sleep 2; rosservice call /$UAV_NAME/uvdar_led_manager_node/load_sequences + sleep 2; rosservice call /$UAV_NAME/uvdar_led_manager_node/select_sequences [0,1,2,3] + sleep 2; rosservice call /$UAV_NAME/uvdar_led_manager_node/set_frequency 1 + sleep 5 + + # kill the LED manager and remove temporary file + kill -9 "$pid_led_manager" + rm $tmp_file_LED_launch + echo "##################### LED Configuration done! ###################" + echo $'\e[1;32mPlease verify that the LEDs are correctly wired!\e[0m' + echo "Blinking Pattern: Clockwise blinking circle starting at the left front arm!" + echo $'\e[0;33mIf the blinking pattern didn\'t change: Please shutdown the NUC, detach the battery, attach it again and call this script again!\e[0m' +else + echo "OK. Exiting script..." +fi diff --git a/src/led_manager.cpp b/src/led_manager.cpp index 44a4281..93f8d79 100644 --- a/src/led_manager.cpp +++ b/src/led_manager.cpp @@ -183,6 +183,7 @@ namespace uvdar { unsigned char i = 0; + ros::Duration local_sleeper(0.25 + 0.1*(sequences_[0].size())); for (auto sq : sequences_){ serial_msg.payload.clear(); serial_msg.payload.push_back(0x99); //write sequences @@ -196,7 +197,8 @@ namespace uvdar { /* if (i == 3) */ baca_protocol_publisher.publish(serial_msg); - sleeper.sleep(); + + local_sleeper.sleep(); i++; }