PX4-Autopilot icon indicating copy to clipboard operation
PX4-Autopilot copied to clipboard

Use target camera in image capture start/stop messages

Open hamishwillee opened this issue 1 year ago • 3 comments
trafficstars

MAV_CMD_IMAGE_START_CAPTURE and MAV_CMD_IMAGE_STOP_CAPTURE now take the component ID of the target camera in param1. This allows the commands to be addressed to a particular camera when used in a mission.

This change modifies the code that publishes the commands to a mavlink camera to use the id if it is between 1 and 255 (inclusive) and otherwise use 100 (the allocated first ID in for cameras). Note that range 1 to 6 (inclusive) are supposed to be reserved for cameras connected to FCs, so if we ever support that case, we'd need to change this code.

Previously the command was always addressed to 100. This is a little poor, since IDs cannot be guaranteed to be reserved.

hamishwillee avatar May 09 '24 07:05 hamishwillee

@julianoes OK, so I added code to set the ID for SET_CAMERA_MODE too.

So for this to be "rock solid" we may need to add support for caching of MAV_CMD_SET_CAMERA_SOURCE. As per https://github.com/PX4/PX4-Autopilot/pull/23115#discussion_r1600977412 "can you do this?"

If not, let me know.


A complete aside:

  • the changes made here are good for setting the target id in the explicit camera cases - they default to the camera id specified or 100.
  • But other mavlink commands, including the video commands will be sent to all cameras - we don't index them by component id but by stream id. In theory we should probably maintain a mapping of stream id and component id and send commands addressed to a particular stream id to only that camera.

hamishwillee avatar May 23 '24 00:05 hamishwillee

@hamishwillee make sure to run make format to fix styling.

julianoes avatar May 23 '24 02:05 julianoes

@julianoes I finally got around to running format on this, which cleared your approval. There is a SITL error, which I suspect is unrelated. Can you confirm?

hamishwillee avatar Aug 07 '24 01:08 hamishwillee