Example codes as a complement to rclc/examples
ROS2 Distro: Humble
docker image: tonghezhang/ros2_x86:humble_lint_0.1
Examples
prerequisites
To use subscription_with_loaned_msg, we need to add msg_loan in rclc/executor.c
rcl_take_loaned_message
rcl_return_loaned_message_from_subscription
This change is already on branch humble_add_msg_loan_in_sub_callback of my fork of ros2/rclc,
currently, you can use my repo rclc to test this feature
build rclc from source
git clone https://github.com/Zard-C/rclc.git git checkout humble colcon build --packages-select rclc
build rclc_example from source
colcon build --packages-select rclc_example
use ros2's default middleware (fastrtps) zero copy feature
export FASTRTPS_DEFAULT_PROFILES_FILE=${PATH_TO_CONFIG}/fast_dds_profiles.xml export RMW_FASTRTPS_USE_QOS_FROM_XML=1
replace ${PATH_TO_CONFIG} with your own path (we have a demo in demo_config_file)
Build
colcon build --packages-select rclc_example
dependencies and version
environment
source /opt/ros2/humble/setup.bash source ${rclc}/install/setup.bash source ${rclc_example}/install/setup.bash # for using fastrtps's zero copy, in your rclc_example workspace export FASTRTPS_DEFAULT_PROFILES_FILE=${PATH_TO_CONFIG}/fast_dds_profiles.xml export RMW_FASTRTPS_USE_QOS_FROM_XML=1 # run in one terminal ./build/rclc_example/pub_loaned_msg # run in another terminal ./build/rclc_example/sub_loaned_msg
features
- timer_with_context
- publish_with_loaned_msg
- subscription_with_loaned_msg
- subscription_with_context