> For the complete documentation index, see [llms.txt](https://realtimerobotics.gitbook.io/real-time-robotics/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://realtimerobotics.gitbook.io/real-time-robotics/gimbal/mavlink-message.md).

# MAVLink Message

## RTR Gimbal MAVLink Message

Real time Robotics H1/H2 Gimbal MAVLink Message Commands

### MAVLink Commands

#### [HEARTBEAT](https://mavlink.io/en/messages/minimal.html#HEARTBEAT) - 1Hz

Heartbeat mà gimbal trả về. Tần số là 1Hz.

| Field Name       | Type                       | Value       | Description         |
| ---------------- | -------------------------- | ----------- | ------------------- |
| type             | uint8\_t                   | <p><br></p> | <p><br></p>         |
| autopilot        | uint8\_t                   | <p><br></p> | <p><br></p>         |
| base\_mode       | charuint8\_t16]            | <p><br></p> | <p><br></p>         |
| custom\_mode     | uint32\_t                  | <p><br></p> | <p><br></p>         |
| system\_status   | uint8\_t                   | <p><br></p> | System status flag. |
| mavlink\_version | uint8\_t\_mavlink\_version | <p><br></p> | MAVLink version     |

#### [RAW\_IMU](https://mavlink.io/en/messages/common.html#RAW_IMU) - 10Hz

Thông tin về raw IMU của gimbal, Tần số là 10Hz.

| Field Name     | Type      | Units       | Description                                                                                          |
| -------------- | --------- | ----------- | ---------------------------------------------------------------------------------------------------- |
| time\_usec     | uint64\_t | us          | Timestamp                                                                                            |
| xacc           | int16\_t  | <p><br></p> | X acceleration (raw)                                                                                 |
| yacc           | int16\_t  | <p><br></p> | Y acceleration (raw)                                                                                 |
| zacc           | int16\_t  | <p><br></p> | Z acceleration (raw)                                                                                 |
| xgyro          | int16\_t  | <p><br></p> | Angular speed around X axis (raw)                                                                    |
| ygyro          | int16\_t  | <p><br></p> | Angular speed around Y axis (raw)                                                                    |
| zgyro          | int16\_t  | <p><br></p> | Angular speed around Z axis (raw)                                                                    |
| xmag           | int16\_t  | <p><br></p> | X Magnetic field (raw)                                                                               |
| ymag           | int16\_t  | <p><br></p> | Y Magnetic field (raw)                                                                               |
| zmag           | int16\_t  | <p><br></p> | Z Magnetic field (raw)                                                                               |
| id ++          | int16\_t  | <p><br></p> | Ids are numbered from 0 and map to IMUs numbered from 1                                              |
| temperature ++ | int16\_t  | cdegC       | Temperature, 0: IMU does not provide temperature values. If the IMU is at 0C it must send 1 (0.01C). |

#### [MOUNT\_ORIENTATION](https://mavlink.io/en/messages/common.html#MOUNT_ORIENTATION) - 50Hz

Trả về góc tilt, roll, pan của gimbal. Tần số là 50Hz.

| Field Name       | Type      | Value | Description                         |
| ---------------- | --------- | ----- | ----------------------------------- |
| time\_boot\_ms   | uint32\_t | ms    | Timestamp (time since system boot). |
| roll             | float     | deg   | Roll in global frame                |
| pitch            | float     | deg   | Pitch in global frame               |
| yaw              | float     | deg   | Yaw relative to vehicle             |
| yaw\_absolute ++ | float     | deg   | Not used                            |

#### [COMMAND\_LONG](https://mavlink.io/en/messages/common.html#COMMAND_LONG)&#x20;

Gửi các lệnh MAV\_CMD qua gói COMMAND\_LONG.

| Field Name        | Type      | Value       | Description                                                              |
| ----------------- | --------- | ----------- | ------------------------------------------------------------------------ |
| target\_system    | uint8\_t  | <p><br></p> | System which should execute the command                                  |
| target\_component | uint8\_t  | <p><br></p> | Component which should execute the command, 0 for all components         |
| command           | uint16\_t | MAV\_CMD    | Command ID (of command to send).                                         |
| confirmation      | uint8\_t  | <p><br></p> | 0: First transmission of this command. 1-255: Confirmation transmissions |
| param1            | float     | <p><br></p> | Parameter 1                                                              |
| param2            | float     | <p><br></p> | Parameter 2                                                              |
| param3            | float     | <p><br></p> | Parameter 3                                                              |
| param4            | float     | <p><br></p> | Parameter 4                                                              |
| param5            | float     | <p><br></p> | Parameter 5                                                              |
| param6            | float     | <p><br></p> | Parameter 6                                                              |
| param7            | float     | <p><br></p> | Parameter 7                                                              |

#### [COMMAND\_ACK](https://mavlink.io/en/messages/common.html#COMMAND_ACK)

Feedback lại status của command.

| Field Name           | Type      | Units       | Value                                                                | Description                           |
| -------------------- | --------- | ----------- | -------------------------------------------------------------------- | ------------------------------------- |
| command              | uint16\_t | <p><br></p> | MAV\_CMD                                                             | Command ID (of acknowledged command). |
| result               | uint8\_t  | <p><br></p> | [MAV\_RESULT](https://mavlink.io/en/messages/common.html#MAV_RESULT) | Result of command.                    |
| progress ++          | uint8\_t  | %           | invalid:UINT8\_MAX                                                   | Not used                              |
| result\_param2 ++    | int32\_t  | <p><br></p> | <p><br></p>                                                          | Not used                              |
| target\_system ++    | uint8\_t  | <p><br></p> | <p><br></p>                                                          | Not used                              |
| target\_component ++ | uint8\_t  | <p><br></p> | <p><br></p>                                                          | Not used                              |

#### [MAV\_CMD\_DO\_MOUNT\_CONTROL](https://mavlink.io/en/messages/common.html#MAV_CMD_DO_MOUNT_CONTROL)

Lệnh dùng để điều khiển pitch, roll, yaw của gimbal.

| Param (Label) | Description                   | Values      | Units       |
| ------------- | ----------------------------- | ----------- | ----------- |
| pitch         | pitch depending on mount mode | <p><br></p> | deg         |
| roll          | roll depending on mount mode  | <p><br></p> | deg         |
| yaw           | yaw depending on mount mode   | <p><br></p> | deg         |
| Altitude      | Not used                      | <p><br></p> | <p><br></p> |
| Latitude      | Not used                      | <p><br></p> | <p><br></p> |
| Longitude     | Not used                      | <p><br></p> | <p><br></p> |
| Mode          | Not used                      | <p><br></p> | <p><br></p> |

#### [MAV\_CMD\_USER\_2](https://mavlink.io/en/messages/common.html#MAV_CMD_USER_2)

Dùng để chuyển mode của gimbal giữa FOLLOW và LOCK.

| Param (Label) | Description        |
| ------------- | ------------------ |
| 1             | Not used           |
| 2             | Not used           |
| 3             | Not used           |
| 4             | Not used           |
| 5             | Not used           |
| 6             | Not used           |
| 7             | 0: LOCK, 1: FOLLOW |

#### [PARAM\_SET](https://mavlink.io/en/messages/common.html#PARAM_SET)

Dùng để set các param cho việc tuning gimbal:

| Field Name        | Type      | Value       | Description            |
| ----------------- | --------- | ----------- | ---------------------- |
| target\_system    | uint8\_t  | <p><br></p> | System ID              |
| target\_component | uint8\_t  | <p><br></p> | Component ID           |
| param\_id         | char\[16] | <p><br></p> | Gimbal parameter id    |
| param\_value      | float     | <p><br></p> | Gimbal parameter value |
| param\_type       | uint8\_t  | <p><br></p> | Not used               |

Giá trị param\_id và param\_value (range) được mô tả ở bảng phụ lục 1.

#### [PARAM\_REQUEST\_READ](https://mavlink.io/en/messages/common.html#PARAM_REQUEST_READ)

Dùng để request một param của gimbal

| Field Name        | Type      | Value       | Description             |
| ----------------- | --------- | ----------- | ----------------------- |
| target\_system    | uint8\_t  | <p><br></p> | System ID               |
| target\_component | uint8\_t  | <p><br></p> | Component ID            |
| param\_id         | char\[16] | <p><br></p> | Gimbal parameter id     |
| param\_index      | int16\_t  | -1          | Not used, default is -1 |

Giá trị param\_id  được mô tả như bảng phụ lục 1.

#### [PARAM\_REQUEST\_LIST](https://mavlink.io/en/messages/common.html#PARAM_REQUEST_LIST)

Request tất cả các param của gimbal cùng lúc theo gói PARAM\_VALUE

| Field Name        | Type     | Value       | Description  |
| ----------------- | -------- | ----------- | ------------ |
| target\_system    | uint8\_t | <p><br></p> | System ID    |
| target\_component | uint8\_t | <p><br></p> | Component ID |

#### [PARAM\_VALUE](https://mavlink.io/en/messages/common.html#PARAM_VALUE)

Giá trị param của gimbal trả về khi gói PARAM\_REQUEST\_READ hoặc PARAM\_REQUEST\_LIST  được gửi.

| Field Name   | Type      | Value       | Description            |
| ------------ | --------- | ----------- | ---------------------- |
| param\_id    | char\[16] | <p><br></p> | Gimbal parameter id    |
| param\_value | float     | <p><br></p> | Gimbal parameter value |
| param\_type  | uint8\_t  | 0           | Not used               |
| param\_count | uint16\_t | 0           | Not used               |
| param\_index | uint16\_t | 0           | Not used               |

### Appendix

Bảng phụ lục 1: param\_id và range của các thông số dùng để tune Gimbal H1, H2:

| param\_id | param\_name         | range        | description              |
| --------- | ------------------- | ------------ | ------------------------ |
| 1         | ROLL\_ACCEL\_MOVING | 10 - 100     | Roll gimbal accel moving |
| 2         | ROLL\_ACCEL\_OFFSET | -1000 - 1000 | Roll gimbal accel offset |
| 3         | ROLL\_P\_GAIN       | 10 - 100     | Roll gimbal P gain       |
| 4         | ROLL\_I\_GAIN       | 10 - 100     | Roll gimbal I gain       |
| 5         | ROLL\_D\_GAIN       | 10 - 100     | Roll gimbal D gain       |
| 11        | TITL\_ACCEL\_MOVING | 10 - 100     | Tilt gimbal accel moving |
| 12        | TILT\_ACCEL\_OFFSET | -1000 - 1000 | Tilt gimbal accel offset |
| 13        | TILT\_P\_GAIN       | 10 - 100     | Tilt gimbal P gain       |
| 14        | TILT\_I\_GAIN       | 10 - 100     | Tilt gimbal I gain       |
| 15        | TILT\_D\_GAIN       | 10 - 100     | Tilt gimbal D gain       |
| 21        | PAN\_ACCEL\_MOVING  | 10 - 100     | Pan gimbal accel moving  |
| 22        | PAN\_ACCEL\_OFFSET  | -800 - 2800  | Pan gimbal accel offset  |
| 23        | PAN\_P\_GAIN        | 10 - 100     | Pan gimbal P gain        |
| 24        | PAN\_I\_GAIN        | 10 - 100     | Pan gimbal I gain        |
| 25        | PAN\_D\_GAIN        | 10 - 100     | Pan gimbal D gain        |

<br>
