mavlink / c_uart_interface_example

Simple MAVLink to UART interface example for *nix systems
264 stars 257 forks source link

Able to write, unable to get actions. #32

Closed Root3287 closed 4 years ago

Root3287 commented 4 years ago

Our code is like this code, but more simplified. We are able to read, and write (at least it's not giving us errors when trying to write to the pixhawk). But we are not able to control anything. We tried using px4 and ardupilot, but we still get nothing working with writing.

Is there any like any handshake to establish communication to the pixhawk?

What to packets to send to make motors spin or to make a sound on the buzzer?

hamishwillee commented 4 years ago

There isn't a handshake, but the system may expect your code to conform to the HEARTBEAT protocol: https://mavlink.io/en/services/heartbeat.html.

The motors won't spin unless you're armed, and they won't arm until the estimators have a position lock (generally). So usually startup code looks at these things. Using MAVSDK this looks like: https://mavsdk.mavlink.io/develop/en/guide/taking_off_landing.html

To play a sound you can use https://mavlink.io/en/messages/common.html#PLAY_TUNE_V2 (PX4 latest version) or https://mavlink.io/en/messages/common.html#PLAY_TUNE

The easiest way to work out what might be going on is to look at the code for https://github.com/mavlink/MAVSDK (or maybe https://github.com/dronekit/dronekit-python for ArduPilot)

Root3287 commented 4 years ago

So what I understand is that my flight program should be responding to the heartbeats. Then to play a sound I should just send a play tune packet.

If I want to start up the motors I arm the pixhawk and then send some packet to make it fly.

Did I get that correct?

hamishwillee commented 4 years ago

Yes. The remaining point was "copy what works". The higher level APIs like MAVSDK abstract the hard stuff for you.

Root3287 commented 4 years ago

Thank you for this insight!