Material for the ros2 crash course

Overview

ROS2 Crash course

Task 1 Create your new workspace

mkdir -p /home/usr/ros2/workspaces/ros2_crash_ws/src
cd /home/usr/ros2/workspaces/ros2_crash_ws/src

Task 2 Get teleop ros package and modify it

1) Clone the ros package repo
	cd /home/usr/ros2/workspaces/ros2_crash_ws/src/
	git clone [email protected]:ros2/teleop_twist_keyboard.git
	source /opt/ros/foxy/setup.bash
2) Compile the workspace
	cd /home/usr/ros2/workspaces/ros2_crash_ws/
	colcon build
3) Run the binary teleop_twist_keyboard.py and play with it! 
	ros2 run teleop_twist_keyboard teleop_twist_keyboard

Q1: How can we test our program? Hint: ros topics!

4) Add a customized print message in the file teleop_twist_keyboard.py and run it again

Q2: What happened? Hint: underlay vs overlay

5) Modify the binary teleop_twist_keyboard.py to generate the following motions:

	Linear motions: 

	u: left-front
	i: front
	o: right-front
	j: left
	k: stop
	l: right
	m: left-back
	,: back
	.: right-back

	Angular Motions:
	w: counter-clockwise
	e: stop
	r: clock-wise

	Speed:

	+ increase linear speed +0.1
	- decrease linear speed -0.1
	* increase angular speed +0.1
	/ decrease angular speed -0.1

6) Test your new binary
	Open a new terminal and source your workspace
	cd /home/usr/ros2/workspaces/ros2_crash_ws/
	source install/setup.bash
	ros2 run teleop_twist_keyboard teleop_twist_keyboard --ros-args --remap /cmd_vel:=turtle_twist

Q3: Does it work?

Task 3 Create a new ros2 cpp package named "turtle_msg"

1) Use the ros2 create package function 
	cd /home/usr/ros2/workspaces/ros2_crash_ws/src
	ros2 pkg create --build-type ament_cmake turtle_msgs
2) Compile the workspace
	colcon build --symlink-install --merge-install --cmake-args -DCMAKE_EXPORT_COMPILE_COMMANDS=1

Q4: Any problems? Do you notice any difference with the additional compiling arguments?

3) Add msg/TurtleState.msg and modify CMakeLists.txt, package.xml
4) Compile your workspace
5) Verify that your new message has been created, using ros2 interface.

Q5: Can you find your new message? Hint: overlay

Task 4 Create a new ros2 cpp package "turtle_ctrl"

1) Use the ros2 create package function 
	cd /home/dean/ros2/workspaces/ros2_crash_ws/src
	ros2 pkg create --build-type ament_cmake turtle_ctrl
2) Compile your workspace
3) Copy the TurtleVis class files TurtleVis.h and TurtleVis.cpp to their corresponding folders
4) Modify the CMakeFile to create a shared library with the TurtleVis class
5) Copy the application file turtle_vis.cpp
6) Modify the CMakeFile to create a new binary (Exec)
7) Compile your workspace (or single ros package)
8) Copy the file "turtle.rviz" into turtle_ctr/rviz/turtle.rviz
9) Test your application. You will need 3 terminals
	T1) Run the turtle visualization 
		ros2 run turtle_ctrl turtle_vis
	T2) Run rviz
		ros2 run rviz2 rviz2 -d src/turtle_ctrl/rviz/turtle.rvi
	T3) Publish a TurtleState message and check the rviz window
		ros2 topic pub --rate 1 /turtle_pose turtle_msgs/msg/TurtleStateStamped "{pose: {x: 1, y: 1, theta: 0}}"

Q6: What can you see?

Task 5 Let's create a lunch file to automate the above process

1) Copy the file "turtle_vis_test_launch.py" into the folder turtle_ctrl/launch/
2) Run the new launch file
	ros2 launch turtle_ctrl turtle_vis_test_launch.py

Q7: Does it work? What happened?

Task 6 Create the controller

1) Copy the class files  TurtleCtrl.cpp and TurtleCtrl.h to its corresponding folders
2) Modify the CMakeFile to create a shared library with the control class
3) Copy the application file turtle_control.cpp
4) Modify the CMakeFile to create a new binary (Exec)
5) Compile your workspace (or single ros package) 
6) Test your application
	T1) Copy the launch file turtle_vis_test_launch.py and renamed as turtle_test_launch.py
		Modify the new launch file to include the control node

Q8: How can you test your application?

Task 7 Trajectory generator

We will implement two methods to generate the commanded turtle pose for the controller.
First, transform the Twist (turtle velocity) message generated from the node teleop_twist_keyboard to continuous 
commanded turtle poses. 
Second, we will create a node that provides a service to request a desired turtle pose. This node will use the
requested turtle pose and generate a continuous smooth trajectory for the commanded turtle pose. 
The output of both nodes is a TurtleStateStamped message, which is connected to the controller to change the 
pose of the turtle
1) Create a new ros python package "turtle_trajectory_generator"
	ros2 pkg create --build-type ament_python turtle_trajectory_generator
2) Fix the ros package configuration files to use the new package, e.g. package.xml, resource, setup.py, etc.
3) Copy the file teleop_twist_keyboard.py from the ros package teleop_twist_keyboard to this new package
4) Compile the workspace. This is needed to create the symbolic links to the python files. 
	colcon build --symlink-install --merge-install --cmake-args -DCMAKE_EXPORT_COMPILE_COMMANDS=1
5) Create the trajectory generator module. Use the file trajectory_generator_class.py 
6) Compile again the workspace
7) Create the application nodes
	a) applications/poly_trajectories.py: Generates the smooth trajectory for the commanded turtle pose (TurtleStateStamped message)
	b) applications/twist2cmd.py: Converts from Twist message to commanded turtle pose (TurtleStateStamped message)
8) Compile your workspace 
7) Test your applications

Q9: How can you test the trajectory generator nodes only? Hint: ros2 run rqt_plot rqt_plot Q9: Does it work? Hint: did you configure your setup.py file?

Running Demo

Turtle Ctrl + Vis

T1) cd /home/dean/ros2/workspaces/ros2_crash_ws/

source install/setup.bash

ros2 launch turtle_ctrl turtle_test_launch.py

T2) ros2 topic pub --rate 1 /turtle_pose turtle_msgs/msg/TurtleStateStamped "{pose: {x: 0, y: 1, theta: 0}}"

Turtle Trajectory + Ctrl + Vis

ros2 launch turtle_ctrl turtle_test_launch.py

Keyboard commands (Velocity reference)

T1) ros2 run turtle_trajectory_generator twist2cmd

T2) ros2 run turtle_trajectory_generator teleop_twist_keyboard --ros-args --remap /cmd_vel:=turtle_twist

Spline (Smooth Position Commands)

T1) ros2 run turtle_trajectory_generator poly_trajectory

T2) ros2 service call /set_desired_pose turtle_msgs/srv/SetDesiredPose "{ turtle_d:{x: 1, y: 0, theta: 0}, time: 1}"

Owner
Emmanuel Dean
Emmanuel Dean
My solutions to the Advent of Code 2021 problems in Go and Python 🎄

🎄 Advent of Code 2021 🎄 Summary Advent of Code is an annual Advent calendar of programming puzzles. This year I am doing it in Go and Python. Runnin

Orfeas Antoniou 16 Jun 16, 2022
The blazing-fast Discord bot.

Wavy Wavy is an open-source multipurpose Discord bot built with pycord. Wavy is still in development, so use it at your own risk. Tools and services u

Wavy 7 Dec 27, 2022
Run `black` on python code blocks in documentation files

blacken-docs Run black on python code blocks in documentation files. install pip install blacken-docs usage blacken-docs provides a single executable

Anthony Sottile 460 Dec 23, 2022
Convenient tools for using Swagger to define and validate your interfaces in a Pyramid webapp.

Convenient tools for using Swagger to define and validate your interfaces in a Pyramid webapp.

Scott Triglia 64 Sep 18, 2022
Generate YARA rules for OOXML documents using ZIP local header metadata.

