Skip to content

Latest commit

 

History

105 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ROS 2 Workspace

Turtlesim


This is a collection from src files that I have written with the help of a) ROS Documentation b) YouTube and c) "ROS 2 from Scratch" book.

Requirements

  1. Ubuntu 24.04
  2. ROS 2 Jazzy

Getting Started

  1. Clone the repository
  2. Build the workspace with colcon build
$ cd ~/ROS2
$ colcon build
  1. Source the workspace
$ source ~/ROS2/install/setup.bash
  1. or add the following line to your .bashrc
$ echo "source ~/ROS2/install/setup.bash" >> ~/.bashrc
  1. Create a package (folder) for the nodes
cd src/

# python
ros2 pkg create my_py_pkg --build-type ament_python --dependencies rclpy

# or cpp
ros2 pkg create my_cpp_pkg --build-type ament_cmake --dependencies rclcpp
  1. Create a file for the node and make it executable
cd src/my_robot_controller/my_robot_controller

# create file
touch my_first_node.py

# make it excecutive VERY IMPORTANT
chmod +x my_first_node.py
  1. Write the code for the node, add the reference to the setup.py and load dependencies (if necessary) in package.xml
  2. Bd everything in development mode
cd ~/ros2_ws
colcon build --symlink-install 

# or optional
colcoun build --symlink-install --packages-select my_robot_controller
  1. Source the file (in bashrc)
source ~/.bashrc

# there must be a line:
source ~/path/to/ros2_ws/install/setup.bash

like

# start ros2
source /opt/ros/jazzy/setup.bash
source /usr/share/colcon_cd/function/colcon_cd-argcomplete.bash
# install my ROS workspace
source ~/Desktop/GitHub/ros2_ws/install/setup.bash

In this repository, I cover the topics:

  1. ROS Terminology, Concepts and Programming
  2. ROS Visualization Tools
  3. Building a Robot with URDF
  4. Improving the URDF file with Xacro

And this is enough for getting started with ROS 2. The following topics, about Gazebo and Robot simulations will happen in a new workspace, since it makes sense to seperate workspaces for every robot we build. This workspace is already quite full with turtlesim and my_robot_controller, as well as the URDF files on top of it. So lets start a new workspace for the next robot.

IMPORTANT LAST NOTE

The workspace, we are working with, is sourced in .bashrc when opening a terminal.

# start ros2
source /opt/ros/jazzy/setup.bash
source /usr/share/colcon_cd/function/colcon_cd-argcomplete.bash
# install my ROS workspace
source ~/Desktop/GitHub/ros2_ws/install/setup.bash

Never source 2 workspaces together, so make sure to comment out the old workspace, when starting a new one.

# source ~/Desktop/GitHub/ros2_ws/install/setup.bash
source ~/Desktop/GitHub/my_new_workspace_name/install/setup.bash

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages