Accessing topics from multiple ros2 workspaces, sourced separately
Hello, I am new to ros2 and could use some advice. I would like to subscribe to a ros2 topic from one workspace, and publish that information to a separate ros2 topic on a separate workspace. Given that these workspaces are each sourced independently, and the topics only available in terminals where they are sourced, I'm not sure how to go about this. If it makes any difference, I would likely end up doing this in a python script instead of a terminal. Information on my platform and stack is at the bottom.
1st workspace: ros2-vicon-receiver
This workspace uses a Vicon (motion capture) datastream to create a ros2 topic of object position estimates.
source ~/ros2-vicon-receiver/vicon_receiver/install/setup.bash
ros2 launch vicon_receiver client.launch.py
ros2 topic echo /vicon/vicon_object/vicon_object
This outputs the vicon position information:
x_trans: -123.21699523925781
y_trans: 208.47030639648438
z_trans: 9545.1748046875
x_rot: 0.6378947496414185
y_rot: 0.5461642742156982
z_rot: -0.3194762170314789
w: 0.43901005387306213
segment_name: vicon_object
subject_name: vicon_object
frame_number: 216956
translation_type: Global
I would like to capture this position information and publish it to another ros2 topic in a different workspace (below).
2nd workspace: px4_ros_com
This workspace publishes ros2 topics to the PX4 flight controller over a bridge using micrortps.
source ~/px4_ros_com_ros2/install/setup.bash
micrortps_agent start -t UDP
ros2 topic pub /fmu/vehicle_mocap_odometry/in <msg_type> '<args>'
I plan to use a script to convert the information from the first workspace into the args that the second workspace requires.
For both workspaces, my env | grep ROS
is:
ROS_VERSION=2
ROS_PYTHON_VERSION=3
ROS_LOCALHOST_ONLY=0
ROS_DISTRO=foxy
Platform:
Distributor ID: Ubuntu
Description: Ubuntu 20.04.3 LTS
Release: 20.04
Codename: focal
Kernel: 5.4.0-124-generic
x86_64 GNU/Linux
Thank you very much!