本文主要是介绍基于 parallels ubuntu 20.04 LTS (focal) 的ros+px4+gazebo 安装,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
系统环境:
主机环境 | macos 14.2.1 (23C71)、M1芯片 |
Paralles | 商业版 19.1.0 (54729) |
ubuntu | ubuntu 20.04 LTS (focal) |
PX4 | v1.14.0 |
ROS2 | foxy |
虚拟机安装
1. 下载安装 parallels,参考评论;
2. 下载 ubuntu 镜像,使用 ubuntu 20.04 LTS (focal) arm 版本: ubuntu-20.04-live-server-arm64.isohttp://old-releases.ubuntu.com/releases/focal/ubuntu-20.04-live-server-arm64.iso
3. 利用 parallels 安装镜像,一路 continue,参考:Parallels Desktop 19 安装Ubuntu桌面版(m芯片arm架构) - 哔哩哔哩最近超想体验Ubuntu。没敢在真机上试,就现在虚拟机体验体验。由于我的mac是m架构的芯片,只能安装arm版的Ubuntu。目前我试了这三种方法,这里介绍我最后使用的方法,这是三种里面最复杂的一个。因为可以指定系统版本,操作复杂,我尽量详细一点,配上了截图,应该好理解。在Ubuntu官网(https://cn.ubuntu.com/)只找到 Ubuntu Server有arm版本,思路是可以先装server版本,然后再安装桌面环境。 给熟手的安装方法:1、下载arm版本的 Ubuntu Serhttps://www.bilibili.com/read/cv26559447/
# 更新源
sudo apt update
# 安装可视化桌面
sudo apt install ubuntu-desktop
4. 安装 Parallels Tools。
安装编译 PX4
1. 配置环境:
# 配置
# sudo dpkg --add-architecture amd64
sudo apt-get update
sudo apt-get upgradesudo apt-get install git
sudo apt-get install vim# 一定要升级 cmake
# CMake 3.22 or higher is required by Micro-XRCE-DDS-Agent
# 卸载原来的 cmake
sudo apt-get remove --purge cmake
hash -r
# 安装最新 cmake https://cmake.org/files/v3.22/cmake-3.22.0-linux-aarch64.sh
sudo bash cmake-3.22.0-linux-aarch64.sh --skip-license --exclude-subdir --prefix=/usr/local
2. 克隆源码:
# 下载 px4 源码
git clone https://github.com/PX4/PX4-Autopilot.git --recursivecd PX4-Autopilot/Tools/setup/
# delete the two lines (lines 125, 126) in ubuntu.sh
# g++-multilib \
# gcc-multilib \
vim ubuntu.sh
sudo apt-get install gcc-multilib-arm-linux-gnueabi gcc-multilib-arm-linux-gnueabihf g++-multilib-arm-linux-gnueabi g++-multilib-arm-linux-gnueabihf
bash ubuntu.sh# 报错:ubuntu.sh: line 129: gdb-multiarch: command not found
sudo apt-get install gdb-multiarch# 重启系统
3. 编译运行:
# 编译
make px4_sitl gazebo
# 起飞
commander takeoff
# make px4_sitl jmavsim
安装ROS2
参考 ROS 2 用户指南 | PX4 自动驾驶用户指南 (main)、Ubuntu (Debian) — ROS 2 Documentation: Galactic documentation
sudo apt update && sudo apt install locales
sudo locale-gen en_US en_US.UTF-8
sudo update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8
export LANG=en_US.UTF-8
sudo apt install software-properties-common
sudo add-apt-repository universe
sudo apt update && sudo apt install curl -y
sudo curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu $(. /etc/os-release && echo $UBUNTU_CODENAME) main" | sudo tee /etc/apt/sources.list.d/ros2.list > /dev/null
sudo apt update && sudo apt upgrade -y# 注意 :ubuntu 20.04 LTS (focal)不支持 px4 humble 版本,
# galactic 版本尝试后,连接不成功
# sudo apt install ros-humble-desktop
# sudo apt install ros-galactic-desktop
# sudo apt install ros-dev-tools
# source /opt/ros/galactic/setup.bash && echo "source /opt/ros/galactic/setup.bash" >> .bashrcsudo apt install ros-foxy-desktop python3-argcomplete
sudo apt install ros-dev-tools
source /opt/ros/foxy/setup.bash && echo "source /opt/ros/foxy/setup.bash" >
# 测试
ros2 run turtlesim turtlesim_node
ros2 run turtlesim turtle_teleop_key# Some Python dependencies must also be installed
pip install --user -U empy==3.3.4 pyros-genmsg setuptoolssudo apt install ros-foxy-desktop python3-argcomplete
sudo apt install ros-dev-tools
source /opt/ros/foxy/setup.bash && echo "source /opt/ros/foxy/setup.bash" >> .bashrc
安装 Micro XRCE-DDS Agent & Client
git clone https://github.com/eProsima/Micro-XRCE-DDS-Agent.git
cd Micro-XRCE-DDS-Agent
c
cmake ..
make# Error: CMake 3.22 or higher is required. You are running version 3.16.3
# 卸载原来的 cmake 安装最新 cmake,重新检查对 cmake 依赖的其他组件是否正常sudo make install
sudo ldconfig /usr/local/lib/# To start the agent with settings for connecting to the uXRCE-DDS client running on the simulator
MicroXRCEAgent udp4 -p 8888
Build ROS 2 Workspace
mkdir -p ws_sensor_combined/src/ && cd ws_sensor_combined/src/git clone https://github.com/PX4/px4_msgs.git
git clone https://github.com/PX4/px4_ros_com.gitrm -f px4_msgs/msg/*.msg
cp ../../PX4-Autopilot/msg/*.msg px4_msgs/msg/cd ..
colcon buildsource install/local_setup.bash
ros2 launch px4_ros_com sensor_combined_listener.launch.py
遇到问题
问题1:运行 “ros2 launch px4_ros_com sensor_combined_listener.launch.py“ 没数据。
原因1:galactic 版本的ROS2不适用,更换foxy版本。
报错“[sensor_combined_listener-1] 1704627439.467785 [0] sensor_com: selected interface "lo" is not multicast-capable: disabling multicast”,执行“ifconfig lo multicast”还是没数据。
export ROS_LOCALHOST_ONLY=1
printenv | grep -i ROSifconfig lo multicast
qgc 局域网中 MavLink 连接 px4
# 在 px4 命令行中执行
mavlink start -p -o 14550mavlink start -p -t 10.211.55.2 -o 14550# 远程 mavlink 连接
./Tools/mavlink_shell.py 192.168.4.2:14550
安装ROS1
# Setup your computer to accept software from packages.ros.org.
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 install curl # if you haven't already installed curl
curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | sudo apt-key add -
sudo apt-get update
sudo apt install ros-noetic-desktop-full# 配置环境,可选择 ros 版本
vim ~/.bashrc
# 插入 start
echo "ros noetic(1) or ros2 foxy(2)?"
read edition
if [ "$edition" -eq "1" ];thensource /opt/ros/noetic/setup.bash
elsesource /opt/ros/foxy/setup.bash
fi
# end# 更新
source ~/.bashrc
错误: RLException: Unable to contact my own server at [http://ubuntu-arm:45885/]. This usually means that the network is not configured properly.
解决:关闭vpn。
这篇关于基于 parallels ubuntu 20.04 LTS (focal) 的ros+px4+gazebo 安装的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!