개발하는 핑구
article thumbnail
Published 2023. 2. 21. 16:26
[ROS2 시작하기 - 2] Tools Robotics/ROS2

ROS2 Tools

# you can know the details of function
ros2 -h
# print now executing nodes
ros2 node list
# print the node's information
ros2 node info [node`s name]

# in your ~/.bashrc
# you can not use ros2 functions without this line(ex. ros2 run ~)
source /opt/ros/foxy/setup.bash
# you can not use your local workspace nodes without this line
source ~/ros2_ws/install/setup.bash
source /usr/share/colcon_argcomplete/hook/colcon-argcomplete.bash

You can rename a node when you launch node if you want to launch the same node a few times with a different name each other. Because a node can have many sensors

ros2 run my_py_pkg py_node --ros-args --remap __node:=[name of node]
# or
ros2 run my_py_pkg py_node --ros-args -r __node:=[name of node]

Colcon

you should compile the package whenever you change the py file if you have compiled the package before. But this code makes you don’t need to compile whenever you change the file. It is automatically compiled if you change the file.

colcon build --packages-select my_py_pkg --symlink-install

if you have an error, it is because your computer can't find executable file (~/ros2_ws/src/my_py_pkg/my_py_pkg/my_first_node.py). so you need to make the file to executable file.

chmod +x my_first_node.py

rqt and rqt graph

It is a GUI tool that you can use to debug your graph and nodes.

rqt

We are interested about node graph.

# you can use node graph directly
 rqt_graph

Every nodes are publish to the rosout. And every node is independent, but still communicating with the topic rosout

/test, /py_test : your node

/rqt_gui_py_node_3312 : you execute rqt_graph. it is also node

/_ros2cli_caemon_0 : it is something that is launched when you start a node. it will be easier for node to find each other

/rosout : topic

Turtlesim

ros2 run turtlesim turtlesim_node

# you can control the turtle
ros2 run turtlesim turtle_teleop_key

Section Conclusion

In this section you’ve discovered 2 important tools you’ll use for any ROS2 application you develop: the ros2 cli (Command Line Interface), and rqt with all its plugins. During the course you’ll continue to practice with those tools, and you’ll discover more of them.

You also discovered the Turtlesim package, which will be very useful to apply what you learn throughout the course.

So, with the last section on nodes + the activities from this section, you already have a good foundation to:

  • Create a custom node in your own package (Python and Cpp)
  • Compile and run your nodes
  • Launch and debug your nodes with different tools
  • Run existing nodes from other packages

Now, the next logical step is to see how those nodes can communicate between each other. And… That’s just what’s coming in the next section on ROS2 Topics.

'Robotics > ROS2' 카테고리의 다른 글

[ROS2 시작하기 - 4] Service  (0) 2023.02.24
[ROS2 시작하기 - 3] Topic  (0) 2023.02.23
[ROS2 시작하기 - 1] Node  (0) 2023.02.20
[ROS2 시작하기 - 0] 환경 셋팅  (0) 2023.02.19
ROS2와 DDS란?  (0) 2023.02.18
profile

개발하는 핑구

@sinq

포스팅이 좋았다면 "좋아요❤️" 또는 "구독👍🏻" 해주세요!