Skip to content

Add Pixhawk 6C ↔ Teensy 4.1 UART/MAVLink plan and Teensy example#1

Open
kellytai wants to merge 1 commit intomainfrom
codex/create-coding-plan-for-pixhawk-6c-and-teensy-4.1
Open

Add Pixhawk 6C ↔ Teensy 4.1 UART/MAVLink plan and Teensy example#1
kellytai wants to merge 1 commit intomainfrom
codex/create-coding-plan-for-pixhawk-6c-and-teensy-4.1

Conversation

@kellytai
Copy link
Owner

@kellytai kellytai commented Feb 9, 2026

Motivation

  • Provide a concrete, hands-on guide for connecting a Pixhawk 6C running ArduPilot to a Teensy 4.1 over UART/MAVLink, including wiring, firmware configuration, message flow, and example companion code to enable autopilot control and testing.

Description

  • Add PIXHAWK_TEENSY_PLAN.md which 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_DISARM via COMMAND_LONG, and MANUAL_CONTROL), safety guidance, and an integration checklist.

Testing

  • No automated tests were run because this is a documentation-only change.

Codex Task

Copilot AI review requested due to automatic review settings February 9, 2026 05:57
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.md with 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.

Comment on lines +32 to +33
- **SET_MODE** (Teensy → Pixhawk) to arm and set flight mode
- **COMMAND_LONG** for arming and other commands
Copy link

Copilot AI Feb 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
- **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

Copilot uses AI. Check for mistakes.
Comment on lines +97 to +101
void setup() {
Serial1.begin(115200);
delay(1000);
sendHeartbeat();
}
Copy link

Copilot AI Feb 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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().

Copilot uses AI. Check for mistakes.
Comment on lines +42 to +43
- Arm/disarm and send a simple roll/pitch/yaw/throttle command

Copy link

Copilot AI Feb 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
- 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`).
>

Copilot uses AI. Check for mistakes.
}
}

// Example: send manual control (range -1000..1000)
Copy link

Copilot AI Feb 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
// Example: send manual control (range -1000..1000)
// Example: send manual control (x/y/r: -1000..1000, z (throttle): 0..1000)

Copilot uses AI. Check for mistakes.
uint8_t buf[MAVLINK_MAX_PACKET_LEN];
mavlink_msg_heartbeat_pack(
SYS_ID, COMP_ID, &msg,
MAV_TYPE_GCS,
Copy link

Copilot AI Feb 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
MAV_TYPE_GCS,
MAV_TYPE_ONBOARD_CONTROLLER,

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants