Webots和ROS2使用說明(部分翻譯)
參考鏈接 Reference:

文檔:http://wiki.ros.org/webots_ros2
源碼:https://github.com/cyberbotics/webots_ros2
2021更新webots+ros2 筆記系列:
https://blog.csdn.net/ZhangRelay/article/details/112670542
目前,已經(jīng)測試過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:只能源碼編譯。過程如下:
導(dǎo)入Dashing環(huán)境:
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
設(shè)置路徑:
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
更新工作環(huán)境:
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文件夾下:
使用colcon編譯。
如果使用Windows環(huán)境,請參考wiki。
移動機(jī)器人示例:
啟動:
ros2 launch webots_ros2_examples example.launch.py
rqt:
用命令方式移動機(jī)器人或者顯示傳感器參數(shù):
ros2 service call /motor webots_ros2_msgs/SetDifferentialWheelSpeed "{ left_speed: 1.0, right_speed: 0.5 }"
ros2 topic echo /sensor
給定左右輪相同速度,緩慢向前移動:
快接近邊緣時候停止運(yùn)動:
傳感器值感覺還是有問題的!
工業(yè)機(jī)械臂示例:
單機(jī)械臂:
ros2 launch webots_ros2_universal_robot universal_robot.launch.py
雙機(jī)械臂
ros2 launch webots_ros2_universal_robot universal_robot_multiple.launch.py
移動機(jī)械臂:
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 } }
]
}
}"
顯示關(guān)節(jié)的狀態(tài):
ros2 topic echo /joint_states
目前教程只有4個,還比較簡單,但是涵蓋了入門ros2和webots的基礎(chǔ)要點(diǎn):
webots_ros2包的每個子包的描述和教程。
webots_ros2_msgs包
服務(wù),消息和操作定義。
webots_ros2_core包
核心接口包。
webots_ros2_examples包
示例ROS2節(jié)點(diǎn)連接Webots和ROS2
webots_ros2_universal_robot包
用于連接Universal Robots和Webots的軟件包。
webots_ros2是一個ROS功能包,提供必要的接口來仿真機(jī)器人的Webots開源3D剛體模擬器中的機(jī)器人。 它使用ROS2消息,服務(wù)和操作與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,或者從源代碼構(gòu)建Webots。
在運(yùn)行時,ROS2將在以下位置查找Webots(按此順序):
如果設(shè)置了ROS2_WEBOTS_HOME環(huán)境變量,ROS2將使用此文件夾中的Webots。
如果安裝了webots_ros2_desktop ROS2軟件包,ROS2將使用此軟件包中包含的Webots版本。
如果設(shè)置了WEBOTS_HOME環(huán)境變量,ROS2將使用此文件夾中的Webots。
如果沒有設(shè)置/安裝前一點(diǎn),ROS2將在默認(rèn)安裝路徑中查找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).
機(jī)器翻譯
版權(quán)聲明:本文內(nèi)容由網(wǎng)絡(luò)用戶投稿,版權(quán)歸原作者所有,本站不擁有其著作權(quán),亦不承擔(dān)相應(yīng)法律責(zé)任。如果您發(fā)現(xiàn)本站中有涉嫌抄襲或描述失實(shí)的內(nèi)容,請聯(lián)系我們jiasou666@gmail.com 處理,核實(shí)后本網(wǎng)站將在24小時內(nèi)刪除侵權(quán)內(nèi)容。
版權(quán)聲明:本文內(nèi)容由網(wǎng)絡(luò)用戶投稿,版權(quán)歸原作者所有,本站不擁有其著作權(quán),亦不承擔(dān)相應(yīng)法律責(zé)任。如果您發(fā)現(xiàn)本站中有涉嫌抄襲或描述失實(shí)的內(nèi)容,請聯(lián)系我們jiasou666@gmail.com 處理,核實(shí)后本網(wǎng)站將在24小時內(nèi)刪除侵權(quán)內(nèi)容。