I am trying to understand how does the communication between QGroundControl and PixHawk flight controller is taking place.
Say, I have a camera connected to the PixHawk via a physical connection. What I am trying to understand is when I push turn on button on QGroundControl to turn on the camera how the communication is taking place. How does the ON message will get to the camera through PixHawk ? Do I need to make a node for it on uORB layer ?
If you want to understand some principles (not implementation-specific and not specific to QGC) of MAVLink, here’s a short guide, definitely worth a read.
However, without more information like
- which camera are you using? (Is it a FPV camera, does it support CHDK etc.)
- How did you connect the camera to the Pixhawk? (AUX Port?)
- What do you actually want to achieve?
You’ve written [quote=“muscles, post:1, topic:941”]
[…] QGroundControl to turn on the camera […]
so do you wanna turn it on? Or make the camera take a picture (assuming the camera is turned on manually before flight)?
Note that QGC comes with quite some camera support out of the box, so maybe there’s no reason to re-invent the wheel. Maybe you run in this issue though?
Also have a look at the MAVLink message definitions, they give you a great overview of what the protocol is capable of per default, even though the information might overwhelm you, but
Ctrl+F is your friend.
Maybe you just want a button on your remote to trigger the shutter of your camera? As I said, understanding your use case might help a lot
Thank You very much for the response. The camera was just an example. What I am trying to achieve is to integrate a sensor package onboard with PixHawk and the sensor will be controlled from QGroundControl via MAVLink. My goal is to understand how it can be done using the QGroundControl and PX4 firmware. Is it something already avaialble or I need to work on it and where should I focus on the firmware side and QGroundControl Side. Like for example I want a button on QGroundControl which simply turns ON/OFF the sensor, as soon as the sensor is on it will start doing its task.
Iam just trying to figure out how the message will get to the Sensor ( I meant turn on message ) as soon as I push the ON button on QGC. What are the different steps involved ?
Ok, so your task, besides the hardware integration can be splitted into three categories:
- MAVLink communicatoin
- PX4 stack
I would approach it in that order, that is:
@1. find out which MAVLink message you want to send or define your custom one
@2. implement it in QGroundControl - a good way to tackle this is to look at an implementation which does almost what you want to do. Right now I’ve got the
PAUSE button in my mind. See what happens when you click it, from the qml button’s click event, over to
Vehicle.cc and finally to
PX4FirmwarePlugin::pauseVehicle which, ultimately, sends the message. This should be quite straightforward to adapt to your needs once you integrated your own messages
@3. That’s the part I can’t really help you, I haven’t looked into the PX4 stack so far, so I can’t really say a lot about it. Of course your custom MAVLink message(s) need to be integrated here as well, and yes, I thing uORB comes into play, but it’s just a request broker, nothing really to worry about. Maybe following
PAUSE here as well might not be a that good idea, cause I think it’s a flight mode, that’s at least what it is on the APM side. But sorry, I’m the wrong guy for #3
Sounds like an interesting project which makes you get in touch with all the major components, keep us updated
Let me expand on the 3rd step: assuming you have your custom mavlink message, you need to add a handler for it in the PX4 code. This is described here: http://dev.px4.io/custom-mavlink-message.html#receiving-custom-mavlink-messages
Then you probably have your own application ( http://dev.px4.io/tutorial-hello-sky.html) or device driver to talk to the device and handle the logic. From the mavlink handler you need to send an uORB message and subscribe to it in your own application. How to add an uORB message is described here: http://dev.px4.io/advanced-uorb.html
those links are not working can you resend it please.