Commit Graph
39 Commits
Author SHA1 Message Date
Peter BarkerandClaude Sonnet 4.6 3a92dded1e AP_Mount: factor send_camera_information into base class
Move the common mavlink_msg_camera_information_send call into
AP_Mount_Backend::send_camera_information(), following the same pattern as
send_gimbal_device_attitude_status(). Backends supply their specific data
via virtual getter overrides: get_camera_vendor_name(), get_camera_model_name(),
get_camera_firmware_version(), get_camera_focal_length_mm(), get_camera_lens_id(),
and get_camera_cap_flags(). Backends suppress sending by leaving
has_camera_information() returning false (the base class default); backends
with a known camera override it to return true. Siyi's previous
!_fw_version.received guard is dropped — the message now sends with
fw_version=0 until the version is received.

Also fixes the misaligned parameter comments in Viewpro's send call (focal_length
was labelled as sensor_size_h), since there is now only one copy of those comments.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-12 08:46:03 +09:00
Peter BarkerandClaude Sonnet 4.6 3b64dd7d92 AP_Mount: validate wire-data lengths before using as buffer/loop bounds
Topotek gimbal_version_analyse: data_buf_len comes from char_to_hex(_msg_buff[5]),
which returns 255 for an invalid hex byte. Return early on that value to reject
the malformed packet; a valid length field is always a hex digit.

Viewpro QUERY_MODEL handler: cap the memcpy to MIN(buffer, data_bytes_received-1)
so a short response cannot cause stale bytes from a previous packet to appear in
_model_name.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-07 08:45:08 +10:00
Peter BarkerandClaude Sonnet 4.6 482a6efe87 AP_Mount: use MAVLink field len defines and strncpy_noterm for camera_information strings
Replace hardcoded buffer sizes (32, 140) with MAVLINK_MSG_CAMERA_INFORMATION_FIELD_*_LEN
defines in Siyi, Viewpro, Topotek, and Xacti backends. Use strncpy_noterm (which omits
the null terminator only when the string fills the field, as MAVLink allows) in place of
strncpy for copies into vendor_name and model_name send buffers. Also cap the Topotek
gimbal_model_name_analyse strncpy to sizeof(_model_name)-1 to ensure null termination,
and document _model_name as always null-terminated in both Viewpro and Topotek headers.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-07 08:45:08 +10:00
Peter Barker d45e298a1f AP_Mount: avoid buffer-overread sending Viewpro camera_information
we prepared a buffer on the stack of the correct length but didn't use it.

The mavlink bindings memcpy out of this buffer according to the spec-defined length, so a buffer of at least that length should be supplied
2026-04-07 08:45:08 +10:00
Peter BarkerandClaude Sonnet 4.6 8f0040fad2 AP_Mount: use char[] rather than uint8_t[] for gimbal model name
The _model_name member in Viewpro and Topotek drivers holds a
null-terminated ASCII string, so char[] is the correct type.
Using uint8_t[] required pervasive (char*) and (const char*) casts
at every point of use. Switch to char[] and remove the now-redundant
casts, adding (const uint8_t*) only where the MAVLink API requires it.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-07 08:45:08 +10:00
Peter BarkerandClaude Sonnet 4.6 be466868cf AP_Mount: Viewpro: replace strncpy with memcpy to fix -Wstringop-truncation
Making _msg_buff_data_start static constexpr allowed the compiler to
constant-fold the source pointer in the strncpy call, exposing a
-Wstringop-truncation warning: the source buffer extends 62 bytes but
only 10 are copied. The truncation is intentional (bounding to the
destination size), so replace with memcpy + explicit null terminator
to make the intent clear and silence the warning.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-07 08:45:08 +10:00
Peter Barker c6cea72c53 AP_Mount: add send_target_to_gimbal on AP_Mount_Backend
calls virtual methods which sends commands to the gimbal
2025-12-20 18:55:39 +11:00
Peter Barker d9f8b46ffb AP_Mount: create an update_mnt_target method to factor code up 2025-12-09 08:55:13 +09:00
Ep Pravitra 1ae116a732 AP_Mount: send the currently selected image sensor for ViewPro gimbal 2025-11-05 16:12:11 +09:00
Oleksiy Protas 373d4a1e52 AP_Mount: retract servo(s) operation for all backends 2025-08-06 08:47:01 +10:00
Peter Barker 60cf43135e AP_Mount: use get_roll_deg in place of degrees(get_roll_rad) etc. 2025-08-05 09:00:08 +09:00
Peter Barker 461faa1db8 AP_Mount: rename AHRS get_roll etc accessors to include _rad 2025-06-05 17:28:41 +10:00
Ep Pravitra 43cdf1a03d AP_Mount: fix object tracking command for ViewPro
The command should also take negative values

