前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Webots和ROS2使用说明(部分翻译)

Webots和ROS2使用说明(部分翻译)

作者头像
zhangrelay
发布2019-09-18 15:17:37
1.5K0
发布2019-09-18 15:17:37
举报

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。

本文链接:https://cloud.tencent.com/developer/article/1508802

参考链接 Reference:

  1. 文档:http://wiki.ros.org/webots_ros2
  2. 源码:https://github.com/cyberbotics/webots_ros2

目前,已经测试过Crystal和Dashing这两个版本的ROS2,均可非常愉快的玩耍。

At present, the two versions of ROS2, Crystal and Dashing, have been tested and can be played very happily.


下载编译包:

Crystal:sudo apt install ros-crystal-webots-ros2

Dashing:只能源码编译。过程如下:

代码语言:javascript
复制
导入Dashing环境:
source /opt/ros/dashing/setup.bash

获取webots:
wget https://github.com/omichel/webots/releases/download/R2019b/webots-R2019b-x86-64.tar.bz2

解压:
tar xjf webots-R2019b-x86-64.tar.bz2

设置路径:
export WEBOTS_HOME=$PWD/webots

下载webots_ros2源码:
cd /path/to/catkin_ws/src
git clone -b $ROS_DISTRO https://github.com/cyberbotics/webots_ros2.git
cd /path/to/catkin_ws

更新rosdep,并安装需要的依赖:
rosdep update
rosdep install --from-paths src --ignore-src --rosdistro $ROS_DISTRO

编译:
colcon build

更新工作环境:
source /path/to/catkin_ws install/setup.bash
source /path/to/catkin_ws install/local_setup.bash

注意:control_msgs(在19年9月3日时,还不能使用apt install安装),需要源码编译。

将包从github下载,放置在src文件夹下:

src

使用colcon编译。

如果使用Windows环境,请参考wiki。

移动机器人示例:

启动:

代码语言:javascript
复制
ros2 launch webots_ros2_examples example.launch.py

webots

rqt:

rqt

用命令方式移动机器人或者显示传感器参数:

代码语言:javascript
复制
ros2 service call /motor webots_ros2_msgs/SetDifferentialWheelSpeed "{ left_speed: 1.0, right_speed: 0.5 }"
代码语言:javascript
复制
ros2 topic echo /sensor

给定左右轮相同速度,缓慢向前移动:

move

快接近边缘时候停止运动:

stop

传感器值感觉还是有问题的!

sensor

​​

工业机械臂示例:

单机械臂:

代码语言:javascript
复制
ros2 launch webots_ros2_universal_robot universal_robot.launch.py

universal_robot

universal_robot

双机械臂

代码语言:javascript
复制
ros2 launch webots_ros2_universal_robot universal_robot_multiple.launch.py

multi

移动机械臂:

代码语言:javascript
复制
ros2 action send_goal /follow_joint_trajectory control_msgs/action/FollowJointTrajectory "{
  trajectory: {
    joint_names: [shoulder_pan_joint, shoulder_lift_joint, elbow_joint, wrist_1_joint, wrist_2_joint, wrist_3_joint],
    points: [
      { positions: [3.02, -1.63, -1.88, 1.01, 1.51, 1.13], velocities: [0.1, 0.1, 0.1, 0.1, 0.1, 0.1], accelerations: [0.1, 0.1, 0.1, 0.1, 0.1, 0.1], time_from_start: { sec: 5, nanosec: 500 } },
      { positions: [-1.01, 0.38, -0.63, -0.88, 0.25, -1.63], velocities: [0.1, 0.1, 0.1, 0.1, 0.1, 0.1], accelerations: [0.1, 0.1, 0.1, 0.1, 0.1, 0.1], time_from_start: { sec: 6, nanosec: 500 } },
      { positions: [-1.01, 0.38, -0.63, -0.88, 0.25, 6.2], velocities: [0.1, 0.1, 0.1, 0.1, 0.1, 0.1], accelerations: [0.1, 0.1, 0.1, 0.1, 0.1, 0.1], time_from_start: { sec: 50, nanosec: 500 } }
    ]
  }
}"

显示关节的状态:

代码语言:javascript
复制
ros2 topic echo /joint_states

目前教程只有4个,还比较简单,但是涵盖了入门ros2和webots的基础要点:

webots_ros2包的每个子包的描述和教程。

  1. webots_ros2_msgs包 服务,消息和操作定义。
  2. webots_ros2_core包 核心接口包。
  3. webots_ros2_examples包 示例ROS2节点连接Webots和ROS2
  4. webots_ros2_universal_robot包 用于连接Universal Robots和Webots的软件包。

webots_ros2是一个ROS功能包,提供必要的接口来仿真机器人的Webots开源3D刚体模拟器中的机器人。 它使用ROS2消息,服务和操作与ROS2集成。

webots_ros2 is a package that provides the necessary interfaces to simulate a robot in the Webots open-source 3D rigid body simulator for robots. It integrates with ROS2 using ROS2 messages, services and actions.

Webots是使用webots_ros2包的先决条件。 它可以从Github存储库下载。 安装很简单,但如果需要,可以在此处找到安装说明。

或者,您也可以从webots_ros2_desktop ROS2包中获取Webot,或者从源代码构建Webots。

在运行时,ROS2将在以下位置查找Webots(按此顺序):

如果设置了ROS2_WEBOTS_HOME环境变量,ROS2将使用此文件夹中的Webots。

如果安装了webots_ros2_desktop ROS2软件包,ROS2将使用此软件包中包含的Webots版本。

如果设置了WEBOTS_HOME环境变量,ROS2将使用此文件夹中的Webots。

如果没有设置/安装前一点,ROS2将在默认安装路径中查找Webots(例如/ usr / local / webots)。

Webots is a prerequisite to use the webots_ros2 package. It can be downloaded from the Github repository. The installation is straightforward, but if need the installation instructions can be found here.

Alternatively, you can also get Webots from the webots_ros2_desktop ROS2 package or build Webots from the sources.

At runtime, ROS2 will look for Webots at the following locations (in this order):

If the ROS2_WEBOTS_HOME environment variable is set, ROS2 will use the Webots in this folder.

If the webots_ros2_desktop ROS2 package is installed, ROS2 will use the Webots version included in this package.

If the WEBOTS_HOME environment variable is set, ROS2 will use the Webots in this folder.

If none of the previous point is set/installed ROS2 will look for Webots in the default installation paths (e.g. /usr/local/webots).

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2019年09月03日,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档