Skip to content

soda-auto/soda-validate-sdrig-sdk-cpp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SDR ROS2

Description

Packages for ROS2 to work with SDR modules.

Dependencies

  • ROS2
  • PCAP: sudo apt-get install libpcap0.8-dev
  • Python. pip and virtualenv are needed to generate CAN messages handlers in generate_can directory.

Build

Note: it is implied that all the commands are executed from the root of the project, if not said otherwise.

Build

Build everything:

colcon build --symlink-install

Build packages separately:

colcon build --packages-select sdr_interfaces
colcon build --packages-select sdr_library_cpp

or

colcon build --packages-up-to sdr_nodes_cpp     # build the package and its dependencies

Usage

All commands are executed under superuser.

SDR module node

These commands below will:

  • source the setup files to have access to the ROS2 commands
  • define domain ID for your group of ROS2 nodes (0 to 101, inclusive)
  • run UIO node with an argument mac="5a:73:19:03:f4:f2", which is its MAC-address
source /opt/ros/jazzy/setup.bash
source install/setup.bash
export ROS_DOMAIN_ID=1
ros2 run sdr_nodes_cpp uio_node --ros-args -p mac:="5a731903f4f2"

Note: First three commands need to be issued once in every console terminal. It can be automated with the following commands:

echo "source /opt/ros/jazzy/setup.bash" >> ~/.bashrc
echo "export ROS_DOMAIN_ID=1" >> ~/.bashrc

Note: When the project has beed rebuilt, the second command (source install/setup.bash) needs to be executed again.

Service client nodes

Clients can be run in non-SU mode.

Note: Apparently clients and ros2 cannot see nodes created in SU mode.


Reading voltage on a pin #1 (starts from 0) of UIO module with MAC-address="5a:73:19:03:f4:F2":

ros2 run sdr_srvcli_py srv_voltage_get --ros-args -p type:=UIO -p mac:="5a731903f4F2" -p pin:=0

Setting 4 V on a pin #1 of UIO module with MAC-address="5a:73:19:03:f4:F2":

ros2 run sdr_srvcli_py srv_voltage_set --ros-args -p type:=UIO -p mac:="5a731903f4F2" -p pin:=0 -p enable:=1 -p voltage:=4.0

Reading current on a pin #2 of UIO module with MAC-address="5a:73:19:03:f4:F2":

ros2 run sdr_srvcli_py srv_current_get --ros-args -p type:=UIO -p mac:="5a731903f4F2" -p pin:=1

Setting 10 mA on a pin #2 of UIO module with MAC-address="5a:73:19:03:f4:F2":

ros2 run sdr_srvcli_py srv_current_set --ros-args -p type:=UIO -p mac:="5a731903f4F2" -p pin:=1 -p enable:=1 -p current:=10.0

Reading PWM on a pin #8 of UIO module with MAC-address="5a:73:19:03:f4:F2":

ros2 run sdr_srvcli_py srv_pwm_get --ros-args -p type:=UIO -p mac:="5a731903f4F2" -p pin:=7

Setting PWM (10 kHz, 40%) on a pin #8 of UIO module with MAC-address="5a:73:19:03:f4:F2":

ros2 run sdr_srvcli_py srv_pwm_set --ros-args -p type:=UIO -p mac:="5a731903f4F2" -p pin:=7 -p enable:=0 -p frequency:=10000.0 -p duty:=40.0

Node Interrupting

A running node can be stopped with "Ctrl + C" combination.

Logging and Debugging

In order to manually set a log level for a node, add a ros argument (after "--ros-args" option):

--log-level DEBUG                   # to set global log level

or

--log-level <Node_name>:=DEBUG      # to set log level only for the node

Robotframework

Getting started

Create python virtual environment to install robotframework. Python package virtualenv will be used here:

virtualenv venv --system-site-packages # to use system packages for ROS2

Activate virtual environment:

source venv/bin/activate

Install robotframework:

pip install robotframework

Start a test:

robot test/test.robot

About

SODA Software Defined Rig C++ SDK

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published