LibrePilot Forum

Users => Applications - Autonomous Flight => Topic started by: yconst on June 02, 2016, 12:21:24 am

Title: cc3d telemetry to raspberry to wifi to gcs
Post by: yconst on June 02, 2016, 12:21:24 am
Hello all, first post here.

I have a quad with a cc3d and a raspberry pi 2 onboard. I wish to configure the raspberry to act as a telemetry proxy for cc3d (connected via serial), so that I can receive telemetry via wifi on the ground station running on a laptop.

I think I can figure out the serial communication between the cc3d and the pi. But I am at a loss as to how to go about for setting up the pi as a telemetry proxy via wifi.

I understand that the ground station has an option to connect via udp, but I was unable to find any more information on it.

Does anybody have any experience with a similar setup? Can anyone provide some information on how to proceed?
Please note that the telemetry connection I wish to establish is not using an oplink modem, but a combination of serial and wifi.

Thanks a lot.
Title: Re: cc3d telemetry to raspberry to wifi to gcs
Post by: yconst on June 05, 2016, 09:06:51 am
Quick update here: I started my attempt at this by trying to directly forward the serial port communication to wifi, by using a utility called ser2net. The configuration options I am using are as follows (according to the format specified by the utility):

192.168.1.42,54444:raw:0:/dev/ttyACM0:57600 8DATABITS NONE 1STOPBIT NOBREAK

The data rate has been configured in the GCS as well to be the same.

The connection is picked up by the GCS when I click connect, and the RX/TX indicators are momentarily active at full. However, right after that there is no RX activity at all, the GCS shows a "Log Replay" indication, and almost all controls are disabled, as if disconnected. Furthermore, at the pi side, I get the following log message from ser2net:

ser2net[966]: Could not turn off break for device /dev/ttyACM0 port 192.168.1.42,54444: Broken pipe

By the way, I should mention that I am using a USB connection, with the USB Telemetry option of GCS.

Any ideas?
Title: Re: cc3d telemetry to raspberry to wifi to gcs
Post by: Mateusz on June 05, 2016, 04:31:35 pm
Just a short note. My HD cam using WiFi used to trigger failsafe on my frsky receiver. Lots of crashes before I figured out why. Frsky and many radio systems use 2.4G same as WiFi which can be 2.4/5.8. For vtx not an issue for control it may cause troubles.
Title: Re: cc3d telemetry to raspberry to wifi to gcs
Post by: Vixiom on July 05, 2016, 08:39:12 pm
I think I can figure out the serial communication between the cc3d and the pi.

Hi,

I tried to perform the same (rpi and cc3d serial link) with librepilot 15.09 and I cant have it working.

I tried by different ways, at the end I tried directly to connect my cc3d with an FTDI Usb adapter : dont work and I have exactly the same symptom : momentarily active at full, right after that there is no RX activity at all, then the GCS shows a "Log Replay" indication...

Serial link was working with cleanflight software so it's not an hardware/wiring issue.

I try with windows computer too, and nothing is coming on my FTDI.

With LP I try Flex port and main port, and modify CC Hardware Configuration in GCS accordingly (when connected to the functionnal USB to have change saved) then reboot and dont work (with usb disconnected as LibrePilot seem to only enable usb if this is connected).

Does the serial link is working on CC3D with serial peripheral other than a oplink modem ?
Title: Re: cc3d telemetry to raspberry to wifi to gcs
Post by: TheOtherCliff on July 06, 2016, 12:11:05 am
I think there are many people who send serial telemetry from CC3D to OSD board.

I personally have set up serial telemetry from Revo to APM telemetry boards for a test.
Title: Re: cc3d telemetry to raspberry to wifi to gcs
Post by: Vixiom on July 06, 2016, 06:24:59 pm
Ok, thank you I will go back here if I found usefull information
Title: Re: cc3d telemetry to raspberry to wifi to gcs
Post by: Vixiom on July 07, 2016, 01:11:29 am
TheOtherCliff, you're great !!

I was thinking my need was like the Setup a bluetooth for telemetry, but I understood I was wrong since you say me about MinOPOSD, then I use this information:
https://librepilot.atlassian.net/wiki/display/LPDOC/MinOPOSD+setup

