Getting Started 21 Ku ranking ROS stress study notes (9-16 Programming Fundamentals course) (continually updated)

Create a workspace lesson Feature Pack Lesson 9

Workspace

src: code space. xml file
build: Compile space, basically do not care about
devel: development of space,
install: the installation space

  1. Create a workspace
    mkdir -p ~ / catkin_ws / src
    cd ~ / catkin_ws / src
    catkin_init_workspace

  2. Compiler workspace
    cd ~ / catkin_ws /
    catkin_make (devel generate and build folders)
    catkin_make install (produce install folder)

  3. Set the environment variable
    source devel / setup.bash

  4. Check the environment variable
    echo $ ROS_PACKAGE_PATH

Creating Feature Pack

catkin_creat_pkg (function package name) [1] [dependency dependent dependent 3] [2]

  1. Creating Feature Pack
    cd ~ / catkin_ws / src
    catkin_create_pkg test_pkg std_msgs rospy roscpp

  2. Compilation package
    CD ~ / catkin_ws
    catkin_make
    Source ~ / catkin_ws / devel / setup.bash

Under the same workspace, not allowed to have the same name as the function package, under different workspaces can have.

Lesson Ten publisher Publisher's programming

Creating Feature Pack

cd ~/catkin_ws/src
catkin_create_pkg learning_topic roscpp std_msgs geometry_msgs turtlesim

c ++ realize

1. Write a program

References in the velocity_publisher.cpp file.
Here Insert Picture Description

2. At the end of the file plus CMakelist.txt

add_executable(velocity_publisher src/velocity_publisher.cpp)
target_link_libraries(velocity_publisher ${catkin_LIBRARIES})

3. Compile and run

~ CD / catkin_ws
catkin_make
Source devel / setup.bash
newly opened terminal roscore
new terminal rosrun turtlesim turtlesim_node opened
to open the terminal rosrun learning_topic velocity_publisher

python achieve

Look courseware Code

Lesson Eleven subscribers Subscriber's programming

Published 15 original articles · won praise 1 · views 727

Guess you like

Origin blog.csdn.net/Enochzhu/article/details/104370802