一、引言
這篇文章主要內(nèi)容是關(guān)于如何在 Ros2 環(huán)境中構(gòu)建在 Mac 上模擬 Mycobot 280 M5 的環(huán)境。
我寫(xiě)這篇文章是因?yàn)橄嚓P(guān)可參考的文章不多,希望這篇文章可以給你一些幫助。
由于我是 ROS 新手,關(guān)于文章內(nèi)容如果您有任何指教或補(bǔ)充,歡迎在下方留言和我們溝通。
二、準(zhǔn)備工作與技術(shù)介紹
1、硬件組件
Elephant Robotics myCobot-6 DOF collaborative robot
myCobot 280系列機(jī)械臂是專(zhuān)門(mén)為研究、教育、技術(shù)應(yīng)用和商業(yè)展覽而開(kāi)發(fā)的6-DOF協(xié)作機(jī)器人。
2、環(huán)境配置
M3 MacBook Air
16GB RAM
三、項(xiàng)目運(yùn)行
1、搭建ROS2環(huán)境
在Docker上搭建ROS2(Humble)環(huán)境
可以參考此鏈接搭建安裝了ROS2的Ubuntu圖形用戶(hù)界面環(huán)境 https://memoteki.net/archives/2955#index_id3
然后創(chuàng)建一個(gè)Docker容器
在設(shè)置Dock容器的共享內(nèi)存時(shí)最好進(jìn)行一些修改——通常共享內(nèi)存默認(rèn)是64MB,容量不大,所以建議至少應(yīng)設(shè)置為2GB。
docker run -p 6080:80 --security-opt seccomp=unconfined --shm-size=2G tiryoh/ros2-desktop-vnc:humble-amd64
成功啟動(dòng)后,訪問(wèn)http://127.0.0.1:6080/ 。此時(shí) Ubuntu 應(yīng)該已啟動(dòng)。
2、構(gòu)建 MoveIt2 環(huán)境
這一步是通過(guò)官方教程來(lái)完成的。
教程鏈接為:https://moveit.picknik.ai/main/doc/tutorials/getting_started/getting_started.html
按順序執(zhí)行以下命令:
在 Ubuntu 終端中操作
source /opt/ros/humble/setup.bash
安裝rosdep(可能已安裝)
sudo apt install python3-rosdep sudo rosdep init rosdep update sudo apt update sudo apt dist-upgrade
安裝colcon mixin擴(kuò)展
sudo apt install python3-colcon-common-extensions sudo apt install python3-colcon-mixin colcon mixin add default https://raw.githubusercontent.com/colcon/colcon-mixin-repository/master/index.yaml colcon mixin update default
安裝 vsctool
sudo apt install python3-vcstool
創(chuàng)建colcon工作空間
mkdir -p ~/ws_moveit/src
獲取MoveIt源代碼
cd ~/ws_moveit/src git clone -b humble https://github.com/moveit/moveit2_tutorials vcs import --recursive < moveit2_tutorials/moveit2_tutorials.repos
構(gòu)建colcon工作空間
sudo apt remove ros-humble-moveit* sudo apt update && rosdep install -r --from-paths . --ignore-src --rosdistro humble -y
進(jìn)行構(gòu)建可能需要幾十分鐘到一個(gè)小時(shí)。
關(guān)于構(gòu)建參數(shù):
在Docker環(huán)境中,建議指定以下參數(shù),以避免可能出現(xiàn)的內(nèi)存不足問(wèn)題。
--executor sequential:逐個(gè)進(jìn)行構(gòu)建
--parallel - workers 2:指定同時(shí)進(jìn)行構(gòu)建的數(shù)量
如果可以的話,也增加Docker共享內(nèi)存來(lái)加快構(gòu)建時(shí)間。
cd ~/ws_moveit colcon build --mixin release
源代碼
source ~/ws_moveit/install/setup.bash echo ‘source ~/ws_moveit/install/setup.bash’ >> ~/.bashrc
3、關(guān)于構(gòu)建中的錯(cuò)誤
在構(gòu)建中可能遇到各種錯(cuò)誤,這里寫(xiě)出部分注釋以供參考。
pick_ik錯(cuò)誤
sudo apt-get remove ros-humble-pick-ik
ament_cmake錯(cuò)誤
以特權(quán)用戶(hù)身份運(yùn)行構(gòu)建命令
su
4、讓mycobot模擬器與moveit2一起工作
參考以下鏈接來(lái)創(chuàng)作
https://www.youtube.com/watch?v=ZOIKEV_BCBE&t=566s
獲取ROS2的mycobot源
在ws_moveit/src下克隆
git clone https://github.com/elephantrobotics/mycobot_ros2.git
5、啟動(dòng)設(shè)置助手
選擇創(chuàng)建新MoviIt
選擇mycobot的URDF并點(diǎn)擊loadFile
mycobot_ros2/mycobot_description/urdf/mhcobot_280_m5/mycobot_280_m5.urdf
機(jī)器的型號(hào)以及泵頭或攝像頭是否可用可以根據(jù)情況而定。
自碰撞設(shè)置(Self collision)
默認(rèn)生成沖突矩陣。
虛擬關(guān)節(jié)設(shè)置(Virtual joints)
添加虛擬接頭,命名后保存它們。
定義規(guī)劃組(Planning Groups)
添加 Add Group
選擇求解器的kdl_kinematics_plugin
Kin. parameters file設(shè)置為3
添加關(guān)節(jié)
除g_base以外,均可添加添加鏈接
同上,增加g_base
添加姿態(tài)
使用滑塊創(chuàng)建姿態(tài)。
也可以之后再添加。
設(shè)置ROS2控制器
點(diǎn)擊“自動(dòng)添加”
設(shè)置MoveIt控制器
點(diǎn)擊“自動(dòng)添加”
添加作者和郵箱
生成并保存
保存在colcon工作空間的src目錄下
構(gòu)建和安裝
cd ~/ws_moveit colcon build --mixin release . install/setup.bash
啟動(dòng)
ros2 launch mycobot_move_it demo.launch.py
四、總結(jié)
通過(guò)以上步驟就可以使程序在模擬器中運(yùn)行了。但是問(wèn)題在于,在Mac系統(tǒng)上無(wú)法通過(guò)Docker使用USB,所以無(wú)法運(yùn)行實(shí)際設(shè)備。如果你有關(guān)于本文的內(nèi)容或者機(jī)械臂使用有任何觀點(diǎn)和疑問(wèn),歡迎留言和我們交流溝通。
-
Mac
+關(guān)注
關(guān)注
0文章
1110瀏覽量
51705 -
容器
+關(guān)注
關(guān)注
0文章
499瀏覽量
22119 -
ROS
+關(guān)注
關(guān)注
1文章
280瀏覽量
17094 -
Docker
+關(guān)注
關(guān)注
0文章
492瀏覽量
11960
原文標(biāo)題:在Mac上使用 Docker 構(gòu)建一個(gè) noVNC 環(huán)境并成功運(yùn)行MyCobot案例!
文章出處:【微信號(hào):ElephantRobotics,微信公眾號(hào):大象機(jī)器人】歡迎添加關(guān)注!文章轉(zhuǎn)載請(qǐng)注明出處。
發(fā)布評(píng)論請(qǐng)先 登錄
相關(guān)推薦
評(píng)論