Controlling Parrot drones using SkyController2

I did get rangefinder to work out-of-the box with arduplane-4.0.6 (built with libiio). Yet there are some other params missing required by Arduplane 4.0.x - need to work out these in order to get correct Disco params file.

I will get these out from my Disco and put them somewhere this week. Sorry I couldn’t do it earlier.

Thank you for reporting, I would be glad to contribute by updating docs or workflow. May you share your binary, just to compare

@lucasdemarchi Thank you ! I’m not sure about my system files at this time as I tested several things … For now, I know how to downgrade / upgrade parrot fw in Disco or SC2 but I notice they don’t seem to change these files in upgrade/downgrade

@lucasdemarchi - could you share a bit insight into SC2 dema-rc theory of operation? I could not find clear info on that - so I would like to check if I got it correctly:

  • dema-rc on SC2 basically translates joystick controller events into mavlink messages - that can be understood by arduplane FC
  • dema-rc on SC2 connects to Disco wifi SSID (by pausing mppd) and connects to Arduplane FC running on Disco
  • GCS (QGroundControl or Mission Planner) would connect via SC2 usb networking and connection will be masqueraded by SC2 iptables in order for GCS to reach Arduplane udp:14550 via SC2<->Disco wifi connection?

If all the above is correct - why there is a dema-rc connection target as 192.168.42.1:777 in default config:

Written here :
https://ardupilot.org/dev/docs/building-for-bebop-on-linux.html
It’s the RCout port

It seems that Lucas get inspiration from uavpal and disco4g mod, am I wrong ?

@mainframe

  • dema-rc translates the joystick controllers/buttons into its own format that is shared with ArduPilot, RCInput_UDP. dema-rc doesn’t actually know anything about mavlink
  • dema-rc connects to Disco wifi SSID and starts sending the input packets (connection-less since it’s via UDP)
  • To allow a GCS to reuse the same wifi link, dema-rc creates the iptables rules so the IP traffic in the ports used for mavlink is forwarded from the wlan interface to the usb interface. It does the same for video as well, that the drone sends via RTP.

@kikislater didn’ t have time to make it work with disco4g. It would be great if someone could adapt it. I have an idea how it works, and checked some of their startup scripts.

The protocol between dema-rc and ArduPilot comes from the pre-existent protocol (extended to allow more channels) for Bebop, that used a joystick controller by Julien Beraud, that used to work at Parrot. See https://github.com/jberaud/joystick_remote

In order to use all the buttons, you actually need a commit in ardupilot that is only in the master branch, not in a stable release. I will commit it to stable 4.0.x soon.

Here are the files that I use:

# cat /bin/onoffbutton/shortpress_3.sh
#!/bin/sh

prestart arduplane
# cat /etc/boxinit.d/50-arduplane.rc 
service arduplane /data/ftp/internal_000/ardupilot/usr/bin/start_arduplane.sh
    class main
    user root
    disabled
# cat /data/ftp/internal_000/ardupilot/usr/bin/start_arduplane.sh
#!/bin/sh

ulog_tag="arduplane"
source /usr/share/ulog/ulog_api.sh

ulogi "Stopping stock autopilot"
kk

media-ctl -l '"mt9f002 0-0010":0->"avicam.0":0[1]'
media-ctl -l '"avicam_dummy_dev.0":0->"avicam.0":0[0]'
pstop ledd-ng
prestart pimp
prestart dxowrapperd

# setup GPS
echo 1 > /sys/devices/platform/user_gpio/RESET_GNSS/value
/bin/sleep 1
echo 0 > /sys/devices/platform/user_gpio/RESET_GNSS/value

# listen to port 14550 so the GCS can connect
# and broadcast on the USB connection for convenience
exec env LD_LIBRARY_PATH=/data/ftp/internal_000/ardupilot/usr/lib \
        /data/ftp/internal_000/ardupilot/usr/bin/arduplane \
        -A udpin:0.0.0.0:14550 \
        -C udp:192.168.43.255:14551:bcast \
        -B /dev/ttyPA1

Thank you @lucasdemarchi for the explanation - all clear now :slight_smile:

If you want to start arduplane by default, you can simply remove the " disabled" from the boxinit.d file. Or do some replacements in /etc/init.d/rcS_mode_default

1 Like

@kikislater Im evaluating dema-rc to possibly make it work with disco4g-rpi - where instead of phone/tablet hotspot we use raspberry pi (pretending to be a parrot drone itself).

Wonderfull !
My shortpress_3.sh looks like that :

#!/bin/sh

ulog_tag="APM:Plane Disco"
source /usr/share/ulog/ulog_api.sh

/usr/bin/apm-plane-disco.sh prepare
if [ $? -eq 0 ] ; then
        ulogi "Stopping stock autopilot"
        kk
