Skip to content

Commit b88b663

Browse files
committed
updated: ROS2 mixin docs
1 parent 099687e commit b88b663

File tree

2 files changed

+45
-16
lines changed

2 files changed

+45
-16
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,17 @@
11
---
2-
title: workspace profiles
3-
pagination_label: ROS2 workspace profiles
2+
title: Mixin AKA Workspace Profiles
3+
pagination_label: ROS2 workspace profiles mixin
44
description: ROS2 workspace profiles
55
---
66

77
# ROS2 workspace profiles
88

99
## Setting work-space wide configurations
1010

11-
Create a file `colcon_defaults.yaml` in the workspace's root.
12-
Build parameters can be set, e.g., for limiting the number of build threads:
13-
14-
```yaml
15-
build:
16-
parallel-workers: 8
17-
```
18-
1911
## Mixin
12+
A `mixin` is a tag given to a set of parameters that you may want to pass to `colcon` during build (maybe used with other `colcon` commands).
2013

21-
**"Manually adding arguments but with extra steps"**
22-
14+
### Adding Mixins to `colcon`
2315
Add the official mixin repository:
2416
```bash
2517
colcon mixin add default https://raw.githubusercontent.com/colcon/colcon-mixin-repository/master/index.yaml
@@ -40,11 +32,48 @@ Build with particular mixin:
4032
colcon build --mixin rel-with-deb-info
4133
```
4234

43-
Use mixins automatically: Use the `colcon_defaults.yaml` file:
35+
### Adding a custom Mixins
36+
- Make a `build_types.mixin` file that defines custom mixins(`JSON` format)
37+
```json
38+
{
39+
"build": {
40+
"debug": {
41+
"cmake-args": ["-DCMAKE_BUILD_TYPE=Debug",
42+
"-DCMAKE_EXPORT_COMPILE_COMMANDS=ON",
43+
"-DCMAKE_CXX_FLAGS='-std=c++17 -Og'",
44+
"-DCMAKE_C_FLAGS='-Og'"]
45+
},
46+
"rel-with-deb-info": {
47+
"cmake-args": ["-DCMAKE_BUILD_TYPE=RelWithDebInfo",
48+
"-DCMAKE_EXPORT_COMPILE_COMMANDS=ON",
49+
"-DCMAKE_CXX_FLAGS='-std=c++17'"]
50+
},
51+
"release": {
52+
"cmake-args": ["-DCMAKE_BUILD_TYPE=Release",
53+
"-DCMAKE_EXPORT_COMPILE_COMMANDS=ON",
54+
"-DCMAKE_CXX_FLAGS='-std=c++17'"]
55+
}
56+
}
57+
}
58+
```
59+
- Make an `index.yaml` file for `colcon mixin` to find all the defined mixins
60+
```bash
61+
mixin:
62+
- build_types.mixin
63+
```
64+
- Add the file to the mixin repository and update the mixins:
65+
```bash
66+
colcon mixin add mrs file://<path-to-directory-with-mixin-index-file>/index.yaml
67+
colcon mixin update mrs
68+
```
69+
Add these lines to your `.zshrc` or `.bashrc` to automatically access the mixins with each new shell.
4470

71+
## Using Mixins for build
72+
- `colcon` uses configuration files for building, testing and installing packages. It's good practice to have a `colcon_defaults.yaml` in the root of your ROS2 workspace.
73+
- The file can have different parameters as described at https://colcon.readthedocs.io/en/released/reference/verb/build.html. For eg. using a particular mixin and limiting the threads during build would look like
4574
```yaml
4675
build:
76+
parallel-workers: 8
4777
mixin:
4878
- rel-with-deb-info
49-
- compile-commands
50-
```
79+
```

docs/10-prerequisities/25-ros2/index.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: ROS
2+
title: ROS2
33
pagination_label: Robot Operating System
44
description: Robot Operating System
55
---

0 commit comments

Comments
 (0)