It is possible to create development environments using tooling commonly available for Windows 10, macOS 10.14, Ubuntu Linux Bionic Beaver (18.04), and Ubuntu Xenial Xerus (16.04), and most recently Ubuntu Focal Fossa (20.04). See the ROS2 installation instructions using the latest release for more details. For now, development environment support will focus on using docker as instructed below.
- Install docker
- Understand the docker command line https://docs.docker.com/engine/reference/commandline/cli/
- Pull the docker build environment. Contains the latest OpenDDS (master) and currently ROS2 foxy release.
docker pull objectcomputing/opendds_ros2
- Create a workspace directory on the host filesystem (e.g. opendds_rmw_ws)
- Clone
rmw_build
repo into directory from previous step
git clone https://github.com/oci-labs/rmw_build
- Run docker to start build environment
docker run -it -v /host/path/to/workspace_directory:/opt/workspace objectcomputing/opendds_ros2 bash
- In the docker container, make sure you’re in
/opt/workspace
cd /opt/workspace
- Create the workspace (pulls all necessary rmw and test repos) by running the following command in the container.
./rmw_build/create_workspace.sh
- Build the workspace (builds only what we need)
./rmw_build/build_all.sh
The new run_test.sh script has several features
- Runs with gdb to capture call stack (i.e. bt) if the code fails
- Can run sub or pub from the same script
- Can run other RMW implementations such as the default FastRTPS This test script does not replace the system tests but is more for RMW developers to test and debug in various environments.
- Get help on the
run_test.sh
script.
./rmw_build/run_test.sh -h
- Run the publisher test (sources environment and executes the test publisher code using the OpenDDS RMW)
./rmw_build/run_test.sh
- Run the subscriber test (sources environment and executes the test subscriber code using the OpenDDS RMW)
./rmw_build/run_test.sh -s
Note: Add --ros-args --disable-rosout-logs
to the end of the RMW_IMPLEMENTATION
line in run_test.sh
to disable rosout logging
eval RMW_IMPLEMENTATION="$alt_rmw ros2 run --prefix '${gdb_cmd}' $run_test$executable_suffix --ros-args --disable-rosout-logs"
Good gdb references
(gdb) help
- Run the test in breakpoint debug mode
./rmw_build/run_test.sh -b
- Show current (aka present) working directory for relative file paths
(gdb) pwd
- Set breakpoint in publisher code and run
- Show block of 10 lines centered on line 52
(gdb) list 52
- Set breakpoint at line 52
(gdb) b 52
- Run execution
(gdb) run
- After breakpoint is hit, execute next line
(gdb) next
- Set breakpoint in
rmw_init
function from fresh run
- Run the code
(gdb) run
- Accept to restart execution if applicable
y
- List the code in source file
rmw_init.cpp
at functionrm_init
(gdb) list src/rmw_opendds/rmw_opendds_cpp/src/rmw_init.cpp:rmw_init
- Set breakpoint in file
rmw_init.cpp
at first line ofrmw_init
function
(gdb) b src/rmw_opendds/rmw_opendds_cpp/src/rmw_init.cpp:rmw_init
- Run the code
(gdb) run
- Accept to restart execution if applicable
y
- Next until desired line
(gdb) next
- Backtrace (
bt
) Shows the call stack
(gdb) bt
- Set breakpoint in
rmw_create_node
from fresh run
- Run the code
(gdb) run
- Accept to restart execution if applicable
y
- Show first line of function
rmw_create_node
in filermw_node.cpp
(gdb) list src/rmw_opendds/rmw_opendds_cpp/src/rmw_node.cpp:rmw_create_node
- Set breakpoint on first line of
rmw_create_node
in filermw_node.cpp
(gdb) b src/rmw_opendds/rmw_opendds_cpp/src/rmw_node.cpp:rmw_create_node
- To desired line of code
(gdb) run
y
(gdb) next
- To see the backtrace (
bt
) at that line of code
(gdb) bt
Edit files from /host/path/to/workspace_directory
from your host OS using your favorite editor.