From 37f50395db5472f7e739d4d7a8eed59e28fddc19 Mon Sep 17 00:00:00 2001 From: emranB Date: Mon, 24 Jun 2024 13:56:31 -0300 Subject: [PATCH 01/10] Testing standalone docker compose --- Dockerfile | 2 + docker-compose-test-stadalone.yml | 70 +++++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+) create mode 100644 docker-compose-test-stadalone.yml diff --git a/Dockerfile b/Dockerfile index 988fc79..e2f1952 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,6 +5,7 @@ RUN apt-get update && apt-get install -y \ vim \ build-essential \ ros-kinetic-mavros \ + dos2unix \ ros-kinetic-mavros-extras \ ros-kinetic-mavros-msgs \ ros-kinetic-catkin @@ -20,5 +21,6 @@ ENV CATKIN_SETUP_FILE devel/setup.bash RUN apt-get clean COPY ./ros_entrypoint.sh /ros_entrypoint.sh +RUN /bin/bash -c "dos2unix /ros_entrypoint.sh" HEALTHCHECK --interval=5s --timeout=5s --retries=3 CMD /ros_entrypoint.sh rostopic list \ No newline at end of file diff --git a/docker-compose-test-stadalone.yml b/docker-compose-test-stadalone.yml new file mode 100644 index 0000000..63a8e2f --- /dev/null +++ b/docker-compose-test-stadalone.yml @@ -0,0 +1,70 @@ +version: "3.8" + + + +services: + + # mavros: + # #This service bridges our mavlink-based robot-coprosessor into ROS + # #In this example it connects to a simulated coprocessor. + # image: git.spirirobotics.com/spiri/services-ros1-mavros:master + # command: roslaunch mavros px4.launch fcu_url:="udp://:14557@gazebo:14540" + # environment: + # - "ROS_MASTER_URI=http://ros-master:11311" + # depends_on: + # ros-master: + # condition: service_healthy + # # mavproxy: + # # condition: service_started + # restart: always + # deploy: + # resources: + # limits: + # # cpus: '0.01' + # memory: 200M + # ulimits: + # nofile: + # soft: 1024 + # hard: 524288 + # networks: + # - sim_network + + ros-master: + image: git.spirirobotics.com/spiri/services-ros1-core:main + command: stdbuf -o L roscore + environment: + - "ROS_MASTER_URI=http://ros-master:11311" + restart: always + ports: + - "11311:11311" + deploy: + resources: + limits: + memory: 1G + # Madness, setting a low ulimit here fixes memory leaks + # https://answers.ros.org/question/336963/rosout-high-memory-usage/ + ulimits: + nofile: + soft: 1024 + hard: 524288 + networks: + - sim_network + + xbee-mav: + command: tail -f /dev/null + container_name: xbee-mav + depends_on: + - ros-master + build: + context: . + dockerfile: Dockerfile + devices: + - 'COM16' + environment: + - "ROS_MASTER_URI=http://ros-master:11311" + networks: + - sim_network + +networks: + sim_network: + driver: bridge \ No newline at end of file From 46f41982a5a055109fdc3f6eb56e73a04af90439 Mon Sep 17 00:00:00 2001 From: Emran Billah Date: Mon, 24 Jun 2024 16:58:11 -0300 Subject: [PATCH 02/10] testing xbeemav --- Dockerfile | 2 +- docker-compose-test-stadalone.yml | 30 +++--------------------------- 2 files changed, 4 insertions(+), 28 deletions(-) diff --git a/Dockerfile b/Dockerfile index e2f1952..9a32745 100644 --- a/Dockerfile +++ b/Dockerfile @@ -23,4 +23,4 @@ RUN apt-get clean COPY ./ros_entrypoint.sh /ros_entrypoint.sh RUN /bin/bash -c "dos2unix /ros_entrypoint.sh" -HEALTHCHECK --interval=5s --timeout=5s --retries=3 CMD /ros_entrypoint.sh rostopic list \ No newline at end of file +HEALTHCHECK --interval=5s --timeout=5s --retries=3 CMD /ros_entrypoint.sh rostopic list diff --git a/docker-compose-test-stadalone.yml b/docker-compose-test-stadalone.yml index 63a8e2f..38156ad 100644 --- a/docker-compose-test-stadalone.yml +++ b/docker-compose-test-stadalone.yml @@ -4,31 +4,6 @@ version: "3.8" services: - # mavros: - # #This service bridges our mavlink-based robot-coprosessor into ROS - # #In this example it connects to a simulated coprocessor. - # image: git.spirirobotics.com/spiri/services-ros1-mavros:master - # command: roslaunch mavros px4.launch fcu_url:="udp://:14557@gazebo:14540" - # environment: - # - "ROS_MASTER_URI=http://ros-master:11311" - # depends_on: - # ros-master: - # condition: service_healthy - # # mavproxy: - # # condition: service_started - # restart: always - # deploy: - # resources: - # limits: - # # cpus: '0.01' - # memory: 200M - # ulimits: - # nofile: - # soft: 1024 - # hard: 524288 - # networks: - # - sim_network - ros-master: image: git.spirirobotics.com/spiri/services-ros1-core:main command: stdbuf -o L roscore @@ -52,6 +27,7 @@ services: xbee-mav: command: tail -f /dev/null + # command: rosrun xbee_ros_node xbee_config /dev/ttyUSB0 9600 container_name: xbee-mav depends_on: - ros-master @@ -59,7 +35,7 @@ services: context: . dockerfile: Dockerfile devices: - - 'COM16' + - /dev/ttyUSB0:/dev/ttyUSB0 environment: - "ROS_MASTER_URI=http://ros-master:11311" networks: @@ -67,4 +43,4 @@ services: networks: sim_network: - driver: bridge \ No newline at end of file + driver: bridge From 6e3e142d8433a05560d32c4a971c47cf071c43be Mon Sep 17 00:00:00 2001 From: Emran Billah Date: Tue, 25 Jun 2024 11:08:52 -0300 Subject: [PATCH 03/10] Testing xbeemav flasher --- docker-compose-test-stadalone.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker-compose-test-stadalone.yml b/docker-compose-test-stadalone.yml index 38156ad..c01fd93 100644 --- a/docker-compose-test-stadalone.yml +++ b/docker-compose-test-stadalone.yml @@ -26,8 +26,8 @@ services: - sim_network xbee-mav: - command: tail -f /dev/null - # command: rosrun xbee_ros_node xbee_config /dev/ttyUSB0 9600 + # command: tail -f /dev/null + command: roslaunch xbee_ros_node xbeemav.launch baud:=230400 port:="/dev/ttyUSB0" drone:="master" mode:="swarm" container_name: xbee-mav depends_on: - ros-master From 2a16e48015b3bc32540c56239a8c56cc76f0327d Mon Sep 17 00:00:00 2001 From: Emran Billah Date: Tue, 25 Jun 2024 11:56:54 -0300 Subject: [PATCH 04/10] Adding new xbee devices --- xbeemav/Resources/database.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/xbeemav/Resources/database.xml b/xbeemav/Resources/database.xml index 26e9faa..ea440c6 100644 --- a/xbeemav/Resources/database.xml +++ b/xbeemav/Resources/database.xml @@ -5,5 +5,7 @@ 0013A20041C4FEAB 0013A20041C4FC1C 0013A20041C4FC97 + 0013A20041C4FF68 + 0013A20041C4FC42 From b0581882d30f87a9957322740a4b4abb36ccf537 Mon Sep 17 00:00:00 2001 From: Emran Billah Date: Tue, 25 Jun 2024 12:29:18 -0300 Subject: [PATCH 05/10] Testing xbee flashing --- docker-compose-test-stadalone.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker-compose-test-stadalone.yml b/docker-compose-test-stadalone.yml index c01fd93..499709e 100644 --- a/docker-compose-test-stadalone.yml +++ b/docker-compose-test-stadalone.yml @@ -26,8 +26,8 @@ services: - sim_network xbee-mav: - # command: tail -f /dev/null - command: roslaunch xbee_ros_node xbeemav.launch baud:=230400 port:="/dev/ttyUSB0" drone:="master" mode:="swarm" + command: tail -f /dev/null + # command: roslaunch xbee_ros_node xbeemav.launch baud:=230400 port:="/dev/ttyUSB0" drone:="master" mode:="swarm" container_name: xbee-mav depends_on: - ros-master From e2b7b95db313049dcbec7475b730fad70ceefce7 Mon Sep 17 00:00:00 2001 From: Emran Billah Date: Tue, 25 Jun 2024 18:14:32 -0300 Subject: [PATCH 06/10] Flashing process working ok. Need to add a method to allow specific params to be written, passed to the program as a cmd line arg --- docker-compose-flash-device.yml | 21 ++++++++ docker-compose-test-stadalone.yml | 4 +- xbeemav/src/XBeeSetup.cpp | 89 +++++++++++++------------------ xbeemav/src/main.cpp | 4 +- 4 files changed, 60 insertions(+), 58 deletions(-) create mode 100644 docker-compose-flash-device.yml diff --git a/docker-compose-flash-device.yml b/docker-compose-flash-device.yml new file mode 100644 index 0000000..dcbf784 --- /dev/null +++ b/docker-compose-flash-device.yml @@ -0,0 +1,21 @@ +version: "3.8" + + + +services: + + xbee-mav: + command: rosrun xbee_ros_node xbee_config /dev/ttyUSB0 230400 + build: + context: . + dockerfile: Dockerfile + devices: + - /dev/ttyUSB0:/dev/ttyUSB0 + environment: + - "ROS_MASTER_URI=http://ros-master:11311" + networks: + - sim_network + +networks: + sim_network: + driver: bridge diff --git a/docker-compose-test-stadalone.yml b/docker-compose-test-stadalone.yml index 499709e..f5625f8 100644 --- a/docker-compose-test-stadalone.yml +++ b/docker-compose-test-stadalone.yml @@ -26,9 +26,7 @@ services: - sim_network xbee-mav: - command: tail -f /dev/null - # command: roslaunch xbee_ros_node xbeemav.launch baud:=230400 port:="/dev/ttyUSB0" drone:="master" mode:="swarm" - container_name: xbee-mav + command: rosrun xbee_ros_node xbee_config /dev/ttyUSB0 230400 depends_on: - ros-master build: diff --git a/xbeemav/src/XBeeSetup.cpp b/xbeemav/src/XBeeSetup.cpp index f19479b..417e1cd 100644 --- a/xbeemav/src/XBeeSetup.cpp +++ b/xbeemav/src/XBeeSetup.cpp @@ -13,58 +13,41 @@ bool setupXBee(const std::string &device_port, const unsigned int baud_rate) { XBeeModule xbee_module; XMLConfigParser config_parser; - if (xbee_module.Init_Port(device_port, baud_rate)) { - std::thread th_service(&XBeeModule::Run_Service, &xbee_module); - - while (!xbee_module.Is_Connected() && - !xbee_module.Check_Time_Out_Exceeded()) { - continue; - } - - if (xbee_module.Is_Connected()) { - std::cout << "Connected to XBee." << std::endl; - std::cout << "Loading Config File..." << std::endl; - - if (config_parser.Load_Config()) { - std::cout << "Config Loaded Successfully." << std::endl; - std::cout << "Transferring Data..." << std::endl; - std::vector *config_parameters = - config_parser.Get_Loaded_Parameters(); - - for (std::size_t i = 0; i < config_parameters->size(); i++) { - std::string current_command; - xbee_module.Format_AT_Command(config_parameters->at(i), - ¤t_command); - xbee_module.Send_Data(current_command); - } - - std::string write_command = "ATWR \r"; - xbee_module.Send_Data(write_command); - } - } - - th_service.join(); - - std::cout << "Exiting AT Command Mode..." << std::endl; - - if (xbee_module.Is_Connected()) - { - xbee_module.Exit_AT_Command_Mode(); - - if (config_parser.Is_Config_Loaded_Successfully()) - { - std::cout << "XBee Configured Successfully." << std::endl; - return true; - } - else - { - std::cout << "XBee Configuration Failed." << std::endl; - } - } - else - { - std::cout << "XBee Configuration Failed." << std::endl; - } + // Init port at specified baud rate + if (!xbee_module.Init_Port(device_port, baud_rate)) { + std::cout << "XBee Configuration Failed. Could not Init_Port." << std::endl; + return false; } - return false; + + // Run xbee flashing process in a separate thread + std::thread th_service(&XBeeModule::Run_Service, &xbee_module); + + // Wait till connection to device is established + while (!xbee_module.Is_Connected() && !xbee_module.Check_Time_Out_Exceeded()) { + continue; + } + + // Load external config file + if (!config_parser.Load_Config()) { + std::cout << "XBee Configuration Failed. Could not config file." << std::endl; + return false; + } + + // Flash config params to device + std::cout << "Connected to XBee. Flashing Config File..." << std::endl; + std::vector *config_parameters = config_parser.Get_Loaded_Parameters(); + for (auto& param : *config_parameters) { + std::string current_command = ""; + xbee_module.Format_AT_Command(param, ¤t_command); + xbee_module.Send_Data(current_command); + } + std::string write_command = "ATWR \r"; + xbee_module.Send_Data(write_command); + + // Kill service once device has been flashed + th_service.join(); + xbee_module.Exit_AT_Command_Mode(); + + std::cout << "Flashing process complete." << std::endl; + return true; } diff --git a/xbeemav/src/main.cpp b/xbeemav/src/main.cpp index fc6a1b1..1302cf2 100644 --- a/xbeemav/src/main.cpp +++ b/xbeemav/src/main.cpp @@ -13,7 +13,7 @@ int main(int argc, char*argv[]) { std::string device_port; unsigned int baud_rate = 0; - const unsigned int DEFAULT_BAUD_RATE = 9600; + const unsigned int DEFAULT_BAUD_RATE = 230400; const std::string DEFAULT_DEVICE_PORT = "/dev/ttyUSB0"; if (argc < 1) @@ -26,7 +26,7 @@ int main(int argc, char*argv[]) else sscanf(argv[2], "%u", &baud_rate); - //setupXBee(device_port, baud_rate); + setupXBee(device_port, baud_rate); } catch (const std::exception& e) { From 4b0593944b733b357208f653ae473d4178c678a9 Mon Sep 17 00:00:00 2001 From: Emran Billah Date: Tue, 25 Jun 2024 18:19:24 -0300 Subject: [PATCH 07/10] Flashing process working ok. Need to add a method to allow specific params to be written, passed to the program as a cmd line arg --- README.md | 10 ++++++++++ docker-compose-test-stadalone.yml | 3 ++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 64a87c8..f55e63b 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,14 @@ # XbeeMav + + +## Usage: + +- To run xbee_mav and ros master as a docker pod, use: + - `docker compose -f docker-compose-test-stadalone.yml up --build` +- To run xbee_mav as an exclusive service to flash xbee devices, use: + - `docker compose -f docker-compose-flash-device.yml up --build` +Note: The xbee config file is located in: `/xbeemav/Resources/XBee_Config.xml` + ## Description The "xbee_ros_node" package provides many tools (ROS nodes) to configure, test and communicate Xbee devices. diff --git a/docker-compose-test-stadalone.yml b/docker-compose-test-stadalone.yml index f5625f8..d2d3001 100644 --- a/docker-compose-test-stadalone.yml +++ b/docker-compose-test-stadalone.yml @@ -26,7 +26,8 @@ services: - sim_network xbee-mav: - command: rosrun xbee_ros_node xbee_config /dev/ttyUSB0 230400 + # command: rosrun xbee_ros_node xbee_config /dev/ttyUSB0 230400 + command: tail -f /dev/null depends_on: - ros-master build: From c7048800538592511a10c91325af484a71518af3 Mon Sep 17 00:00:00 2001 From: Emran Billah Date: Tue, 25 Jun 2024 18:20:58 -0300 Subject: [PATCH 08/10] Flashing process working ok. Need to add a method to allow specific params to be written, passed to the program as a cmd line arg --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index f55e63b..cba0bbe 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,8 @@ - `docker compose -f docker-compose-test-stadalone.yml up --build` - To run xbee_mav as an exclusive service to flash xbee devices, use: - `docker compose -f docker-compose-flash-device.yml up --build` -Note: The xbee config file is located in: `/xbeemav/Resources/XBee_Config.xml` +Note: The xbee config file is located in: `/xbeemav/Resources/XBee_Config.xml`. +This setup assumes the xbee is attached to /dev/ttyUSB0 and programmed to work at a baud rate of 230400. ## Description From ff198103e9925a0c20754b2d19345f4f81b8fd0c Mon Sep 17 00:00:00 2001 From: Emran Billah Date: Tue, 25 Jun 2024 18:25:22 -0300 Subject: [PATCH 09/10] Flashing process working ok. Need to add a method to allow specific params to be written, passed to the program as a cmd line arg --- README.md | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index cba0bbe..4fb64d3 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,18 @@ # XbeeMav -## Usage: +## Usage -- To run xbee_mav and ros master as a docker pod, use: +To run xbee_mav and ros master as a docker pod, use: - `docker compose -f docker-compose-test-stadalone.yml up --build` -- To run xbee_mav as an exclusive service to flash xbee devices, use: + +To run xbee_mav as an exclusive service to flash xbee devices, use: - `docker compose -f docker-compose-flash-device.yml up --build` -Note: The xbee config file is located in: `/xbeemav/Resources/XBee_Config.xml`. -This setup assumes the xbee is attached to /dev/ttyUSB0 and programmed to work at a baud rate of 230400. + +#### Note: The xbee config file is located in: +- `/xbeemav/Resources/XBee_Config.xml`. +#### This setup assumes the xbee is attached to `/dev/ttyUSB0` and programmed to work at a baud rate of `230400`. + ## Description From a9ae6c4e2bdbdf618aa4ecfdab219093fb2ed46b Mon Sep 17 00:00:00 2001 From: emranB Date: Wed, 26 Jun 2024 19:10:52 -0300 Subject: [PATCH 10/10] Adding minimal config setup --- docker-compose-flash-device.yml | 11 +---------- xbeemav/Resources/XBee_Config.xml | 12 ++++++------ 2 files changed, 7 insertions(+), 16 deletions(-) diff --git a/docker-compose-flash-device.yml b/docker-compose-flash-device.yml index dcbf784..edc40e5 100644 --- a/docker-compose-flash-device.yml +++ b/docker-compose-flash-device.yml @@ -1,9 +1,6 @@ version: "3.8" - - services: - xbee-mav: command: rosrun xbee_ros_node xbee_config /dev/ttyUSB0 230400 build: @@ -11,11 +8,5 @@ services: dockerfile: Dockerfile devices: - /dev/ttyUSB0:/dev/ttyUSB0 - environment: - - "ROS_MASTER_URI=http://ros-master:11311" - networks: - - sim_network -networks: - sim_network: - driver: bridge + diff --git a/xbeemav/Resources/XBee_Config.xml b/xbeemav/Resources/XBee_Config.xml index e33fdc8..5c1737f 100644 --- a/xbeemav/Resources/XBee_Config.xml +++ b/xbeemav/Resources/XBee_Config.xml @@ -2,9 +2,9 @@ - 00FFFFFFFFFFF7FFFF + 00FFFFFFFFFFFFFFFF 1 - 5FFF + 7777 0 4 A @@ -16,10 +16,10 @@ 0 FFFF C0 - 'Node 1' + Router 82 0 - 11 + 1 0 8 @@ -46,7 +46,7 @@ 1 7FFF 7FFF - 0 + 0 0 0 28 @@ -56,7 +56,7 @@ 0 0 2 - 1 + 1 12C BB8 0