Redo scaling to comply with mavlink documentation.
2025-02-08 08:48:52 +09:00
Ep Pravitra 0b659ac8a1 AP_Mount: zoom for Viewpro IR sensor 2025-02-06 10:50:14 +09:00
Peter Barker 99e314f49a AP_Mount: tidy header includes
our pattern is to include the config file and then use the relevant define, with nothing in between
2024-11-12 13:02:43 +11:00
Peter Barker dcc04d685f AP_Mount: factor out update_mnt_target_from_rc_target from servo, use it elsewhere
this gives all backends the neutral-on-RC-failsafe behaviour
2024-11-12 11:01:21 +11:00
Peter Barkerandmuramura decf484702 AP_Mount: use NaN in place of 0 for camera information message
Co-authored-by: muramura <ma2maru@gmail.com>
2024-09-26 19:26:59 +10:00
Peter Barker edc0e46614 AP_Mount: add and use global NaNf float value 2024-09-26 19:26:59 +10:00
Randy Mackay 7fc00efe7e AP_Mount: Viewpro inherits from serial backend 2024-05-22 18:00:22 +10:00
muramura a9d0bf856e AP_Mount: Do not perform unnecessary processing 2024-04-11 18:35:01 +10:00
Randy Mackay a6a5cde34c AP_Mount: add set_camera_source support 2024-03-25 09:19:18 +09:00
Randy Mackay f9198b7e4e AP_Mount: add set_rangefinder_enable for ViewPro 2024-03-22 14:55:43 +09:00
Randy Mackay 456c1bf39c AP_Mount: viewpro fix for swapped ahrs roll pitch 2024-03-20 17:59:48 +11:00
Peter Barker 64d3897126 AP_Mount: correct compilation when GCS not available 2024-03-09 10:20:03 +11:00
Peter Barker 49c697221a AP_Mount: make AHRS attitude member variables private 2024-01-14 12:47:47 +11:00
Randy Mackay fa5e58d652 AP_Mount: switch to RC_TARGETING on RC input 2024-01-10 09:48:00 +09:00
Peter Barker 48b10a3105 AP_Mount: allow for compilation without AP_RTC_ENABLED 2023-10-11 19:17:27 +11:00
Randy Mackay 6a14c1f72f AP_Mount: Viewpro fix for date sent from autopilot 2023-08-29 11:34:51 +10:00
Randy Mackay 9d09739044 AP_Mount: Viewpro supports get rangefinder distance 2023-08-23 18:09:56 +10:00
davidsastresas 767710340a AP_Mount: Viewpro sends gimbal_device_id in camera_information 2023-08-10 14:37:30 +09:00
Peter Barker 117d99045d AP_Mount: correct ViewPro compilation under g++-7.5.0
non-trivial designators not implemented
2023-08-02 11:32:31 +09:00
Randy Mackay 617fb98eb6 AP_Mount: viewpro gets vehicle yaw in 0 to 360 range 2023-07-26 20:20:13 +09:00
Randy Mackay 0ccf41b525 AP_Mount: viewpro formatting fix 2023-07-26 20:20:13 +09:00
Randy Mackay 70cf9de970 AP_Mount: viewpro directly fills in packet structures 2023-07-26 20:20:13 +09:00
Randy Mackay cea0acdb01 AP_Mount: viewpro implements set lens
also reports model, firmware version and zoom to GCS
also gets recording status from gimbal
2023-07-26 20:20:13 +09:00
Randy Mackay 2812b1e8bf AP_Mount: viewpro fix for pitch angle reporting 2023-07-26 17:33:18 +10:00
Asif Khan fd6db1ef45 AP_Mount: add MNT log msg for mount's actual and target angles logging 2023-07-26 17:33:18 +10:00
Randy Mackay d5977b6d96 AP_Mount: viewpro calc_crc len arg fix
Also remove one unnecessary length check
Also correct length check that meant last byte of buffer was unusable
2023-07-18 21:02:02 +09:00
Randy Mackay a8bb79b9ab AP_Mount: add viewpro cpp driver 2023-07-18 21:02:02 +09:00