———————————————————————————————————————————
1、PIXhawk或者Pixracer
2、一个已经安装好ubuntu mate16.04的树莓派3B
3、一根micro USB 数据线
———————————————————————————————————————————
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
sudo apt-key adv --keyserver hkp://ha.pool.sks-keyservers.net:80 --recv-key 421C365BD9FF1F717815A3895523BAEEB01FA116
有能力的可以单独安装所需的Ros包,这里只是为了方便学习,减少不必要的麻烦所以安装完整版。
sudo apt-get update
sudo apt-get install ros-kinetic-desktop-full
echo "source /opt/ros/kinetic/setup.bash" >> ~/.bashrc
source ~/.bashrc
sudo apt-get install python-rosinstall python-rosinstall-generator python-wstool build-essential
可以通过命令检查环境是否配置完成:printenv | grep ROS
sudo apt-get install ros-kinetic-rqt
sudo apt-get install ros-kinetic-rqt-common-plugins
mkdir -p ~/catkin_ws/src
cd ~/catkin_ws/
catkin_make
echo "source ~/catkin_ws/devel/setup.bash" >> ~/.bashrc
source ~/.bashrc
sudo apt-get install ros-kinetic-mavros ros-kinetic-mavros-extras
cd ~/catkin_ws/src
catkin_create_pkg px4_mavros std_msgs rospy roscpp
cd px4_mavros
vim package.xm
插入字段:
cd ~/catkin_ws
catkin_make
——————————————————————————————————————————
sudo vim /opt/ros/kinetic/share/mavros/launch/px4.launch
更改串口波特率:/ dev / ttyACM0:921600
执行完此操作之后需要从新登录才能使得更改生效。
sudo usermod -a -G dialout $USER
环境搭建完毕之后如果想测试一下ROS是否能够和PIX飞控正常通信可以使用下面指令。
roslaunch mavros px4.launch
如果出现一下错误:
[FATAL] [1516873473.284961896]: UAS: GeographicLib exception: File not readable /usr/share/GeographicLib/geoids/egm96-5.pgm | Run install_geographiclib_dataset.sh script in order to install Geoid Model dataset!
================================================================
REQUIRED process [mavros-2] has died!
process has finished cleanly
log file: /home/rainbow/.ros/log/56ca2eb6-01b4-11e8-b939-000c29d97950/mavros-2*.log
Initiating shutdown!
================================================================
解决方法:
sudo /opt/ros/kinetic/lib/mavros/install_geographiclib_datasets.sh
rostopic list
可以看到有许多消息。
我们尝试监听一个消息(拿imu数据来说):
rostopic echo /mavros/imu/data
可以看到IMU传感器实时数据:
———————————————————END—————————————————————
参考文章:
https://dev.px4.io/en/
https://www.cnblogs.com/liu-fa/p/5779206.html
http://blog.csdn.net/abc869788668/article/details/78323395?locationNum=8&fps=1