ROS 2 Notes Saket
ROS 2 Notes Saket
Well this ain’t enough, we have to make this Python file into executive
mode:
chmod +x python_folder_name.py
[For confirmation, type ls and check if the python file name is changed to green from white
color.]
Then Do this:
Node: It is like a Robot Program or a task we are defining. (They can either publish or
subscribe to a Topic)
Topic: It is which two nodes communicate with each other. (Way to communicate
between different nodes.)
Here oval enclosed text are nodes, there are two nodes here, one opens a turtle simulator
(turtlesim) and the other actually moves (teleop) the turtle when we press keys, the other
example is a publisher node and a subscriber node.
Creating a Publisher:
Don’t forget to add these things:
Dependencies in package.xml:
Result:
Similarly write the code for Subscriber:
’
Now here is a new code of a closed loop of a Publisher and a
subscriber:
Now to run this code:
Lil complex function/code for the same: (Just an added if-else condition to avoid hitting of
turtle)
Hello
ROS2 Action
Start:
cmake_minimum_required(VERSION 3.8)
project(my_robot_interfaces)
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
endif()
# find dependencies
find_package(ament_cmake REQUIRED)
find_package(rosidl_default_generators REQUIRED)
rosidl_generate_interfaces(${PROJECT_NAME}
)
ament_export_dependecies(rosidl_default_runtime)
ament_package()