apooxml Generate YARA rules for OOXML documents using ZIP local header metadata. To learn more about this tool and the methodology behind it, check ou

MANDIANT 34 Jan 26, 2022
Ultimaker Cura 2 Mooraker Upload Plugin

Klipper & Cura - Cura2MoonrakerPlugin Allows you to upload Gcode directly from Cura to your Klipper-based 3D printer (Fluidd, Mainsailos etc.) using t

214 Jan 03, 2023
BakTst_Org is a backtesting system for quantitative transactions.

BakTst_Org 中文reademe:传送门 Introduction: BakTst_Org is a prototype of the backtesting system used for BTC quantitative trading. This readme is mainly di

18 May 08, 2021
Documentation generator for C++ based on Doxygen and mosra/m.css.

mosra/m.css is a Doxygen-based documentation generator that significantly improves on Doxygen's default output by controlling some of Doxygen's more unruly options, supplying it's own slick HTML+CSS

Mark Gillard 109 Dec 07, 2022
This is a repository for "100 days of code challenge" projects. You can reach all projects from beginner to professional which are written in Python.

100 Days of Code It's a challenge that aims to gain code practice and enhance programming knowledge. Day #1 Create a Band Name Generator It's actually

SelenNB 2 May 12, 2022
🐱‍🏍 A curated list of awesome things related to Hugo themes.

awesome-hugo-themes Automated deployment @ 2021-10-12 06:24:07 Asia/Shanghai &sorted=updated Theme Author License GitHub Stars Updated Blonde wamo MIT

13 Dec 12, 2022
Python Eacc is a minimalist but flexible Lexer/Parser tool in Python.

Python Eacc is a parsing tool it implements a flexible lexer and a straightforward approach to analyze documents.

Iury de oliveira gomes figueiredo 60 Nov 16, 2022
Use Brainf*ck with python!

Brainfudge Run Brainf*ck code with python! Classes Interpreter(array_len): encapsulate all functions into class __init__(self, array_len: int=30000) -

1 Dec 14, 2021
Convert excel xlsx file's table to csv file, A GUI application on top of python/pyqt and other opensource softwares.

Convert excel xlsx file's table to csv file, A GUI application on top of python/pyqt and other opensource softwares.

David A 0 Jan 20, 2022
Parser manager for parsing DOC, DOCX, PDF or HTML files

Parser manager Description Parser gets PDF, DOC, DOCX or HTML file via API and saves parsed data to the database. Implemented in Ruby 3.0.1 using Acti

Эдем 4 Dec 04, 2021
Visualizacao-dados-dell - Repositório com as atividades desenvolvidas no curso de Visualização de Dados

📚 Descrição Neste curso da Dell trabalhamos com a visualização de dados. 🖥️ Aulas 1.1 - Explorando conjuntos de dados 1.2 - Fundamentos de visualiza

Claudia dos Anjos 1 Dec 28, 2021
Numpy's Sphinx extensions

numpydoc -- Numpy's Sphinx extensions This package provides the numpydoc Sphinx extension for handling docstrings formatted according to the NumPy doc

NumPy 234 Dec 26, 2022
An introduction course for Python provided by VetsInTech

Introduction to Python This is an introduction course for Python provided by VetsInTech. For every "boot camp", there usually is a pre-req, but becaus

Vets In Tech 2 Dec 02, 2021
Explicit, strict and automatic project version management based on semantic versioning.

Explicit, strict and automatic project version management based on semantic versioning. Getting started End users Semantic versioning Project version

Dmytro Striletskyi 6 Jan 25, 2022
A module filled with many useful functions and modules in various subjects.

Usefulpy Check out the Usefulpy site Usefulpy site is not always up to date Download and Import download and install with with pip download usefulpyth

Austin Garcia 1 Dec 28, 2021
Sphinx Bootstrap Theme

Sphinx Bootstrap Theme This Sphinx theme integrates the Bootstrap CSS / JavaScript framework with various layout options, hierarchical menu navigation

Ryan Roemer 584 Nov 16, 2022