Skip to content

Workspace Setup

Benjamin Poulin edited this page Sep 17, 2022 · 5 revisions

Make sure you have ROS 2 installed on Ubuntu before continuing (Guide).

Create Workspace

Navigate to where you want your workspace directory. I have mine in ~/mate-rov/22-23. Run:

mkdir -p bootcamp_ws/src

Read more about ROS package naming conventions?

Clone Packages

Run:

cd bootcamp_ws/src
git clone https://github.com/cwruRobotics/rov-23-bootcamp.git .

Build Packages

Get back to your main workspace folder:

cd ..

It's best practice to check your dependencies before building:

sudo apt install python3-rosdep2
rosdep update
rosdep install -i --from-path src --rosdistro galactic -y

Build!

sudo apt install python3-colcon-common-extensions
colcon build --symlink-install

Learn ya some ROS

interfaces Package

The interfaces package contains service (srv) and message (msg) files, which describe data structures that may be published (messages) or sent/received as part of a service.

In a new terminal, navigate to your workspace folder by running cd bootcamp_ws. If you put your bootcamp_ws in some other directory, you'll need to type whatever path you chose instead of just bootcamp_ws.

Now source your workspace "overlay" with:

. install/setup.sh

View the descriptions of the interfaces:

ros2 interface show interfaces/msg/Num
ros2 interface show interfaces/msg/Sphere
ros2 interface show interfaces/srv/AddThreeInts

pubsub Package

The pubsub package contains a minimal publisher and subscriber to the topic topic.

In the same terminal where you sourced your workspace, start up the publisher:

ros2 run pubsub talker

Leave the talker running. In a new terminal, navigate to your workspace directory then source your overlay again:

. install/setup.sh

Then run the subscriber:

ros2 run pubsub listener

You should see the talker publishing sequential numbers and the listener receiving them.

service Package

The service package contains a minimal service server and client.

In the terminal where you ran the talker, press Ctrl+C to stop the talker. Then run the service server:

ros2 run service service

In the terminal where you ran the listener, press Ctrl+C to stop the listener. Then run the service client:

ros2 run service client 1 2 3

You should see a response from the server that sums 1, 2 & 3.

Next Steps

Explore? Read some code? Then: customize the example packages.