操作ROS松灵机器人步骤及遇到的问题
小車型號:scout-v2.0
https://github.com/agilexrobotics/scout_ros(所用包的下載地址)
或者
https://hub.fastgit.org/agilexrobotics/scout_ros
注意:使用https://github.com下載的很慢,可以采用國內(nèi)鏡像替換https://www.jianshu.com/p/29824058380f
即
https://hub.fastgit.org/agilexrobotics/scout_ros
Communication interface setup
不用管前面得序號,直接一步一步敲命令
Setup UART
Generally your RS232-to-USB cable should be automatically recognized as "/dev/ttyUSB0" or something similar and ready for use. If you get the error "... permission denied ..." when trying to open the port, you need to grant access of the port to your user account:
$ sudo usermod -a -G dialout $USERYou need to re-login to get the change to take effect.
Setup CAN-To-USB adapter
Enable gs_usb kernel module
$ sudo modprobe gs_usbBringup can device
$ sudo ip link set can0 up type can bitrate 500000If no error occured during the previous steps, you should be able to see the can device now by using command
$ ifconfig -aInstall and use can-utils to test the hardware
$ sudo apt install can-utilsTesting command
# receiving data from can0 $ candump can0 # send data to can0 $ cansend can0 001#1122334455667788Install dependent libraries
Clone the packages into your catkin workspace and compile
(the following instructions assume your catkin workspace is at: ~/catkin_ws/src)
$ cd ~/catkin_ws/src $ git clone --recursive https://github.com/agilexrobotics/ugv_sdk.git $ git clone https://github.com/agilexrobotics/scout_ros.git $ cd .. $ catkin_makeif your car is 1.0 version,Please run this command to switch ugv_sdk to 1.0 version
$ cd ugv_sdk && git checkout masterthen recompile
Launch ROS nodes
-
Start the base node for scout
$ roslaunch scout_bringup scout_minimal.launchThe?scout_bringup/scout_minimal.launch?has 5 parameters:
- port_name: specifies the port used to communicate with the robot, default = "can0"
- simulated_robot: indicates if launching with a simulation, default = "false"
- model_xacro: specifies the target ".xacro" file for the publishing of tf frames, default =?scout_v2.xacro
- odom_topic_name: sets the name of the topic which calculated odometry is published to, defaults = "odom"
- is_scout_mini:Suitable for chassis of type scout_mini,defaults = "false"
-
Start the base node for scout-mini
$ roslaunch scout_bringup scout_mini_minimal.launch -
Start the keyboard tele-op node
$ roslaunch scout_bringup scout_teleop_keyboard.launch
一.catkin_make編譯時,總失敗,報錯如下:
param_demo.cpp:(.text+0x50):對‘ros::init(int&, char**, std::string const&, unsigned int)’未定義的引用
param_demo.cpp:(.text+0x80):對‘ros::NodeHandle::NodeHandle(std::string const&, std::map<std::string, std::string, std::less<std::string>, std::allocator<std::pair<std::string const, std::string> > > const&)’未定義的引用
param_demo.cpp:(.text+0xb8):對‘ros::param::get(std::string const&, int&)’未定義的引用
param_demo.cpp:(.text+0x100):對‘ros::NodeHandle::getParam(std::string const&, int&) const’未定義的引用
param_demo.cpp:(.text+0x1e8):對‘ros::console::initializeLogLocation(ros::console::LogLocation*, std::string const&, ros::console::levels::Level)’未定義的引用
解決辦法:g++ 和gcc 版本不同造成編譯錯誤,參考https://blog.csdn.net/xrinosvip/article/details/81177873
修改成統(tǒng)一版本即可編譯成功!!!
命令如下:(查看版本)
gcc -v?
g++ -v
(修改g++ 和gcc的版本,選擇數(shù)字后回車即可,gcc 和g++ 必須統(tǒng)一才行!)
sudo update-alternatives --config g++
?sudo update-alternatives --config gcc
二.運行roslaunch scout_bringup scout_minimal.launch 報錯如下:
RLException: [scout_minimal.launch] is neither a launch file in package [scout_bringup] nor is [scout_bringup] a launch file name
The traceback for the exception was written to the log file
解決方案:在catkin_ws目錄下:source ./devel/setup.bash 即可解決
三. nanjingtech@nanjingtech-desktop:~/catkin_ws2$ source ./devel/setup.bash
nanjingtech@nanjingtech-desktop:~/catkin_ws2$ roslaunch scout_bringup scout_teleop_keyboard.launch
報錯如下:
ModuleNotFoundError: No module named 'rospkg'
[teleop_keybord-1] process has died [pid 7638, exit code 1, cmd /opt/ros/melodic/lib/teleop_twist_keyboard/teleop_twist_keyboard.py __name:=teleop_keybord __log:=/home/nanjingtech/.ros/log/c9cfb1de-edf0-11eb-818c-845cf327b690/teleop_keybord-1.log].
log file: /home/nanjingtech/.ros/log/c9cfb1de-edf0-11eb-818c-845cf327b690/teleop_keybord-1*.log
all processes on machine have died, roslaunch will exit
shutting down processing monitor...
... shutting down processing monitor complete
done
解決方案參考https://blog.csdn.net/weixin_45688316/article/details/103697198
python版本的問題!!
解決方案
因為ubuntu18.04使用的ros版本是melodic,而melodic默認(rèn)使用的是python2,但是我們跑代碼實際用的是python3。
所以現(xiàn)在bashrc文件里加
alias python=python3
保存后
source ~/.bashrc
下載rospkg
pip3 install rospkg
問題解決
?
總結(jié)
以上是生活随笔為你收集整理的操作ROS松灵机器人步骤及遇到的问题的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: ROS-kinetic 机器语音 之科大
- 下一篇: Jetson Nano 改成国内源(中科