I am trying to start the APMRover2.elf through rc.local, but for some reason it does not work.
/home/pi/./APMRover2.elf -A /dev/ttyUSB0 &
to the rc.local script before the “exit 0”
I am also starting raspivid with
raspivid -t 0 w- 1280 -h 720 &
and it works fine.
How do you guys start the APM elfs?
Another issue is the shutdown of the Raspberry Pi. I use a pushbutton connected to a GPIO pin to run a script, that does reboot or shutdown the Pi, but it always stops working after a while.
We’ve been able to autostart the APM by adding this in rc.local:
sudo /home/pi/APMrover2.elf -A udp:192.168.1.158:14500 > /home/pi/startup_log &
I haven’t tried it with USB radio. Maybe the problem is that there is no /dev/ttyUSB0 at the moment of running the APM? Could you please check the boot log?
What GPIO are you using for a button? It may be busy with another function.
Thanks Mikhail, problem solved.
I had to leave out the “./” before the APMrover2.elf and now it works.
With USB radio, too!
Now my rover is almost ready for its first outdoor test under navio control!
I decided against autostarting the APMrover2.elf, because the Raspberry Pi is very busy with it and does react very slow to user input through ssh for example.
Instead of autostarting, I took my arduino leonardo and connected it via usb to the Raspberry Pi. It acts as a keyboard, sending predefined strings to the Pi. I have three momentary buttons connected to it.
One for shutting down the Raspberry, one for starting and stopping the autopilot and the third to start or quit raspivid with different options. I plan to hook up one channel of my rc receiver to the leonardo, to switch functions from my TX.
I use a Taranis with a X8R receiver. Channels 1-8 go to the Navio via SBUS to CPPM converter and channels 9-16 are accessible through the PWM/Servo connectors on the receiver. This way, I overcome the 8 channel limitation of the CPPM input.
Sebastian, Arduino seems a bit of an overkill:) If SSH is slow you can try a couple of things to overcome this:
- Use more powerful WiFi adapter with external antenna
- Disable WiFi power management
- Raise SSH daemon priority using chrt or nice command.
I do not use WiFi with my rover. I use an ethernet cable for everything not related to APMrover setup. But even with the ethernet cable, the login to the Pi over ssh can take up to 20s, if the APMrover2.elf is running. Mavlink is transmitted through 3dr radios and video through a FPV transmitter.
In previous setups, I tried to control the rover completly through WiFi (onboard router), including video transmission, but the range with legal power settings was very poor.
Why do you think the arduino is overkill?
I think, it has a few advantages over other ways to control the Raspberry Pi.
With the arduino leonardo acting as a keyboard, I do not need to run/install anything additional on the Raspberry Pi, which would be necessary, if I connected the buttons to the gpio pins.
Without Wifi I have one rf device less, that would probably limit my radio control range.
If I manage to connect my rc receiver to the arduino and control the raspberry pi that way, I do not have to install mavproxy on the Pi, which also takes a good amount of cpu power.
Sebastian, ah, I haven’t thought about the 2.4GHz FPV system, then it’s reasonable.
I use 2.4GHz radio control and 5.8GHz FPV.
With WiFi, I was barely able to get 50m away before video dropped out and after about 80m control became dodgy. (It was a foggy day, but still)
With 5.8GHz 25mW, I drove 250m away until the rover got behind a ridge, then video was lost, but radio control was still working.
Sebastian, what FPV system are you using?
ImmersionRC 25mW (maximum in germany without a license) TX and DUO5800 v3 RX with SPW and circular patch antenna. The patch antenna is tracked with a ghettostation antenna tracker. Tracking is not really necessary for a rover, but nice for flying. It keeps the video crystal clear for the distances I am flying/driving.