树莓派2/3自动驾驶仪

    使用这个前期配置好的有效的PX4树莓派镜像。这个镜像默认最大化的事先配置了程序。

    访问设置

    此树莓派镜像已经事先设置好了SSH。用户名:pi 和密码:raspberry。你可以直接通过网络去连接你的树莓派2(以太网已经启动并且默认自动分配IP)和可以配置使用wifi。在这篇文档中,我们采取默认的用户名和密码登入树莓派系统。

    设置你的树莓派加入你的本地wifi网络(使你的树莓派连接你的wifi),关于如何设置请参考这篇
    指导文章。找到树莓派在你网络中的IP地址,随后你可以开始通过SSH的方式连接Pi2。

    Expand the Filesystem

    After installing the OS and connecting to it, make sure to ,so there is enough space on the SD Card.

    为了避免与同一网络上的其他树莓派有冲突,我们建议你改变默认主机名为明显的名字。我们使用px4autopilot作为我们的主机名。通过ssh连接pi并执行指令。

    编辑主机名文件:

    1. sudo nano /etc/hostname

    更改主机名 raspberry为你想要的任何主机名 (一个word字的有限字符)

    下一步更改主机host文件:

      更改入口 127.0.1.1 raspberry127.0.1.1 <YOURNEWHOSTNAME>
      做完这步重启电脑成功后允许他重新关联你的网络。

      Setting up Avahi (Zeroconf)

      1. sudo apt-get install avahi-daemon
      2. sudo insserv avahi-daemon

      接下来,设置Avahi配置文件

      把下面文字加入文件中:

      1. <?xml version="1.0" standalone='no'?>
      2. <!DOCTYPE service-group SYSTEM "avahi-service.dtd">
      3. <service-group>
      4. <name replace-wildcards="yes">%h</name>
      5. <service>
      6. <port>0</port>
      7. <txt-record>model=RackMac</txt-record>
      8. </service>
      9. <type>_ssh._tcp</type>
      10. <port>22</port>
      11. </service>
      12. </service-group>

      重新启动后台进程

      1. sudo /etc/init.d/avahi-daemon restart

      到此就结束了。你应该可以在同一网络上的任意一台电脑上通过树莓派的主机名访问你的树莓派。

      Configuring a SSH Public-Key

      为了允许PX4开发环境自动的更新可执行文件到你的开发板子上,你需要配置无密码访问RPi。我们使用公钥的验证方法。

      输入下面的命令来创建新的SSH密钥 (使用合理的主机名如 <YOURNANME>@<YOURDEVICE>. 在这我们使用 pi@px4autopilot)

      这些命令需要运行在主机开发电脑上!

      1. ssh-keygen -t rsa -C pi@px4autopilot

      执行上面这条命令,将会询问你这个密钥存在哪个位置。我们建议你直接回车让它存储在默认位置($HOME/.ssh/id_rsa)。

      现在你可以看到这些文件 和 id_rsa.pub 在你的 电脑主目录文件夹下的.ssh 文件夹里:

      id_rsa 文件是你的私人密钥. 让它保存在开发主机电脑上.
      id_rsa.pub 文件是你的公共密钥. This is what you put on the targets you want to connect to.

      把你的公共密钥复制到你的树莓派上,使用下面的命令来将你的公共密钥添加到树莓派上的密钥授权文件里。sending it over SSH:

      1. cat ~/.ssh/id_rsa.pub | ssh pi@px4autopilot 'cat >> .ssh/authorized_keys'

      现在尝试使用 ssh pi 连接时没有密码提示.

      如果你看到这条信息”Agent admitted failure to sign using the key.“ 然后加入你的RSA或者DSA认证身份到你的 ssh-agent(密钥管理器),并执行下面的命令:

      1. ssh-add

      如果它不工作, 使用 rm ~/.ssh/id*这条命令删除你的密钥,然后按照上面的操作重新再做一遍。

      我们使用SCP命令通过网络(wifi或者以太网)从开发主机传输文件到目标板。

      为了测试你的设置, 现在尝试通过网络从开发主机上推送到树莓派上。确保你的树莓派能正确访问网络,并且你可以使用ssh访问它。

      1. echo "Hello" > hello.txt
      2. scp hello.txt pi@px4autopilot:/home/pi/
      3. rm hello.txt

      这是拷贝一个”hello.txt”文件到你树莓派的家目录下(/home/pi)。
      确认这个文件是真的拷贝进去了,你就可以执行下一步了。

      本地构建 (可选)

      You can run PX4 builds directly on the Pi if you desire. This is the native build. The other option is to run builds on a development computer which cross-compiles for the Pi, and pushes the PX4 executable binary directly to the Pi. This is the cross-compiler build, and the recommended one for developers due to speed of deployment and ease of use.

      For cross-compiling setups, you can skip this step.

      The steps below will setup the build system on the Pi to that required by PX4. Run these commands on the Pi itself!

      Then clone the Firmware directly onto the Pi.

      Building the code

      Continue with our standard build system installation.