Merge pull request 'standalone' (#1) from standalone into main
Create and publish a Docker image / build-and-push-image (push) Successful in 8m36s Details

Reviewed-on: #1
This commit is contained in:
Youssof 2024-07-11 15:54:35 -03:00
commit fa4177f1e0
7 changed files with 119 additions and 62 deletions

View File

@ -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
HEALTHCHECK --interval=5s --timeout=5s --retries=3 CMD /ros_entrypoint.sh rostopic list

View File

@ -1,4 +1,19 @@
# 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`.
#### This setup assumes the xbee is attached to `/dev/ttyUSB0` and programmed to work at a baud rate of `230400`.
## Description
The "xbee_ros_node" package provides many tools (ROS nodes) to configure, test and communicate Xbee devices.

View File

@ -0,0 +1,12 @@
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

View File

@ -0,0 +1,45 @@
version: "3.8"
services:
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: rosrun xbee_ros_node xbee_config /dev/ttyUSB0 230400
command: tail -f /dev/null
depends_on:
- ros-master
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

View File

@ -2,9 +2,9 @@
<XBeeConfig>
<Settings>
<Parameter Command="CM" Description="Channel Mask">00FFFFFFFFFFF7FFFF</Parameter>
<Parameter Command="CM" Description="Channel Mask">00FFFFFFFFFFFFFFFF</Parameter>
<Parameter Command="HP" Description="Preamble ID">1</Parameter>
<Parameter Command="ID" Description="Network ID">5FFF</Parameter>
<Parameter Command="ID" Description="Network ID">7777</Parameter>
<Parameter Command="MT" Description="Broadcast Multi-Transmits">0</Parameter>
<Parameter Command="PL" Description="TX Power Level">4</Parameter>
<Parameter Command="RR" Description="Unicast Retries">A</Parameter>
@ -16,10 +16,10 @@
<Parameter Command="DH" Description="Destination Address High">0</Parameter>
<Parameter Command="DL" Description="Destination Address Low">FFFF</Parameter>
<Parameter Command="TO" Description="Transmit Options">C0</Parameter>
<Parameter Command="NI" Description="Node Identifier">'Node 1'</Parameter>
<Parameter Command="NI" Description="Node Identifier">Router</Parameter>
<Parameter Command="NT" Description="Network Dsicovery Back-Off">82</Parameter>
<Parameter Command="NO" Description="Network Dsicovery Options">0</Parameter>
<Parameter Command="CI" Description="Cluster ID">11</Parameter>
<Parameter Command="CI" Description="Cluster ID">1</Parameter>
<Parameter Command="EE" Description="Encryption Enbale">0</Parameter>
<Parameter Command="KY" Description="Encryption Key"></Parameter>
<Parameter Command="BD" Description="Baud Rate">8</Parameter>
@ -46,7 +46,7 @@
<Parameter Command="P4" Description="DIO14/DIN">1</Parameter>
<Parameter Command="PD" Description="Pull Direction">7FFF</Parameter>
<Parameter Command="PR" Description="Pull-Up/Down Resistor">7FFF</Parameter>
<Parameter Command="M0" Description=" PWM0 Duty Cycle">0</Parameter>
<Parameter Command="M0" Description="PWM0 Duty Cycle">0</Parameter>
<Parameter Command="M1" Description="PWM1 Duty Cycle">0</Parameter>
<Parameter Command="LT" Description="Associate LED Blink Time">0</Parameter>
<Parameter Command="RP" Description="RSSI PWM Timer">28</Parameter>
@ -56,7 +56,7 @@
<Parameter Command="IR" Description="Sample Rate">0</Parameter>
<Parameter Command="SM" Description="Sleep Mode">0</Parameter>
<Parameter Command="SO" Description="Sleep Options">2</Parameter>
<Parameter Command="SN" Description="Nu,ber of Cycles between On/Sleep">1</Parameter>
<Parameter Command="SN" Description="Number of Cycles between On/Sleep">1</Parameter>
<Parameter Command="SP" Description="Sleep Time">12C</Parameter>
<Parameter Command="ST" Description="Wake Time">BB8</Parameter>
<Parameter Command="WH" Description="Wake Host Delay">0</Parameter>

View File

@ -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<XBee_Parameter_S> *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),
&current_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<XBee_Parameter_S> *config_parameters = config_parser.Get_Loaded_Parameters();
for (auto& param : *config_parameters) {
std::string current_command = "";
xbee_module.Format_AT_Command(param, &current_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;
}

View File

@ -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)
{