基于 parallels ubuntu 20.04 LTS (focal) 的ros+px4+gazebo 安装

news/2025/2/22 7:43:03

ubuntu-2004-lts-focal-的ros-px4-gazebo-安装">系统环境:

主机环境macos 14.2.1 (23C71)、M1芯片
Paralles商业版 19.1.0 (54729)
ubuntuubuntu 20.04 LTS (focal)
PX4v1.14.0
ROS2foxy

虚拟机安装 

1. 下载安装 parallels,参考评论;

2. 下载 ubuntu 镜像,使用 ubuntu 20.04 LTS (focal) arm 版本: ubuntu-20.04-live-server-arm64.isoicon-default.png?t=N7T8http://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 Sericon-default.png?t=N7T8https://www.bilibili.com/read/cv26559447/

# 更新源
sudo apt update
# 安装可视化桌面
sudo apt install ubuntu-desktop

4. 安装 Parallels Tools。

ubuntu-配置">安装编译 PX4

1. 配置环境: 

# 配置
# sudo dpkg --add-architecture amd64
sudo apt-get update
sudo apt-get upgrade

sudo 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 --recursive

cd 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" >> .bashrc

sudo 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 setuptools



sudo 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.git

rm -f px4_msgs/msg/*.msg
cp ../../PX4-Autopilot/msg/*.msg px4_msgs/msg/

cd ..
colcon build

source 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 ROS

ifconfig lo multicast

qgc 局域网中 MavLink 连接 px4

# 在 px4 命令行中执行
mavlink start -p -o 14550

mavlink 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" ];then
  source /opt/ros/noetic/setup.bash
else
  source /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。


http://www.niftyadmin.cn/n/5472752.html

相关文章

我的C++奇迹之旅:内联函数和auto关键推导和指针空值

文章目录 📝内联函数🌠 查看内联函数inline方式🌉内联函数特性🌉面试题 🌠auto关键字(C11)🌠 auto的使用细则🌉auto不能推导的场景 🌠基于范围的for循环(C11)🌠范围for的…

【芯片设计- RTL 数字逻辑设计入门 1.2 -- Verdi 原理图查看】

请阅读【芯片设计 RTL 数字逻辑设计扫盲 】 文章目录 Verdi 原理图查看显示原理图各信号名信号查找信号追踪 Verdi 原理图查看 这里以D触发器的RTL 实现为例来简单介绍如何在Verdi 中查看原理图,具体RTL code 如下: 可以按照下面步骤来查看原理图&…

react组件:strictmode

帮助你在开发过程中尽早地发现组件中的常见错误。 ** 严格模式启用了以下仅在开发环境下有效的行为: 组件将 重新渲染一次,以查找由于非纯渲染而引起的错误。 组件将 重新运行 Effect 一次,以查找由于缺少 Effect 清理而引起的错误。 组件将…

攻防世界 ezbypass-cat 题目解析

ezbypass-cat 一:题目: 二;解析 首先进入到界面查看源码和尝试弱口令都没发现线索,bp抓包分析,注意到 看到login.html突然想到有可能是权限绕过的问题,因为以login开头的登录界面一般是白名单&#xff0…

【LangChain学习之旅】—(16)检索增强生成:通过RAG助力大模型

【LangChain学习之旅】—(16)检索增强生成:通过RAG助力大模型 RAG 的工作原理文档加载文本转换文本分割器文本嵌入存储嵌入缓存存储向量数据库(向量存储)数据检索向量存储检索器各种类型的检索器索引总结什么是 RAG?其全称为 Retrieval-Augmented Generation,即检索增强…

9、鸿蒙学习-开发及引用静态共享包(API 9)

HAR(Harmony Archive)是静态共享包,可以包含代码、C库、资源和配置文件。通过HAR可以实现多个模块或多个工程共享ArkUI组件、资源等相关代码。HAR不同于HAP,不能独立安装运行在设备上,只能作为应用模块的依赖项被引用。…

fastjson list转json

1,内容是字符串 String json JSON. toJSONString(list); 结果:["111" ,“222”] 2,内容是时间 SerializeConfig config new SerializeConfig(); config. put(Date.class, new SimpleDateFormatSerializer("yyyy-MM-dd HH:mm:ss")); Strin…

Vue3:对ref、reactive的一个性能优化API

一、情景说明 我们知道,在Vue3中,想要创建响应式的变量,就要用到ref、reactive来包裹一下数据即可。 但是,这里有个损耗性能的地方 就是,被它包裹的数据,都会构建成响应式的,无论多少层次&…