ROS2 Notes
Packages
## General info
Container for installing/sharing code
Can have as many packages and types of packages as you want in a workspace. Usually in the
src folder
Can't have nested packages
Can make Python and CMake packages
## Creating a package
```
$ cd <workspace>/src
$ ros2 pkg create --build-type ament_python <package_name>
OR
$ ros2 pkg create --build-type ament_cmake <package_name>
```
## Dependencies
[Link]
```
<exec_depend>rclpy</exec_depend>
<exec_depend>std_msgs</exec_depend>
```
[Link]
```
entry_points={
}
```
## Launch files
run a single launch file to start up the entire system (nodes and configurations)
`ros2 launch`
Creating a launch file
```
$ mkdir launch
$ touch <your_launch>.py
Nodes
Node settings with integers, floats, booleans, strings, lists
Define parameters with command line commands or yaml files (can set multiple nodes)
`self.declare_parameter('my_param')`
`self.get_parameter('my_param')`
```
Topics
Lets nodes exchange messages through publisher and subscriber
Good for continuous updates
Parameters
Node settings with integers, floats, booleans, strings, lists
Define parameters with command line commands or yaml files (can set multiple nodes)
`self.declare_parameter('my_param')`
`self.get_parameter('my_param')`
Workspace
## `colcon build`
Arguments
* `--packages-up-to`
* `--symlink-install` don't need to rebuild every time you edit Python scripts
* `--event-handlers console_direct+` console output while building
Directories made after building
* build
* `install` setup files
* log
* src
## Overlays and underlays
Underlay: main ROS2 environment
Overlay: workspaces
## Sourcing the overlays
`$ source /[Link]/foxy/[Link]` source the underlay
Source
```
cd workspace
source install/local_setup.bash
```