I would like to send information from raspberry pi to pixhawk and then send it to the laptop. My idea is to use UART communication Raspberry Pi <-> PIXHAWK. Then I want to extend Mavlink communication frame with my data and send it on the ground via 3dr 433 MHz radio module.
http://ardupilot.org/dev/docs/raspberry-pi-via-mavlink.html
I’ve made a UART communication same as in the 1st point of the guide above, however I cannot find any information on what data I should put on Raspberry output (telemetry input) to make it recognisable by Pixhawk. I’m also not sure if Pixhawk will send my custom data via Mavlink protocol to the ground station on laptop.
I’ve analyzed Mission Planner sources but I couldn’t extract the proper method to attach my own information to the Mavlink communication frame.
I know it could be done by using separate communication canals, f.e. creating a wi-fi connection just for Raspberry Pi and laptop. But 433 MHz module transmission rate is more that enought for my data, the only problem is how to attach my data to the data that are alredy send via Mavlink.
Also, if you are adding your own MAVLink messages, you’ll need to do build your version of ArduPilot, it won’t magically know the new messages (unfortunately ). There is some information about MAVLink at http://mavlink.org that you probably should read, if you haven’t.
I’ve done just this, but using the Pi to forward messages instead of reprogramming the Pixhawk to do so. I had the Pixhawk’s TELEM1 connected to a Teensy board attached to the Pi, and added some messages to the serial stream before a program on the Pi repeated those messages and sent them on to the telemetry radio connected via serial. And there was similar behavior for the reverse, the Pi would receive messages over the serial port from the telemetry radio, strip the ones the Pixhawk wouldn’t understand, and send the rest on to the Pix via the Teensy. This way, I only needed a custom MavLink message library on the Pi to enable the new telemetry types.
In hindsight, if you’re just forwarding a Teensy should be sufficient, but I wanted to do onboard calculations with the data so the Pi was a middleman.
Thanks James for the reply. Actually I want to send it in such manner. However I couldn’t recreate your approach. Could I please ask you about it a little more?
Firstly, what is the purpose of Teensy, if you have already Raspberry on board? Could you send a wiring diagram how you have connected Pixhawk, Teenesy and RASP? (What ports have been used?) Can you please tell me did you use this tutorial ( http://qgroundcontrol.org/mavlink/create_new_mavlink_message ), was it sufficient?
@Plkonrad The Teensy was used because the Pi is not very good at interfacing with external sensors. It has only one serial port, no analog capability, and SPI and I2C drivers can be cumbersome. The Teensy is comparatively very good at interfacing with hardware and sensors.
The Pi was connected to the Teensy and Pixhawk over USB. All the sensors were connected through the Teensy. In my case, all the data was sent to the ground over WiFi from the Pi instead of the 433MHz radio as you mentioned, but the approach would be the same.
Yes, I used the approach in your link to define new messages.
Hi, I am getting the GPS data from APM board using mavros on Rpi. Now, I want to send the data continuously to another computer and also I want to send the GPS coordinates of the position where the robot needs to reach to Rpi from that computer. How can I proceed?
Dear Pikonrad, it would be helpfull to inform us if you solved your issue and how?
Im facing a similar problem and I will try to help you:
I have connected through I2C two ARDUINOs (master a MEGA and slave a NANO). Using the following code they communicate correctly: For the master: #include <Wire.h>
String msg = String("");
void setup()
{
Wire.begin(); // join i2c bus (address optional for master)
Serial.begin(9600); // start serial for output
}
void loop()
{
Wire.requestFrom(10, 27); // request n=27 bytes from slave device #10
while (Wire.available())
{
char c = Wire.read(); // receive a byte as character
Serial.print(c); // print the character
}
delay(1000);
Wire.end();
} And for the slave: #include <Wire.h>
void setup()
{
Wire.begin(10); // join i2c bus with address #10
Wire.onRequest(requestEvent); // register event
}
void loop()
{
delay(1000);
}
// function that executes whenever data is requested by master
void requestEvent() // this function is registered as an event, see setup()
{
Wire.write("41.139234,24.912345,67.25; "); // respond with message of n bytes
}
I must replace the master ARDUINO MEGA with the PIXHAWK flight controller of a hexa. What is the code in python scripting, that will replace the above cpp code, in order to communicate through I2C with the slave ARDUINO NANO and read the above sentence "41.139234,24.912345,67.25;”? I use python scripting through Mission Planner to control the hexa.
An alternative way would be to send the above set of characters: ("41.139234,24.912345,67.25; ") through the Pixhawk’s serial port 2 (Telem2) loadind it on a message and using MAVLINK messaging to send it to GCS. Could some one please help me how to achieve it?
Thanking you in advance.