A ROS2 adaptation of the vision_to_mavros package for integrating vision-based pose estimation systems with MAVROS in ROS2.
- Easy integration between vision-based systems (like Intel® RealSense™ T265) and ArduPilot/PX4 via MAVROS
- Simple configuration for various camera mounting orientations
- Transforms TF2 pose data to the frame expected by flight controllers
- Full ROS2 implementation with launch files for quick setup
- Support for precision landing capabilities
This package provides a bridge between vision-based localization systems and flight controllers using ROS2. It subscribes to TF2 transforms provided by vision systems (like the Intel RealSense T265 tracking camera), performs the necessary frame transformations, and publishes the pose data in a format that can be consumed by MAVROS and subsequently by flight controllers like ArduPilot or PX4.
The vision_to_mavros node handles the coordinate frame transformations to convert from the vision system's frame to the frame expected by the flight controller, ensuring proper alignment of the body frame with the world frame according to ENU (East-North-Up) conventions.
This ROS2 adaptation is based on the original vision_to_mavros package created by Thien Nguyen for ROS1.
The package is particularly useful when integrating the T265 tracking camera with ArduPilot or PX4. The camera provides visual-inertial odometry data through TF2 transforms, which are then processed by vision_to_mavros to provide vision-based pose estimates to the flight controller.
A typical setup requires running three nodes:
- The T265 camera node (from realsense-ros)
- MAVROS node for communication with the flight controller
- vision_to_mavros node to transform the pose data
The package includes a launch file for easy setup with the T265 camera:
ros2 launch vision_to_mavros t265_tf_to_mavros_launch.pyFor a complete setup with all required nodes:
ros2 launch vision_to_mavros t265_all_nodes_launch.pyThe package supports various camera mounting orientations with appropriate configuration parameters:
Frontfacing:
- Forward, USB port to the right (default):
roll_cam=0.0, pitch_cam=0.0, yaw_cam=0.0, gamma_world=-1.5707963 - Forward, USB port to the left:
roll_cam=3.1415926, pitch_cam=0.0, yaw_cam=0.0, gamma_world=-1.5707963
Downfacing:
- USB port to the right:
roll_cam=0.0, pitch_cam=-1.5707963, yaw_cam=0.0, gamma_world=-1.5707963 - USB port to the left:
roll_cam=3.1415926, pitch_cam=-1.5707963, yaw_cam=0.0, gamma_world=-1.5707963 - USB port to the back:
roll_cam=-1.5707963, pitch_cam=-1.5707963, yaw_cam=0.0, gamma_world=-1.5707963 - USB port to the front:
roll_cam=1.5707963, pitch_cam=-1.5707963, yaw_cam=0.0, gamma_world=-1.5707963
Note for downfacing orientation: You need to tilt the vehicle's nose up slightly (not completely flat) when launching the T265 realsense-ros node, otherwise the initial yaw may be randomized (see this issue). Tilting the vehicle to any other side may affect yaw stability.
- Create a ROS2 workspace if you don't have one:
mkdir -p ~/ros2_ws/src
cd ~/ros2_ws- Clone the repository into your workspace:
cd ~/ros2_ws/src
git clone https://github.com/Black-Bee-Drones/vision_to_mavros.git- Build the package:
cd ~/ros2_ws
colcon build --symlink-install --packages-select vision_to_mavros
source install/setup.bashThe node provides several configuration parameters:
target_frame_id: The frame in which we find the transform (default:/camera_odom_frame)source_frame_id: The frame for which we find the transform (default:/camera_link)output_rate: The rate at which pose data is published (default:30.0)roll_cam,pitch_cam,yaw_cam: Rotation angles to align camera frame with body framegamma_world: Rotation around Z axis between world frame and target world frame
enable_precland: Flag to enable precision landing (default:false)precland_target_frame_id: Frame ID of the landing target (default:/landing_target)precland_camera_frame_id: Frame ID of the camera used for precision landing (default:/camera_fisheye2_optical_frame)
/mavros/vision_pose/pose(geometry_msgs/PoseStamped): The transformed pose for the flight controller/body_frame/path(nav_msgs/Path): Visualizes the trajectory of the body frame in rviz2