From 6a01835bb3743fb196ebf995e269498df511dd43 Mon Sep 17 00:00:00 2001 From: Ltxx <55067345+Tartistbz@users.noreply.github.com> Date: Wed, 2 Sep 2026 15:51:07 +0800 Subject: [PATCH] docs(ros2): clarify VehicleCommand routing (#28245) --- docs/en/ros2/multi_vehicle.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/docs/en/ros2/multi_vehicle.md b/docs/en/ros2/multi_vehicle.md index abed4ee206e..05a9e695f8c 100644 --- a/docs/en/ros2/multi_vehicle.md +++ b/docs/en/ros2/multi_vehicle.md @@ -45,10 +45,17 @@ The default client configuration in simulation is summarized as follows: | not provided | >0 | `px4_instance+1` | `px4_${px4_instance}` | | provided | >0 | `px4_instance+1` | `PX4_UXRCE_DDS_NS` | -## Adjusting the `target_system` value +## Adjusting `VehicleCommand` routing fields PX4 accepts [VehicleCommand](../msg_docs/VehicleCommand.md) messages only if their `target_system` field is zero (broadcast communication) or coincides with `MAV_SYS_ID`. In all other situations, the messages are ignored. Therefore, when ROS 2 nodes want to send `VehicleCommand` to PX4, they must ensure that the messages are filled with the appropriate `target_system` value. For example, if you want to send a command to your third vehicle, which has `px4_instance=2`, you need to set `target_system=3` in all your `VehicleCommand` messages. + +PX4 applies the same filtering to `target_component`: a command is handled when the value is `0` (broadcast) or matches the component ID of the autopilot (as set with [MAV_COMP_ID](../advanced_config/parameter_reference.md#MAV_COMP_ID)). +For a normal PX4 flight controller, `target_component=1` addresses the autopilot component. +Any other non-zero value is ignored, as it is intended for another component. + +Commands published by ROS 2 or another process outside PX4 must set `target_system`, `target_component`, `source_system`, and `source_component` appropriately for routing and acknowledgements. +The `from_external` flag is not required for routing; it affects how PX4 handles commands originating outside the autopilot, including forced arm commands.