准备工作(安装ros)
启动前更新一下自己的apt
1 2
| sudo apt-get update sudo apt-get upgrade
|
安装ros
使用Ubuntu操作系统对应的ros版本如下:
Ubuntu |
ROS 1.0 |
ROS 2.0 |
16.04 LTS |
Kinetic LTS |
Ardent |
18.04 LTS |
Melodic LTS |
Dashing LTS |
20.04 LTS |
Noetic LTS |
Foxy LTS |
查看自己现在Ubuntu的版本
换源
一般对系统源也就是位于etc/apt/source。list里面的进行换源
查看和更改源的命令
1
| sudo vim /etc/apt/sources.list
|
此外还有对python安装的换源
pip永久换源(清华源)
1
| pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
|
手动安装
参考ros官方文档
脚本安装
还可以自己书写脚本安装(orange pi 5 plus写的为示例)
直接使用命令
1 2 3 4 5
| install_ros.sh ros1
test_ros.sh
|
测试的脚本(位置还是在/usr/local/bin下)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
| #!/bin/bash
if [[ -f /opt/ros/noetic/setup.bash ]]; then
source /opt/ros/noetic/setup.bash roscore &
sleep 5
rosrun turtlesim turtlesim_node & rosrun turtlesim turtle_teleop_key
fi
if [[ -f /opt/ros/galactic/setup.bash ]]; then
source /opt/ros/galactic/setup.bash ros2 run demo_nodes_cpp talker & ros2 run demo_nodes_py listener
fi
if [[ -f /opt/ros/humble/setup.bash ]]; then
source /opt/ros/humble/setup.bash ros2 run demo_nodes_cpp talker & ros2 run demo_nodes_py listener
fi
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
| #!/bin/bash
mirror_url=https://repo.huaweicloud.com
if [[ -n $1 && $1 =~ ros1|ros2 ]]; then version=$1 else echo "usage: install_ros.sh ros1/ros2" exit fi
release=$(lsb_release -cs)
if [[ $version == "ros1" && $release =~ focal ]]; then
[[ -f /etc/apt/sources.list.d/ros-latest.list ]] && sudo rm /etc/apt/sources.list.d/ros-latest.list sudo sh -c "echo deb ${mirror_url}/ros/ubuntu $(lsb_release -sc) main > /etc/apt/sources.list.d/ros1.list" sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654 sudo apt update sudo apt install -y ros-noetic-desktop-full
sudo sh -c 'echo "source /opt/ros/noetic/setup.bash" >> /root/.bashrc' echo "source /opt/ros/noetic/setup.bash" >> /home/orangepi/.bashrc
sudo apt install -y python3-rosdep python3-rosinstall python3-rosinstall-generator python3-wstool build-essential
sudo sh -c 'echo "151.101.84.133 raw.githubusercontent.com" >> /etc/hosts' source /opt/ros/noetic/setup.bash sudo rosdep init rosdep update
exit fi
if [[ $version == "ros2" && $release =~ focal ]]; then
sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654 echo "deb [arch=$(dpkg --print-architecture)] ${mirror_url}/ros2/ubuntu $(source /etc/os-release && echo $UBUNTU_CODENAME) main" | sudo tee /etc/apt/sources.list.d/ros2.list
sudo apt update sudo apt install -y ros-galactic-desktop sudo apt install -y ros-dev-tools
sudo sh -c 'echo "source /opt/ros/galactic/setup.bash" >> /root/.bashrc' echo "source /opt/ros/galactic/setup.bash" >> /home/orangepi/.bashrc
source /opt/ros/galactic/setup.bash ros2 -h
exit
fi
if [[ $version == "ros2" && $release =~ jammy ]]; then
sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654 echo "deb [arch=$(dpkg --print-architecture)] ${mirror_url}/ros2/ubuntu $(source /etc/os-release && echo $UBUNTU_CODENAME) main" | sudo tee /etc/apt/sources.list.d/ros2.list
sudo apt update sudo apt install -y ros-humble-desktop sudo apt install -y ros-dev-tools
sudo sh -c 'echo "source /opt/ros/humble/setup.bash" >> /root/.bashrc' echo "source /opt/ros/humble/setup.bash" >> /home/orangepi/.bashrc
source /opt/ros/humble/setup.bash ros2 -h
exit
fi
echo "Unsupported System!"
|
安装realsense2_camera
realsense2_camera 可作为 ROS 发行版的 debian 软件包使用
1
| sudo apt-get install ros-$ROS_DISTRO-realsense2-camera
|
安装mavros
参考acfly_mavros官方readme写的安装步骤
官方地址:https://github.com/LauZanMo/acfly-mavros
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
| sudo apt-get install python-catkin-tools python-rosinstall-generator -y
source /opt/ros/${你的ROS版本}/setup.bash
sudo apt purge ros-${ROS_DISTRO}-mavlink ros-${ROS_DISTRO}-mavros
mkdir -p ~/acfly_ws/src && cd ~/acfly_ws catkin init
cd src git clone -b release/${ROS_DISTRO}/mavlink/2022.1.5-1 https://gitee.com/LauZanMo/mavlink git clone -b acfly-develop https://gitee.com/LauZanMo/acfly-mavros
cd .. && rosdep install --from-paths src --ignore-src -y
./src/acfly-mavros/mavros/scripts/install_geographiclib_datasets.sh
./src/acfly-mavros/update_custom_msg.sh
source devel/setup.bash
|
安装可能遇到的问题
1、 gitclone出问题:
解决办法:让板子使用自己的电脑本地的梯子。
具体操作:
1 2 3 4
| export http_proxy=http://192.168.1.25:7890 export https_proxy=http://192.168.1.25:7890
|
2、安装GeographicLib出问题:
很毒!很毒!很毒!
挂梯子也无法解决,一般看脸决定能不能下载下来。
这边提前帮忙下载好的配置文件保留下来
下载地址:
将下载完的GeographicLib文件整个直接放到/usr/share/下
将下载完的GeographicLib文件整个直接放到/usr/share/下
将下载完的GeographicLib文件整个直接放到/usr/share/下
1 2
| sudo mv ./GeographicLib /usr/share
|
安装T265和坐标转换的工具包
1 2 3 4 5 6 7 8 9
| cd ~/acfly_ws/src
git clone https://github.com/thien94/vision_to_mavros.git
git clone https://github.com/IntelRealSense/librealsense.git
cd ~/acfly_ws && catkin build
|
使用说明
1 2 3 4 5 6 7 8 9 10 11 12
|
roslaunch realsense2_camera rs_t265.launch
roslaunch mavros acfly.launch fcu_url:=/dev/ttyS3:57600
source devel/setup.bash roslaunch vision_to_mavros t265_tf_to_mavros.launch
|
补充说明:要使用orangepi5plus的ttyS*口的话,需要打开对应的串口,可以理解为gpio初始化
能够使用的串口及引脚号
UART 总线 |
RX 对应 40pin |
TX 对应 40pin |
dtbo 对应配置 |
UART1_M1 |
27 号引脚 |
28 号引脚 |
uart1-m1 |
UART3_M1 |
18 号引脚 |
16 号引脚 |
uart3-m1 |
UART4_M2 |
19 号引脚 |
23 号引脚 |
uart4-m2 |
UART6_M1 |
10 号引脚 |
8 号引脚 |
uart6-m1 |
UART7_M2 |
24 号引脚 |
26 号引脚 |
uart7-m2 |
UART8_M1 |
40 号引脚 |
35 号引脚 |
uart8-m1 |
具体操作步骤:
1 2 3 4 5 6 7 8 9 10 11 12
| sudo orangepi-config
ls /dev/ttyS*
|
第三个终端中的source可以写入~/.bashrc优化掉
具体操作:
1 2 3 4
| sudo vim source ~/.bashrc
source /home/orangepi/acfly_ws/devel/setup.bash
|
自启动
基于ubuntu自带的session and startup软件启动
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
|
LOG_DIR=/home/orangepi/logs/my_startup_scripts LOG_FILE=$LOG_DIR/startup.log
mkdir -p $LOG_DIR touch $LOG_FILE
echo "$(date) - Script started" >> $LOG_FILE
echo "$(date) - Loading ROS environment variables" >> $LOG_FILE source /opt/ros/noetic/setup.bash source /home/orangepi/acfly_ws/devel/setup.bash
echo "$(date) - Starting realsense2_camera" >> $LOG_FILE (sleep 10; roslaunch realsense2_camera rs_t265.launch >> $LOG_FILE 2>&1) & echo "$(date) - Started realsense2_camera" >> $LOG_FILE
echo "$(date) - Starting mavros" >> $LOG_FILE (sleep 15; roslaunch mavros acfly.launch >> $LOG_FILE 2>&1) & echo "$(date) - Started mavros" >> $LOG_FILE
echo "$(date) - Starting vision_to_mavros" >> $LOG_FILE (sleep 20; roslaunch vision_to_mavros t265_tf_to_mavros.launch >> $LOG_FILE 2>&1) & echo "$(date) - Started vision_to_mavros" >> $LOG_FILE
echo "$(date) - Starting Python script" >> $LOG_FILE (sleep 25; python3 /home/orangepi/acfly_ws/src/cv_for_orangepi/Cv_mode.py >> $LOG_FILE 2>&1) & echo "$(date) - Started Python script" >> $LOG_FILE
|