Ros workspace and compilation

The early little turtles have been provided by others, and we can install them directly. If we want to run them ourselves, or write some function packages, we can do this:

  • Create a workspace:
  • mkdir catkin_ws installs the official name of ros
  • cd catkin_ws/
  • mkdir src src workspace
  • Commands to compile the workspace
  • After catkin_make runs the command, the build and devel folders are added to the directory, run your own function package, and put the code in the src directory.
  • cd src/ is used to store the source code of the function package
  • Pull code
  • git clone https://gitee.com/liufuzhi/bingda_tutorials.git The directory at this time is src
  • cd .. Jump to the upper level directory and recompile the work package because the work package has changed
  • Run catkin_make in the home directory of the workspace
  • After compilation, you cannot run the code directly because it has not been added to the environment variables. Ros does not recognize the function packages in it, so you need to add the workspace to the environment variables.
  • cd
  • To edit environment variables, we use the .bashrc file
  • vim .bashrc
  • Add the namespace to the last line
  • source /home/bingda/catkin_ws/devel/setup.bash Press esc+:wq to save and exit
  • source .bashrc 
  • run
  • roslaunch bingda_tutorials bingda_talker.launch message publisher
  • roslaunch bingda_tutorials bingda_listener.launch message subscribers
  • The above is to run a program written by yourself, compile and run.

Guess you like

Origin blog.csdn.net/qq_44808827/article/details/123353789