Skip to content

sofiavldd2005/Learning-ROS2

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Learning ROS 2

My 1st workspace

  1. Creating the workspace:
mkdir -p ~/learning_ros_ws/src
cd ~/learning_ros_ws/src
  1. Generate the C++ package:
ros2 pkg create --build-type ament_cmake learning_nodes --dependencies rclcpp std_msgs
  1. Added my minimal publisher and subscriber .cpp files
  2. Edit CMakeLists.txt to add the rules to compile the .cpp files into executables:
    • Rules added before ament_package() section
# Add the publisher executable
add_executable(talker src/minimal_publisher.cpp)
ament_target_dependencies(talker rclcpp std_msgs)

# Add the subscriber executable
add_executable(listener src/minimal_subscriber.cpp)
ament_target_dependencies(listener rclcpp std_msgs)

# Tell ROS 2 where to install the executables so it can find them later
install(TARGETS
  talker
  listener
  DESTINATION lib/${PROJECT_NAME})
  1. Build the workspace:
cd ~/learning_ros_ws
colcon build
  1. Source and Run
    • The install folder contains the setup scripts needed to inject this specific workspace into your terminal's environment
source ~/learning_ros_ws/install/setup.zsh
ros2 run learning_nodes talker

and

source ~/learning_ros_ws/install/setup.zsh
ros2 run learning_nodes listener

About

Just stuff I am experimenting to learn ros

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages