So guys, I'm doing a project related to Telemetry, and I want to make ArduPilot (Uploaded with ArduPlane 2.73) send through Serial Port, The sensors informations, like Height, GPS Position, and this kind of things. I have tried to use ArduStation, but I could not change its firmware to do what I want. 

   The idea is reading Ardupilot Serial port using an Arduino Uno, and then, saving it in a SD card in real-time. So ArduPilot needs to send data without any User Input or something like that. I've already tried to manipulate ArduPlane source code to do that, but I couldn't either.

Has someone here did something like that before? I need some advices!

Thanks,

Alessandro

alessandro.ssj@gmail.com

EDIT (30/06/2016) : Guys, I've successfully done the communication of Pixhawk with Arduino through Pixhawk's UART. So I can send informations of the pixhawk's IMU to arduino or any other microcontroller through serial PORT. So, if you want any help, I don't follow this post anymore, so send me an e-mail (alessandro.ssj@gmail.com) and I can help with some details.

EDIT(08/06/2017): So, since I've been receiving lots of emails about this issue, I will clarify here a little more.

The communication was from the arduino to the pixhawk through serial communication (and the inverse communication is straight forward). In the code shown below, the port TELEM2 is used.

The idea was to read a single byte of the serial port and wait for a flag, that was the character 'a' sent by an arduino ( I was communicating the Pixhawk with an arduino). So, when it detects an a, it starts to reads the rest of bytes until the flag 'b', which indicates end of transmission, arrives. The code below implements this idea:

int arduino_thread_main(int argc, char *argv[])
{
running = true;
struct arduino_s data;
char buffer[50];
int c; int i;

// Advertise arduino topic
memset(&data, 0 , sizeof(data));

//Open serial communication with Arduino
//ttyACM0=USB cable; ttyS1= TELEM1; ttyS2=TELEM2
//int fd=open("/dev/ttyS2", O_RDWR | 16 | 0); THIS OPEN STATEMENT DIDN't WORK WELL

FILE *fd=fopen("/dev/ttyS2","r"); // Open Serial communication through TELEM 2

orb_advert_t arduino_pub_fd = orb_advertise(ORB_ID(arduino), &data); // Advertise arduino uORB

while(!should_exit){
float rpm_hall=-1.0f; float rpm_motor=-1.0f; i=0;

while ((c=fgetc(fd)) !='\n') {buffer[i++] = c;} // Construct string from serial comm. c = fgetc(fd) do the magic!

buffer[i]='\0'; // Finish the construction of the string

sscanf(buffer,"h%fr%fe",&rpm_hall,&rpm_motor); // Read separated date using the protocol defined as "hDATAFLOATrDATAFLOATe"

data.hall=(double)rpm_hall*(M_PI/30.0); // in rad/s
data.rpm= (double)rpm_motor*(M_PI/30.0); // in rad/s

orb_publish(ORB_ID(arduino),arduino_pub_fd,&data); // Publish information

}
fclose(fd);
running = false;
return 0;
}

Another issue people are asking me, is how to get pixhawk sensors information (like pitch, yaw, altitude and so on) and do something with it (save in a SD card for example). 

Years ago I made a code to translate the ORB protocol used in pixhawk to access the sensors data, to a more friendly way. You can find the code here:

https://github.com/alessandroSSJ/AeroPixHawk/

Thanks!

Alessandro Soares da Silva Junior - PUC-Rio<\p>

Views: 10484

Reply to This

Replies to This Discussion

Hey @Alessandro - would you perhaps still have the code you used to have the PX4 send those values through it's UART? I am trying to do something similar, where I read PWM values that I am trying to print on the UART and read it via a microcontroller. As of now, all I get is "blank"

uint8_t nchannels = hal.rcin->num_channels();
 
for (uint8_t i=0; i/span>nchannels; i++) 
 
{
 uint16_t v 
= hal.rcin->read(i);
 hal
.uartE->printf("Channel: %d   Output: %d \n",i, v);
 
}

The above should send channel data and I should be able to read at the UART, right? But this doesn't do anything.

Alessandro, I have been studying the PX4 code and haven't made a lot of progress. Can you give me some detail on how you were able to send data through a UART.

It seems all the tutorials and info about accessing the serial ports have been taken down.

Thanks for any help you can provide!

Bill

I realize this is an old thread, but maybe someone can help me.  I'm also trying to download telemetry data directly from a Pix/Mavlink USB/Serial port and dump the data to a file.  I have this working with Mavproxy, but they delay and latency make it near useless.  This is on a Raspberry PI Zero w/ Debian Jessie.  I have compiled a couple C++ codes from examples, but I can't obtain the data I want.  Here is how it should work.

1.  Connect to PIX/Mavlink via /dev/ttyACM0 port.

2.  Download several pieces of telemetry data (GPS, Alt, Speed, Etc) and save them to a local file on the RPI

3.  Repeat, Repeat, Repeat...

Near real time speed is critical.  I could define the telemetry options either in the C++ source or pass them as parameters.

Any help would be GREATLY appreciated.

Thx,

Dave M

Reply to Discussion

RSS

© 2020   Created by Chris Anderson.   Powered by

Badges  |  Report an Issue  |  Terms of Service