I just install APM on RPI 2 following this tutorial and get MissionPlanner connected. Everything works fine except the “Autostarting APM on boot” does not work.I have to login in through SSH and start APM manually.
“#!/bin/sh -e
”#
"# rc.local
"#
"# This script is executed at the end of each multiuser runlevel.
"# Make sure that the script will “exit 0” on success or any other
"# value on error.
"#
"# In order to enable or disable this script just change the execution
"# bits.
"#
"# By default this script does nothing.
"# Print the IP address
_IP=$(hostname -I) || true
if [ “$_IP” ]; then
printf “My IP address is %s\n” "$_IP"
fi
sudo ArduCopter-quad -A udp:192.168.11.2:14550 -C /dev/ttyAMA0
I’m experiencing the same problem as described above. I’m an absolute newb to raspi, but I do know my way around APM. When I modify my rc.local file into what you are suggesting, I have no luck. I am still presented with a logon screen and when I log on, no APM is started.
I am making the modifications to rc.local directly on the raspberry pi 2.
I noticed that the Navio+ guide is suggesting a bit different code from what you have. The bold part below.
Is there any reason why you omitted this bit of code?
sudo ArduCopter-quad -A udp:192.168.1.2:14550 -C /dev/ttyAMA0 > /home/pi/startup_log &
I am expecting not to have to log in to the raspi anymore, when this is working properly. Is that the case? Or will I still have to login every time I power up the board?
The > /home/pi/startup_log will log the output from APM into startup_log file. Could be convenient if you have an issue.
The & will run the program the background.
Try to paste this line of code directly into PI shell after you have logged in. Does the APM start?
sudo ArduCopter-quad -A udp:192.168.1.2:14550 -C /dev/ttyAMA0 > /home/pi/startup_log &
I will attempt to add this line back into rc.local
Do I still have to logon with un/pw? Will the rc.local scripts only be executed after the password is entered?
Below is what my rc.local looks like. It does not startup APM.
Any thoughts?
GNU nano 2.2.6 File: /etc/rc.local
“#!/bin/sh -e
”#
"# rc.local
"#
"# This script is executed at the end of each multiuser runlevel.
"# Make sure that the script will “exit 0” on success or any other
"# value on error.
"#
"# In order to enable or disable this script just change the execution
"# bits.
"#
"# By default this script does nothing.
"# Print the IP address
_IP=$(hostname -I) || true
if [ “$_IP” ]; then
printf “My IP address is %s\n” "$_IP"
fi
sudo ArduCopter-hexa -A udp:192.168.0.103:14550 -C /dev/ttyAMA0 > /home/pi/startup_log &
"#sudo ArduCopter-hexa -A udp:192.168.0.103:14550 -C /dev/ttyAMA0
I had to add a pause above the arducopter line for it to work. Guess it needs to wait until the network is up. You have to experiment with the pause time. My line is as follows:
sleep 25
Thank you. That doesn’t seem to work either. I am also confused about the logon procedure. Does this script bypass the need for logging in to the Raspberry Pi?
Currently APM will not start with option that includes network connection (udp, tcp) if there is no network connection. It is a bug that required a large rework of APM, already made by @george.staroselskiy and it is now being merged in master. We hope that it will make in the next stable release.
For now, you will have to have a network connection ( e.g. Wi-Fi ) when you turn the board on, alternatively you can use only serial connection. Does it work for you with serial only?
I also experinced the problem that the ardupilot software did not start up when not having a valid route to it’s destination host.
When my copter starts before the groundstation (which also includes the wlan ap) is up this is a common problem. I solved it by creating a startup script like this (/home/pi/startapm.sh)
#!/bin/bash
while /bin/true; do
/home/pi/arducopter.elf -A udp:10.1.0.1
done
This just always retries to launch APM until it runs successfully. It’s not very elegant but it works ;-).
After creating the file I gave it run permissions
It would be a good idea to launch socat and APM as backgroud processed, i.e. adding & at the end of the line and logging the output somewhere to be able to deduce your problem.
I made the changes as you recommended and now erverything works fine (APM starts from boot).
Though I’m a little bit confused as I thought I’ve tried the & at the end of the lines with no success before!??? But OK. Thanks again.
The log files excisting but seam to be empty. Nano replies “read 0 lines” when I open the files. Is that because there is no error? I suspected at least the stdout to write something in the log files? But I’m a newbie in Raspberry Pi and wondering about nothing
By the way:
there was a typo in your code. It has to be echo, not acho; just for those who wants to copy and paste the code
Yeah, you are right about the logging part. I got them wrong, sorry! Now I’ve updated them accordingly. I suggest you make the change to the rc.local as well.