Ros using step by step

2 篇文章 0 订阅
2 篇文章 0 订阅

catkin workspace(update in 2020-07-16)

Edited in the third time

  • workspace_folder/ − w o r k s p a c e - \bf workspace workspace
    • src/ − s o u r c e s p a c e -sourcespace sourcespace
      • CMakeLists.txt – The ‘toplevel’ CMake file
      • package_1/
        • CMakeLists.txt
        • package.xml
      • package_n/
        • CATKIN_IGNORE – Optional empty file to exclude package_n from being processed
        • CMakeLists.txt
        • package.xml
    • build/ – BUILD SPACE
      • CATKIN_IGNORE – Keeps catkin from walking this directory
    • devel/ – DEVELOPMENT SPACE (set by CATKIN_DEVEL_PREFIX)
      • bin/
      • etc/
      • include/
      • lib/
      • share/
      • .catkin
      • env.bash
      • setup.bash
      • setup.sh
    • install/ – INSTALL SPACE (set by CMAKE_INSTALL_PREFIX)
    • bin/
    • etc/
    • include/
    • lib/
    • share/
    • .catkin
    • env.bash
    • setup.bash
    • setup.sh

How to set the catkin workspace

mkdir -p ~/catkin_ws/src
cd ~/catkin_ws/src
catkin_init_workspace

create the catkin_workspace

cd ..
catkin_make

if you wanna set the env of install

catkin_make install

create the pkg

cd ~/catkin_ws/src
catkin_create_pkg test_pkg roscpp rospy std_msgs

command:

rospack find package_name
## find the root of the package
rospack list
## list the package in the catkin_ws
roscd package_name
## jump into the package 
rosls package_name
## show the info about this package
roscd package_name file_name
## 
catkin_create_pkg <pkg_name> [deps]
## create the package with dependence 
rosdep install [pkg_names]
## install the dependence
## you can install tree the folder root 
sudo apt install tree 
## you can use command tree to show the folder
tree -L 1 

.bashrc file you can edit the command with terminal

##bash the source 
gedit ~/.bashrc
rosnode list 
rosnode info 
rosnode kill 
roslaunch [pkg_name][file_name.launch]

ORB-SLAM2 with ROS

code source:

we need to download the ORB-SLAM2 code source :
https://github.com/raulmur/ORB_SLAM2
https://github.com/DroidAITech/ROS-Academy-for-Beginners
Warning: if you ROS version is melodic plz choose the branch of the melodic
step1:
init the catkin workspace :

mkdir -p WorkspaceROS/catkin_ws/src
cd WorkspaceROS/catkin_ws
catkin_make 	
# active the env 
source devel/setup.bash
#you should put the ROS-Academy-for-Beginners in the /src/ file 
#and you should install some needed package 
rosdep install --from-paths src --ignore-src --rosdistro=melodic -y
#if you kinect you should rewrite the melodic 
# you alse could add this command in the ~/.bashrc 
# you can edit this file with gedit and add the line 

step2:
set the third part of the OpenCV and Pangolin eigen3

you can find this from my blog in the past i won’t write in this blog
step3:
get the code from the website of github

git clone https://github.com/raulmur/ORB_SLAM2.git
#we need set the ./bashrc
#this command is will be OK :
export ROS_PACKAGE_PATH=${ROS_PACKAGE_PATH}:/home/【本机名】/catkin_ws/src/ORB_SLAM2/Examples/ROS
#i choose gedit ~/.bashrc and the edit by my way 
#just add the ROS file in the root env
cd ORB_SLAM2
chmod +x build.sh 	
./build.sh
chmod +x build_ros.sh
./build_ros.sh

step4: 在//home/本机/catkin_ws/src/ORB_SLAM2/Examples/ROS/ORB_SLAM2/src下找到ros_rgbd.cc

step5:line68和line69用下列代码替换:

message_filters::Subscriber<sensor_msgs::Image> rgb_sub(nh, "/camera/rgb/image_raw", 1);
message_filters::Subscriber<sensor_msgs::Image> depth_sub(nh, "camera/depth/image_raw", 1);

step6:重新编译,回到ORB_SLAM2/下执行:./build_ros.sh
step7: open the terminal and input the command

roslaunch robot_sim_demo robot_spawn.launch
#first one 
roslaunch orbslam2_demo ros_orbslam2.launch
#second one 
rosrun robot_sim_demo robot_keyboard_teleop.py
#third one 

you will get this pic :
在这里插入图片描述在这里插入图片描述

ROS example:

Building traffic light detection and controlling vehicle model movement in ROS based on paddledetection
Env Melodic ROS
step1.

mkdir ~/race_car/src
cd ~/race_car/src 
catkin_init_workspace
# init catkin workspace
git clone https://github.com/xmy0916/racecar
# you could download directly by using the website 
# and when you using git clone maybe download too slow
# that you cannot stand  

step2.may be you should install third part control assembly
You sholud use this command show in below

sudo apt-get install ros-melodic-driver-base
sudo apt-get install ros--melodic-gazebo-ros-control
sudo apt-get install ros--melodic-effort-controllers
sudo apt-get install ros--melodic-joint-state-controller
sudo apt-get install ros-melodic-ackermann-msgs
sudo apt-get install ros-melodic-global-planner
sudo apt-get install ros-melodic-teb-local-planner

error message output :

 Could not find a package configuration file provided by "OpenCV" with any
  of the following names:

    OpenCVConfig.cmake
    opencv-config.cmake

Fixed the problem by adding the line set(OpenCV_DIR /usr/share/OpenCV/) before the find_package() command in my cmakelists file.
Could not find a package configuration file provided by “OpenCV”

this code will find your opencv build target location

locate OpenCVConfig.cmake

and you can find out which one DIR has his opencvcmakelist.txt

go to the command

gedit ~/catkin_ws/src/racecar-master/racecar_gazebo/CMakeLists.txt

ros-melodic-cv-bridge or ros-kinect you must be sure which version you have install

sudo apt-get install python-catkin-tools python3-dev python3-catkin-pkg-modules python3-numpy python3-yaml ros-kinetic-cv-bridge

then :re edit the line 7 may be line 7 to set the OPENCV_DIR
cv_bridge uses opencv3.2

Next:you should create a env to make the workspace cvbridge

mkdir catkin_workspace
cd catkin_workspace
catkin init

Then catkin the python in the catkin_workspace

catkin config -DPYTHON_EXECUTABLE=/usr/bin/python -DPYTHON_INCLUDE_DIR=/usr/include/python3.6m -DPYTHON_LIBRARY=/usr/lib/x86_64-linux-gnu/libpython3.6m.so
catkin config --install
git clone https://github.com/ros-perception/vision_opencv.git src/vision_opencv

Then check out the melodic cvbridge and grep version:
may be you run in the linux 16.04 and then you should use the kinect instead of the melodic

apt-cache show ros-melodic-cv-bridge | grep Version

Then check the git

git checkout 1.12.8

this step have a question of this command

cd ../../
catkin build cv_bridge
source install/setup.bash --extend

error:

 Could not find the following Boost libraries:

          boost_python37
  Unable to find the requested Boost libraries.

  Boost version: 1.65.1

  Boost include path: /usr/include


Thanks:

  1. https://blog.csdn.net/qq_44830040/article/details/107032569?%3E
  2. http://www.luyixian.cn/news_show_402183.aspx this website using for solve the racecar github code’s error
  3. https://blog.csdn.net/bigdog_1027/article/details/79092263 this website tell you how setup the CmakeLists.txt about the opencv
  4. https://aur.archlinux.org/packages/ros-melodic-cv-bridge/ find out linux package
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值