else
        ulogi "Keep Dragon alive"
        exit 0
fi

ulogi "Starting APM:Plane"
media-ctl -l '"mt9f002 0-0010":0->"avicam.0":0[1]'
media-ctl -l '"avicam_dummy_dev.0":0->"avicam.0":0[0]'
pstop ledd
prestart apm-plane-disco
prestart dxowrapperd
prestart pimp

I don’t have arduplane in boxinit but apm

cat /etc/boxinit.d/50-apm-plane-disco.rc

service apm-plane-disco /usr/bin/apm-plane-disco.sh -A udp:192.168.42.255:14550:bcast -B /dev/ttyPA1 -C udp:192.168.43.255:14550:bcast -l /data/ftp/internal_000/ardupilot/logs -t /data/ftp/internal_000/ardupilot/terrain
    class main
    user root
    disabled

I think we should need to update start_ardupilot.sh in official repo to update -A option. I can modify it or if someone want to do it let me know

If you have time please share content of :

That’s the final goal for me. I don’t rely on dragon autopilot as there is a lot of fly away or some crash we couldn’t understand reason … Main crash reason is due to cheap plastic servo, replacing them with emax 08 II metal gear prevent issue but there are others issue we don’t know.

Seems good !

Here are arduplane start options that Im using atm. For some reason bcast as a first option does not work in my case (could be that p2p vpn or its NAT setup somehow limits it). Yet it does work via broadcast after GCS has connected using udp:host:14550 as a first step (and can be disconnected afterwards - switching to broadcast).

cat 50-apm-plane-disco.rc

service apm-plane-disco /data/ftp/internal_000/disco4g-uav/bin/apm-plane-disco.sh -A 
udpin:192.168.42.1:14550 -B /dev/ttyPA1 -C udp:192.168.42.255:14550:bcast -l 
/data/ftp/internal_000/ardupilot/logs -t /data/ftp/internal_000/ardupilot/terrain
    class main
    user root
    disabled

Thanks, seems better for me as well.
So in your case what is the content of /data/ftp/internal_000/disco4g-uav/bin/apm-plane-disco.sh
Lucas shortpress_3.sh doesn’t work for me. Could you please share yours ?

Making a symlink in /usr/bin of arduplane with content of start_arduplane.sh from /data/ftp/internal_000/ardupilot/

ln -s /data/ftp/internal_000/ardupilot/start_arduplane.sh /usr/bin/arduplane

then modifying shorpress_3 (not he best, was better before, I’ll need to review it) :
cat /bin/onoffbutton/shortpress_3.sh

#!/bin/sh

#prestart arduplane
killall arduplane
kk
arduplane

So what is needed to set up in arduplane to make joystick works ?

I dont recall using custom shortpress_3.sh - wasn’t it included in Parrot firmware by default?
I can check later from the drone.

@kikislater make sure you have the right perms set for the files. ulogcat will tell you if boxinit refused to use it because of file permissions. Here are the right ones:

/ # ls -l /bin/onoffbutton/shortpress_3.sh 
-rwxr-xr-x    1 root     root            30 Jan  1  1970 /bin/onoffbutton/shortpress_3.sh
/ # ls -l /etc/boxinit.d/50-arduplane.rc 
-rw-r-----    1 root     root           120 Jan  1  1970 /etc/boxinit.d/50-arduplane.rc
/ # ls -l /data/ftp/internal_000/ardupilot/usr/bin/arduplane 
-rwxrwxrwx    1 root     root       2325040 May  8  2020 /data/ftp/internal_000/ardupilot/usr/bin/arduplane

I have to check but original is listed above in post 51, but it’s not working anymore … Provided by parrot.

It works now with last script in post 54.

@lucasdemarchi : I notice what you post here is not what you have put in documentation. I’m glad I understand linux but for others it will be like swimming in the sea … information differ from here and your doc : https://github.com/ArduPilot/dema-rc/blob/master/docs/install-ardupilot.md
You put files (arduplane and lib folder) in /data/ftp/internal_000/ardupilot/ in documentation whereas you have made some standardisation in this same folder here by putting arduplane in /data/ftp/internal_000/ardupilot/usr/bin/ and lib in /data/ftp/internal_000/ardupilot/usr/. Please keep it one way only : doc or here … It could be difficult to follow you !

Should RC by SC2 joystick suppose to works out of the box or need some arduplane modification ?

@kikislater in first @lucasdemarchi post there is this PR mentioned - that is probably required for dema-rc: https://github.com/ArduPilot/ardupilot/pull/13607

If I understand it correctly - this PR was merged on 3rd of May 2020 and hopefully is then part of latest Arduplane 4.0.6 release. Perhaps @lucasdemarchi can clarify this.