Airsim动态 | 安装ROS包装器(AirSim ROS Wrapper)

file 本期内容我们将带来在Airsim环境下使用ROS Wrapper的相关教程,以下是AirSim客户端库上的一些ROS Wrapper相关配置。

一、启动

以下步骤适用于 Linux 系统。如果是在 Windows 上运行 AirSim,可以使用 Windows Subsystem for Linux (WSL) 来运行 ROS 包装器,如果不想在主机上安装ROS相关工具,也可以使用Docker容器进行安装。请检查下方内容并按照需求安装,具体内容可以参照最后网址。

如果您的默认 GCC 版本不是8或更高版本(检查使用命令gcc --version)

a) 安装 gcc >= 8.0.0:sudo apt-get install gcc-8 g++-8 b) 验证安装 gcc-8 --version

如果是Ubuntu 18.04版本 a) 安装ROS melodic版本 b) 安装 tf2 传感器和 mavros 包: sudo apt-get install ros-kinetic-tf2-sensor-msgs ros-kinetic-tf2-geometry-msgs ros-kinetic-mavros*

如果是Ubuntu 16.04版本 a) 安装ROS Kinetic版本 b)安装 tf2 传感器和 mavros 包: sudo apt-get install ros-melodic-tf2-sensor-msgs ros-melodic-tf2-geometry-msgs ros-melodic-mavros*

如果是Ubuntu 20.04版本 a) 安装ROS noetic版本 b) 安装 tf2 传感器和 mavros 包: sudo apt-get install ros-melodic-tf2-sensor-msgs ros-melodic-tf2-geometry-msgs ros-melodic-mavros*

安装catkin_tools: sudo apt-get install python-catkin-tools 或pip install catkin_tools. 如果使用的Ubuntu是20.04版本,请使用以下安装命令: pip install "git+https://github.com/catkin/catkin_tools.git#egg=catkin_tools"

网址推荐: 1.WSL在Win10上构建环境: https://microsoft.github.io/AirSim/airsim_ros_pkgs/#setting-up-the-build-environment-on-windows10-using-wsl1-or-wsl2

2.使用Docker: https://microsoft.github.io/AirSim/airsim_ros_pkgs/#using-docker-for-ros

二、构建环境

构建AirSim: git clone https://github.com/Microsoft/AirSim.git; cd AirSim; ./setup.sh; ./build.sh; 确定已按照上述界面安装好并为ROS 设置了环境变量。方便起见,将“source”命令添加到自己的【.bashrc】上(替换melodic为特定版本名称)。 echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc source ~/.bashrc

构建ROS包 cd ros; catkin build; # or catkin_make

请注意,如果自己默认GCC版本不是8以上的版本,则会导致编译失败,在这种情况下,可以使用【gcc-8】明确这一点: catkin build -DCMAKE_C_COMPILER=gcc-8 -DCMAKE_CXX_COMPILER=g++-8

三、运行 source devel/setup.bash; roslaunch airsim_ros_pkgs airsim_node.launch; roslaunch airsim_ros_pkgs rviz.launch; 注意:如果运行时出现错误:

注意:如果运行时出现错误: roslaunch airsim_ros_pkgs airsim_node.launch 则可以使用命令catkin clean清除并重新运行。

四、使用AirSim ROS wrapper功能包 ROS wrapper由两个 ROS 节点组成——第一个是 AirSim 的多旋翼C++ 客户端库的包装器,第二个是一个简单的 PD 位置控制器。

关于订阅和发布节点,参数与service可以参考网址: https://microsoft.github.io/AirSim/airsim_ros_pkgs/#airsim-ros-wrapper-node

PID位置控制器节点可以参考: https://microsoft.github.io/AirSim/airsim_ros_pkgs/#simple-pid-position-controller-node

  • End -

技术发展的日新月异,阿木实验室将紧跟技术的脚步,不断把机器人行业最新的技术和硬件推荐给大家。看到经过我们培训的学员在技术上突飞猛进,是我们培训最大的价值。如果你在机器人行业,就请关注我们的公众号,我们将持续发布机器人行业最有价值的信息和技术。 阿木实验室致力于前沿IT科技的教育和智能装备,让机器人研发更高效!

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
Apriltag is a popular library for detecting and identifying visual fiducial markers called tags. The `apriltag_ros` package is a ROS wrapper for the Apriltag library, allowing you to use Apriltag functionalities within a ROS environment. It provides ROS nodes that can subscribe to image topics, detect Apriltags in the images, and publish the detected tag poses. To use `apriltag_ros` in Python, you can follow these steps: 1. Install the `apriltag_ros` package: ```bash sudo apt-get install ros-<distro>-apriltag-ros ``` Replace `<distro>` with your ROS distribution (e.g., melodic, noetic). 2. Create a ROS package (if you haven't already) where you'll write your Python code: ```bash cd ~/catkin_ws/src catkin_create_pkg my_apriltag_pkg rospy apriltag_ros ``` Replace `my_apriltag_pkg` with your desired package name. 3. In your Python script, import the necessary modules: ```python #!/usr/bin/env python import rospy from sensor_msgs.msg import Image from cv_bridge import CvBridge from apriltag_ros.msg import AprilTagDetectionArray ``` 4. Initialize the ROS node and create a subscriber to the image topic: ```python rospy.init_node('apriltag_detector') bridge = CvBridge() def image_callback(msg): cv_image = bridge.imgmsg_to_cv2(msg, desired_encoding='passthrough') # Perform Apriltag detection using cv_image image_sub = rospy.Subscriber('/camera/image_raw', Image, image_callback) ``` Replace `/camera/image_raw` with the appropriate image topic for your setup. 5. Process the received image in the callback function and publish the detected tag poses: ```python def image_callback(msg): cv_image = bridge.imgmsg_to_cv2(msg, desired_encoding='passthrough') # Perform Apriltag detection using cv_image # Publish the detected tag poses detection_array = AprilTagDetectionArray() # Populate detection_array with detected tag poses pub = rospy.Publisher('/apriltag/detections', AprilTagDetectionArray, queue_size=10) pub.publish(detection_array) ``` Replace `/apriltag/detections` with the desired topic to publish the detected tag poses. 6. Finally, run your ROS node: ```bash rosrun my_apriltag_pkg my_apriltag_node.py ``` Remember to replace `my_apriltag_pkg` and `my_apriltag_node.py` with your actual package and node names. This is a basic example to get you started with `apriltag_ros` in Python. You can find more information about the package and its functionalities in the official ROS documentation and the `apriltag_ros` GitHub repository.

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值