It's working fine now !

Thank you
Title: Re: cc3d telemetry to raspberry to wifi to gcs
Post by: yconst on July 09, 2016, 11:00:32 am
Hi all,

Thanks for all your replies. Unfortunately the problem still persists as described above.

Theothercliff, I am wondering if there is a way to simply test the serial connection using something like minicom. Does the cc3d answer to standard serial commands?

Also, is it possible for anyone who got serial working to share their complete serial port settings (rate/data bits/stop bits/parity etc)?
Title: Re: cc3d telemetry to raspberry to wifi to gcs
Post by: Vixiom on July 11, 2016, 08:37:46 pm
Hi,

As described in previous post I did a lot of tries before having a working system.

Maybe it should be good to create a wiki for serial link between CC3D and LibrePilot GCS, I'm volunteer to perform this task but I don't know how to do / which person to contact ?

My working serial configuration was :

CC3D with Tx, Rx and ground connected to FTDI
FTDI connected by Usb to my windows 7 computer,

And LibrePilot software was able to have usefull information (without becoming log review...).

Software config was like : https://librepilot.atlassian.net/wiki/display/LPDOC/MinOPOSD+setup

For baudrate I set 57600 (I found on another post on this forum that is hardcoded and cant be changed right now but it may be changed on future release, correct me if I'm wrong) for :
 - CC3D (please use usb cable to set it before, then change baudrates and save it, then unplug usb cable and power cycle your cc3d)
 - FTDI port com on my windows computer
 - Librepilot settings (on librepilot settings on top of software windows) then apply and close/open librepilot (maybe not usefull but...)

I dont remember about data bits/stop bits/parity but I try with default's one and it was good.

Hoping it help you !




Title: Re: cc3d telemetry to raspberry to wifi to gcs
Post by: yconst on July 16, 2016, 11:06:48 pm
Hi,

Thanks for your reply.

Were you able to establish a connection between a Raspberry and the CC3D?
I can imagine that using a COM port on a PC with the GCS available should be straightforward. However, on a Raspberry (where GCS is not available), there must be a different strategy I suppose.

So far, my attempts at forwarding the (USB) com port to TCP with ser2net have failed. I have tried many different options but to no avail. I suspect that the culprit lies in the serial communication between the PI and the CC3D. I will also try with different utilities and report.

If anyone has successfully succeeded at even a rudimentary attempt at communicating, either using Telemetry port or USB telemetry, it'd be great to chime in.
Title: Re: cc3d telemetry to raspberry to wifi to gcs
Post by: yconst on July 16, 2016, 11:38:40 pm
Ok so I've tried some diagnostics on the port and it seems that the CC3D is recognised as so (1st attachment).
A reminder that this is a serial connection over USB using the RPi

Also, the baud rate of the device is reported at 9600, which seems a bit strange (too low) (attachment 2)
Title: Re: cc3d telemetry to raspberry to wifi to gcs
Post by: Vixiom on July 20, 2016, 03:38:45 pm
I didn't try yet with a raspberry pi, I will do it when I receive my rpi0 which will handle the camera too, my goal is to connect through wifi with vpn on my android.

Once camera work I will try to add gcs (I dont have any idea how to compile that ?..) with serial telemetry.
Title: Re: cc3d telemetry to raspberry to wifi to gcs
Post by: yconst on July 26, 2016, 11:12:47 pm
Great, looking forward to your results as well! It's a no-go so far for me unfortunately.

Meanwhile, for FPV you may want to take a look at this, if you haven't already:
https://befinitiv.wordpress.com/wifibroadcast-analog-like-transmission-of-live-video-data/

As far as I know compiling GCS for RPi is not possible.. (please correct me if wrong). That is the principal reason why I wanted to forward telemetry via WiFi.
Title: Re: cc3d telemetry to raspberry to wifi to gcs
Post by: Vixiom on July 27, 2016, 09:46:46 pm
Thank you for the link, I already see it before, it look great !

But as I want to be able to have the lightest on-field equipment, and dont bring laptop, raspberry with screen, usb batterie... I don't know if I will use it because it seem to need one raspberry pi to receive video too.

My main goal is to know what the copter is recording, if I'm able to perform it with my android it will be enough.

Anyway I will post future working solution, there's a lot of thing to do !
Title: Re: cc3d telemetry to raspberry to wifi to gcs
Post by: ryzhiy on July 28, 2016, 11:15:35 am
hi, have you tried doing the inverse, controlling CC3D with RPi?
Title: Re: cc3d telemetry to raspberry to wifi to gcs
Post by: Vixiom on July 28, 2016, 02:57:44 pm
hi, have you tried doing the inverse, controlling CC3D with RPi?


I'm not sure about the question ?

You want to have the rpi controlling CC3D for copter movement or for telemetry ? Anyway for both, I didn't do it (may be in the future  :P ).
Title: Re: cc3d telemetry to raspberry to wifi to gcs
Post by: sonium on August 02, 2016, 11:46:38 am
Thank you for the link, I already see it before, it look great !

But as I want to be able to have the lightest on-field equipment, and dont bring laptop, raspberry with screen, usb batterie... I don't know if I will use it because it seem to need one raspberry pi to receive video too.

My main goal is to know what the copter is recording, if I'm able to perform it with my android it will be enough.

Anyway I will post future working solution, there's a lot of thing to do !

Just some comments because I had some similar ideas: I found the RPi good for recording/streaming video but too slow on the decoding/display side. I was able to use the faster GPU decoder, but found that it is not as fault-tolerant and therefore does a really crappy job with the wifi transmission.
Title: Re: cc3d telemetry to raspberry to wifi to gcs
Post by: Vixiom on August 02, 2016, 04:54:37 pm
Just some comments because I had some similar ideas: I found the RPi good for recording/streaming video but too slow on the decoding/display side. I was able to use the faster GPU decoder, but found that it is not as fault-tolerant and therefore does a really crappy job with the wifi transmission.

I did some try with an Rpi 3 and camera V1 then now with a rpi zero v1.2 and a V2 camera, for both it seem to work for recording.

But I notice for both some "scratch" on the video maybe due to the high resolution choosed, I will post on youtube my first try soon and perform other try with lower resolution/FPS.

Did you want to use it as FPV ?
Title: Re: cc3d telemetry to raspberry to wifi to gcs
Post by: sonium on August 03, 2016, 10:06:41 am
Yes, FPV was the idea. I'm getting a latency of about 80ms with a 1296x730 resolution which doesn't make it competitive for racing, but hey - it looks nice.

I use the following pipeline for streaming and simultanous caputure:

raspivid -vf -hf -n --intra 5 --profile baseline -w 1296 -h 730 -b 4500000 -fps 49 -t 0 -o - | tee >(gst-launch-1.0 -v fdsrc !  h264parse ! rtph264pay config-interval=10 pt=96 ! udpsink host=192.168.1.11 port=5000) >(cat > capture.h264) > /dev/null

and display on Mac:
gst-launch-1.0  -v udpsrc port=5000 caps='application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264' ! rtph264depay ! avdec_h264 ! videoconvert! video/x-raw,width=800,height=480 ! glimagesink

I think the main part of latency comes from the encoder on the RPi which is not optimized for low latency.
Title: Re: cc3d telemetry to raspberry to wifi to gcs
Post by: Vixiom on August 03, 2016, 03:47:37 pm
I use the following pipeline for streaming and simultanous caputure:

raspivid -vf -hf -n --intra 5 --profile baseline -w 1296 -h 730 -b 4500000 -fps 49 -t 0 -o - | tee >(gst-launch-1.0 -v fdsrc !  h264parse ! rtph264pay config-interval=10 pt=96 ! udpsink host=192.168.1.11 port=5000) >(cat > capture.h264) > /dev/null

and display on Mac:
gst-launch-1.0  -v udpsrc port=5000 caps='application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264' ! rtph264depay ! avdec_h264 ! videoconvert! video/x-raw,width=800,height=480 ! glimagesink

Thank you I save it in my drone draft for future development  ;)

Did you send telemetry via this link too ? How many range you reach with this setup ?
Title: Re: cc3d telemetry to raspberry to wifi to gcs
Post by: sonium on August 03, 2016, 07:25:58 pm
I have not tested the range yet, but I'll keep the telemetry on the oplink radio connection which will have the larger range in any case.