How to Create a ROS 2 Package – Iron

In this tutorial, we will go over how to create a ROS 2 package.

A ROS 2 package is the fundamental building block of robot software in ROS 2. Imagine it as a Lego brick in your robot’s software architecture. Each package contains a specific piece of functionality or capability, like motor control, sensor processing, or communication with other systems.

Remember, just like Legos, you can combine multiple ROS 2 packages to create complex robot functionalities. Each package plays its specific role, and together they build the complete software system for your robot.

The official instructions for creating a package are here, but I will walk you through the entire process, step by step.

Let’s get started!

Prerequisites

Directions

Open a terminal, and type these commands (note: we are using the Apache 2.0 license, but you can remove that piece if you want):

cd ~/ros2_ws/src
ros2 pkg create --build-type ament_cmake --license Apache-2.0 cobot_arm_examples

Now let’s build our new package:

cd ~/ros2_ws
colcon build 

Let’s see if our new package is recognized by ROS 2.

Either open a new terminal window or source the bashrc file like this:

source ~/.bashrc
ros2 pkg list

You can see the newly created package right there at the top.

8-cobot-arm-examples

Install Useful Packages (Optional)

In a month or so, I will begin building a robotic arm. The package in this tutorial will serve as the foundation for the ROS 2 software.

Let’s install some useful packages that will help us along the way.

Begin by installing a tool called Terminator. Terminator will enable you to have multiple terminal panes within a single interface.

Open a terminal window, and type the following commands:

sudo apt-get update -y
sudo apt-get upgrade -y
sudo apt-get install terminator

To open terminator, you can either click the 9 dots in the bottom left of your Desktop and search for “terminator”….or you can type terminator in a regular terminal window.

You can use CTRL + Shift + E or CTRL + Shift + O to split the terminal window into different panels.

Let’s install some useful ROS 2 packages. Open a terminal window, and type the following:

sudo apt-get install ros-$ROS_DISTRO-gazebo-ros
sudo apt-get install ros-$ROS_DISTRO-gazebo-ros2-control
sudo apt-get install ros-$ROS_DISTRO-joint-state-publisher-gui
sudo apt-get install ros-$ROS_DISTRO-moveit
sudo apt-get install ros-$ROS_DISTRO-xacro
sudo apt-get install ros-$ROS_DISTRO-ros2-control
sudo apt-get install ros-$ROS_DISTRO-ros2-controllers
sudo apt-get install libserial-dev
sudo apt-get install python3-pip
pip install pyserial

If you want to use Amazon Alexa Voice Assistant down the road to control your robotic arm, install the following:

pip install ask-sdk
pip install flask
pip install flask-ask-sdk

Configure Colcon

colcon is the primary command-line tool for building, testing, and installing ROS packages.

In your terminal window, type the following command:

echo "source /usr/share/colcon_argcomplete/hook/colcon-argcomplete.bash" >> ~/.bashrc

That’s it! Keep building!

How to Create a ROS 2 Workspace – Iron

In this tutorial, we will go over how to create a ROS 2 workspace.

In ROS 2, a workspace serves as the central point for organizing and developing your robot software. It’s a directory that houses all the different software packages, data files, and configuration scripts related to your specific robot project. Think of it as a dedicated folder for all your “robot building blocks.”

The official instructions for creating a workspace are here, but I will walk you through the entire process, step by step.

Let’s get started!

Prerequisites

Directions

Open a terminal, and type these commands:

mkdir -p ~/ros2_ws/src
cd ~/ros2_ws/
colcon build
echo "source ~/ros2_ws/install/setup.bash" >> ~/.bashrc

That’s it! You have now created a ROS 2 workspace.

How Generative AI Will Impact Robotics

Generative AI is expected to have a major impact on the field of robotics, transforming the way robots are designed, developed, and deployed.

What is Generative AI?

Generative AI works by learning from a lot of examples. For example, if you want a generative AI to create pictures of cats, you would show it a lot of pictures of cats. The generative AI would then learn what cats look like and how to draw them.

Once the generative AI has learned from a lot of examples, it can start to create new things.

For example, it could draw a picture of a cat that you’ve never seen before. Or it could write a story about a cat who goes on an adventure.

1-group-of-cats

Generative AI is still under development, but it’s already being used to create all sorts of amazing things. For example, it’s being used to create new drugs and medical treatments, to design new products, and to create new forms of art and entertainment.

How Generative AI Will Impact Robotics

Here are some specific ways in which generative AI is likely to change robotics:

Robot Design

2-robot-design-hand-prosthesis

Generative AI can be used to design new and innovative robots, optimized for specific tasks and environments. For example, generative AI can be used to design robots with lightweight, energy-efficient bodies, or robots that can move and manipulate objects in complex and unstructured environments.

Robot Control

3-robot-control-mobile-unstructured

Generative AI can be used to develop new control algorithms for robots, enabling them to learn new behaviors and adapt to changing conditions more effectively. For example, generative AI can be used to develop robots that can learn to perform new tasks by watching humans, or robots that can plan and navigate their way through unknown environments.

Robot Training

4-robot-training

Generative AI can be used to create realistic simulations of real-world environments, which can be used to train robots before they are deployed in the real world. This can help reduce the risk of damage to robots and their surroundings, and can also help robots learn faster and more efficiently.

Human-Robot Interaction

5-human-robot-interaction

Generative AI can be used to develop robots that can interact with humans more naturally and effectively. For example, generative AI can be used to develop robots that can understand and respond to human language, or robots that can generate realistic facial expressions and body language.

Examples of Generative AI in Industry Today

6-examples-of-generative-ai

Here are some specific examples of how generative AI is already being used in robotics today:

These are just a few examples of the many ways in which generative AI is being used to revolutionize the field of robotics. As generative AI technology continues to develop, we can expect to see even more innovative and exciting applications for robots in the years to come.

Keep building!