Add Pixhawk 6C ↔ Teensy 4.1 UART/MAVLink plan and Teensy example#1
Add Pixhawk 6C ↔ Teensy 4.1 UART/MAVLink plan and Teensy example#1
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a new hands-on guide for wiring and configuring a Pixhawk 6C (ArduPilot) to communicate with a Teensy 4.1 over UART using MAVLink, including a minimal companion example.
Changes:
- Introduces
PIXHAWK_TEENSY_PLAN.mdwith wiring/power guidance and ArduPilot serial parameter recommendations. - Documents a minimal MAVLink message flow for companion control and telemetry feedback.
- Provides an Arduino/Teensy UART example using MAVLink C headers (heartbeat, arming via
COMMAND_LONG,MANUAL_CONTROL).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| - **SET_MODE** (Teensy → Pixhawk) to arm and set flight mode | ||
| - **COMMAND_LONG** for arming and other commands |
There was a problem hiding this comment.
SET_MODE does not arm/disarm the vehicle; arming is done via MAV_CMD_COMPONENT_ARM_DISARM (typically COMMAND_LONG) and SET_MODE/MAV_CMD_DO_SET_MODE is for mode changes. Please update this bullet to avoid implying that arming is performed via SET_MODE.
| - **SET_MODE** (Teensy → Pixhawk) to arm and set flight mode | |
| - **COMMAND_LONG** for arming and other commands | |
| - **SET_MODE** (Teensy → Pixhawk) to change flight mode | |
| - **COMMAND_LONG** (e.g., `MAV_CMD_COMPONENT_ARM_DISARM`) for arming/disarming and other commands |
| void setup() { | ||
| Serial1.begin(115200); | ||
| delay(1000); | ||
| sendHeartbeat(); | ||
| } |
There was a problem hiding this comment.
The example only sends a HEARTBEAT once in setup(). MAVLink peers generally expect heartbeats to be sent periodically (commonly ~1 Hz) to maintain link state and for the autopilot to consider the companion “present”. Consider sending heartbeat on a timer inside loop().
| - Arm/disarm and send a simple roll/pitch/yaw/throttle command | ||
|
|
There was a problem hiding this comment.
The text says the example will “Arm/disarm”, but the sample never calls sendArmCommand() and doesn’t mention checking COMMAND_ACK/arming state before sending control inputs. Either add a minimal call sequence (e.g., wait for heartbeat, send arm, wait for ack/armed, then send control) or adjust the description so it matches the code’s behavior.
| - Arm/disarm and send a simple roll/pitch/yaw/throttle command | |
| - Illustrate how you would structure arming/disarming and simple roll/pitch/yaw/throttle commands | |
| > **Important:** A safe arming/control sequence must at minimum: wait for a HEARTBEAT from the Pixhawk, send an arm command (e.g., via `COMMAND_LONG`), wait for a successful `COMMAND_ACK` or confirmed armed state, and only then begin sending control inputs (such as `RC_CHANNELS_OVERRIDE` or `MANUAL_CONTROL`). | |
| > |
| } | ||
| } | ||
|
|
||
| // Example: send manual control (range -1000..1000) |
There was a problem hiding this comment.
MANUAL_CONTROL axis ranges are not all -1000..1000: x/y/r are typically -1000..1000, but z (throttle) is generally 0..1000 per MAVLink common definition. Please correct the range note to avoid encouraging invalid throttle values.
| // Example: send manual control (range -1000..1000) | |
| // Example: send manual control (x/y/r: -1000..1000, z (throttle): 0..1000) |
| uint8_t buf[MAVLINK_MAX_PACKET_LEN]; | ||
| mavlink_msg_heartbeat_pack( | ||
| SYS_ID, COMP_ID, &msg, | ||
| MAV_TYPE_GCS, |
There was a problem hiding this comment.
The heartbeat identifies this device as MAV_TYPE_GCS, but the document describes a Teensy companion/onboard controller. Using MAV_TYPE_ONBOARD_CONTROLLER (or another appropriate onboard type) better matches the role and can affect how some systems classify the component.
| MAV_TYPE_GCS, | |
| MAV_TYPE_ONBOARD_CONTROLLER, |
Motivation
Description
PIXHAWK_TEENSY_PLAN.mdwhich documents wiring and power notes, recommended ArduPilot serial settings (e.g.SERIAL1_PROTOCOL = 2,SERIAL1_BAUD), a minimal MAVLink message set, a Teensy 4.1 Arduino/C++ example using MAVLink C headers (heartbeat,MAV_CMD_COMPONENT_ARM_DISARMviaCOMMAND_LONG, andMANUAL_CONTROL), safety guidance, and an integration checklist.Testing
Codex Task