-
Notifications
You must be signed in to change notification settings - Fork 1
/
snapcraft_template.yaml.jinja2
341 lines (274 loc) · 12.3 KB
/
snapcraft_template.yaml.jinja2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
name: rosbot-xl
adopt-info: rosbot-xl
license: Apache-2.0
summary: A driver for ROSbot XL mobile robot
icon: snap/gui/rosbot-xl.png
description: |
The **rosbot-xl** snap includes all the essential software required to operate the ROSbot XL, including the controller, robot state publisher, and more.
**Installation**
To install this snap on the Single Board Computer (SBC) within the ROSbot XL chassis, follow these steps:
1. Connect the SBC to the Digital Board inside ROSbot XL using an Ethernet cable.
2. Configure the Ethernet Interface with the static IP address `192.168.77.2`.
3. Run the following command to install the snap:
snap install rosbot-xl
**Parameters**
The snap provides the following configurable parameters (`param name`: `default value`):
* `configuration`: `basic` - presets for ROSbot XL
* `driver`: `{...}`
* `ros`: `{...}`
* `webui`: `{...}`
The `configuration` key can be set to `basic` or `manipulation` (for ROSbot XL with OpenManipulator-X).
The `ros` contains the following keys:
* `ros.domain-id`: `0` - Sets the `ROS_DOMAIN_ID` environment variable for the ROS driver.
* `ros.localhost-only`: `0` - Sets the `ROS_LOCALHOST_ONLY` environment variable for the ROS driver.
* `ros.transport`: `udp` - Configures DDS transport. Options are `udp`, `shm`, `builtin` (or `rmw_fastrtps_cpp`), `rmw_cyclonedds_cpp`. Corresponding DDS XML files can be found in the `/var/snap/rosbot-xl/common` directory (custom FastDDS setups can also be created here).
* `ros.namespace`: `(unset)` - Namespace for all topics and transforms.
The `driver` contains the following keys:
* `driver.mecanum`: `True` - Enables the mecanum drive controller; otherwise, uses the differential drive controller.
* `driver.include-camera-mount`: `True` - Includes the camera mount in the robot URDF.
* `driver.camera-model`: `None` - Adds the camera model to the robot URDF.
* `driver.lidar-model`: `None` - Adds the LIDAR model to the robot URDF.
* `driver.db-serial-port`: `auto` - Serial port for firmware (e.g., `/dev/ttyUSB0`), or set it to `auto`.
* `driver.manipulator-serial-port`: `auto` - Serial port for OpenManipulator-X (e.g., `/dev/ttyUSB0`), or set it to `auto`.
The `webui` contains the following keys:
* `webui.layout`: `default` - Specifies the layout for the Web UI. Available `*.json` layout files can be found in the `/var/snap/rosbot-xl/common` directory (custom layouts can also be created here).
* `webui.port`: `8080` - Specifies the port for the built-in web server hosting the Web UI.
To set parameters, use the snap set command, e.g.,
snap set rosbot-xl driver.mecanum=True
**Available Apps (Main)**
* `rosbot-xl.flash` - Flash firmware for the STM32F4 microcontroller.
* `rosbot-xl.start` - Start the daemon running the ROSbot XL ROS 2 driver.
* `rosbot-xl.stop` - Stop the daemon running the ROSbot XL ROS 2 driver.
* `rosbot-xl.start-web-ui` - Start the daemon running the Web UI (available at `http://<ROBOT_IP>:8080/ui` by default).
* `rosbot-xl.stop-web-ui` - Stop the daemon running the Web UI.
* `rosbot-xl.teleop` - Run the `teleop_twist_keyboard` node to control the robot from a terminal.
**Auxiliary Apps**
* `rosbot-xl.config-ftdi` - Set up the CBUS pins in the FTDI chip (used with RST and BOOT0 pins in STM32); needs to be done only once.
* `rosbot-xl.print-serial-number` - Print the CPU ID and serial number of ROSbot XL.
* `rosbot-xl.reset-stm32` - Reset the STM32F4 microcontroller.
**Working with ROS Parameters**
For multiple snaps running ROS 2 or host-snap-Docker communication, useful files and scripts are available in `/var/snap/rosbot-xl/common/`.
Example usage:
# Set parameters in the rosbot-xl snap
sudo snap set rosbot-xl transport=udp ros-domain-id=123 ros.namespace=abc
# Mirror the setup for other ROS 2 snaps
sudo snap set husarion-depthai $(cat /var/snap/rosbot-xl/common/ros_snap_args)
...
# Set up the current shell with the same configurations
source /var/snap/rosbot-xl/common/ros.env
# Install configurations with
/var/snap/rosbot-xl/common/manage_ros_env.sh
source ~/.bashrc
ros2 run teleop_twist_keyboard teleop_twist_keyboard --ros-args --remap __ns:=/${ROS_NAMESPACE}
# Additional info:
# **Notes**
# * `rosbot-xl.daemon` runs as the `root` user. To enable shared-memory communication (`ros-localhost-only=1` or `transport` set to `shm` or `builtin`), ensure the user on the host (or in Docker) is also `root`.
# * To run the ROS 2 driver in the current terminal session (and enable shared memory communication with a non-root user):
# sudo rosbot-xl.stop
# rosbot-xl
# * Display logs from the ROS 2 node with:
# sudo snap logs rosbot-xl.daemon
# * Display logs from the snap logger with:
# journalctl -t rosbot-xl
# * `rosbot-xl` snap by default uses the following ports: `3000` by the safe-shutdown service, `8888` by microROS Agent, `8080` by a Web UI.
grade: stable
confinement: strict
base: {{ 'core22' if ros_distro == 'humble' else 'core24' }}
contact: https://github.com/husarion/rosbot-xl-snap/issues
issues: https://github.com/husarion/rosbot-xl-snap/issues
website: https://husarion.com/manuals/rosbot-xl/overview/
slots:
shm-slot:
interface: shared-memory
write: ['*'] # paths are relative to /dev/shm
plugs:
shm-plug:
interface: shared-memory
shared-memory: shm-slot
private: false
apps:
daemon:
command: usr/bin/launcher.sh
command-chain: [usr/bin/ros_setup.sh]
daemon: simple
install-mode: enable
plugs: [network, network-bind, shm-plug, raw-usb]
slots: [shm-slot]
extensions: [ros2-{{ ros_distro }}-ros-base]
db-server:
command: usr/bin/db_server_launcher.sh
daemon: simple
install-mode: enable
plugs: [network, network-bind, shutdown]
rosbot-xl:
command: usr/bin/launcher.sh
command-chain: [usr/bin/check_daemon_running.sh, usr/bin/ros_setup.sh]
plugs: [network, network-bind, shm-plug, raw-usb]
slots: [shm-slot]
extensions: [ros2-{{ ros_distro }}-ros-base]
flash:
command: usr/bin/flash_launcher.sh
plugs: [raw-usb, network-bind]
extensions: [ros2-{{ ros_distro }}-ros-base]
teleop:
command: usr/bin/teleop_launcher.sh
command-chain: [usr/bin/ros_setup.sh]
plugs: [network, network-bind, shm-plug]
slots: [shm-slot]
extensions: [ros2-{{ ros_distro }}-ros-base]
joy:
command: usr/bin/joy_launcher.sh
command-chain: [usr/bin/ros_setup.sh]
daemon: simple
install-mode: enable
environment:
LD_LIBRARY_PATH: "$SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/pulseaudio:$LD_LIBRARY_PATH"
plugs: [hardware-observe, joystick, network, network-bind, shm-plug]
slots: [shm-slot]
extensions: [ros2-{{ ros_distro }}-ros-base]
arm-activate:
command: usr/bin/arm_activate_launcher.sh active
command-chain: [usr/bin/ros_setup.sh]
plugs: [network, network-bind, shm-plug]
slots: [shm-slot]
extensions: [ros2-{{ ros_distro }}-ros-base]
arm-disactivate:
command: usr/bin/arm_activate_launcher.sh inactive
command-chain: [usr/bin/ros_setup.sh]
plugs: [network, network-bind, shm-plug]
slots: [shm-slot]
extensions: [ros2-{{ ros_distro }}-ros-base]
print-serial-number:
command: usr/bin/serial_number_launcher.sh
command-chain: [usr/bin/ros_setup.sh]
plugs: [network, network-bind, shm-plug]
slots: [shm-slot]
extensions: [ros2-{{ ros_distro }}-ros-base]
start:
command: usr/bin/start_launcher.sh
stop:
command: usr/bin/stop_launcher.sh
restart:
command: usr/bin/restart_launcher.sh
reset-stm32:
command: usr/bin/reset_stm32_launcher.sh
plugs: [raw-usb, network-bind]
config-ftdi:
command: usr/bin/ftdi_eeprom_conf_launcher.sh
plugs: [raw-usb, network-bind]
parts:
# rosbot-xl:
# plugin: colcon
# source: https://github.com/husarion/rosbot_xl_ros.git
# source-branch: "0.11.5"
# build-packages:
# - python3-vcstool
# stage-packages:
# - stm32flash
# - libusb-1.0-0
# - usbutils
# - ros-{{ ros_distro }}-rmw-cyclonedds-cpp
# override-pull: |
# craftctl default
# vcs import $CRAFT_PART_SRC < $CRAFT_PART_SRC/rosbot_xl/rosbot_xl_hardware.repos
# cp -r $CRAFT_PART_SRC/ros2_controllers/diff_drive_controller $CRAFT_PART_SRC/
# cp -r $CRAFT_PART_SRC/ros2_controllers/imu_sensor_broadcaster $CRAFT_PART_SRC/
# rm -rf $CRAFT_PART_SRC/ros2_controllers
# rm -r $CRAFT_PART_SRC/rosbot_xl_gazebo
# # Ignore so that rosdep doesn't pull deps
# # and colcon doesn't build
# # touch $CRAFT_PART_SRC/rosbot_xl_gazebo/COLCON_IGNORE
# # Set the snap version from the git tag
# # The grade is set to 'stable' if the latest entry in the git history
# # is the tag itself, otherwise set to devel
# version="$(git describe --always --tags| sed -e 's/^v//;s/-/+git/;y/-/./')"
# [ -n "$(echo $version | grep "+git")" ] && grade=devel || grade=stable
# craftctl set version="$version"
# craftctl set grade="$grade"
rosbot-xl:
plugin: colcon
source: https://github.com/husarion/rosbot_xl_manipulation_ros.git
source-branch: "1.1.2"
build-packages:
- python3-vcstool
- python3-ftdi
stage-packages:
- stm32flash
- libusb-1.0-0
- usbutils
- python3-ftdi
- ros-{{ ros_distro }}-rmw-cyclonedds-cpp
override-pull: |
craftctl default
vcs import $CRAFT_PART_SRC < $CRAFT_PART_SRC/rosbot_xl_manipulation/rosbot_xl_manipulation.repos
vcs import $CRAFT_PART_SRC < $CRAFT_PART_SRC/rosbot_xl_ros/rosbot_xl/rosbot_xl_hardware.repos
vcs import $CRAFT_PART_SRC < $CRAFT_PART_SRC/open_manipulator_x/open_manipulator_x.repos
cp -r $CRAFT_PART_SRC/ros2_controllers/diff_drive_controller $CRAFT_PART_SRC/
cp -r $CRAFT_PART_SRC/ros2_controllers/imu_sensor_broadcaster $CRAFT_PART_SRC/
rm -rf $CRAFT_PART_SRC/ros2_controllers
rm -r $CRAFT_PART_SRC/rosbot_xl_ros/rosbot_xl_gazebo
rm -r $CRAFT_PART_SRC/rosbot_xl_manipulation_gazebo
# Ignore so that rosdep doesn't pull deps
# and colcon doesn't build
# touch $CRAFT_PART_SRC/rosbot_xl_gazebo/COLCON_IGNORE
# Set the snap version from the git tag
# The grade is set to 'stable' if the latest entry in the git history
# is the tag itself, otherwise set to devel
version="$(git describe --always --tags| sed -e 's/^v//;s/-/+git/;y/-/./')"
[ -n "$(echo $version | grep "+git")" ] && grade=devel || grade=stable
craftctl set version="$version"
craftctl set grade="$grade"
teleop:
plugin: nil
stage-packages:
- ros-{{ ros_distro }}-teleop-twist-keyboard
# - ros-{{ ros_distro }}-teleop-twist-joy # 2024-09-13: in apt repository is 2.6.0 version, and stamped messages were introduced in 2.6.1 (https://github.com/ros2/teleop_twist_joy)
# after version 2.6.1+ will be available in apt repository, remove it:
teleop-twist-joy:
plugin: colcon
source: https://github.com/ros2/teleop_twist_joy.git
stage:
- "-opt/ros/snap/local_setup.sh"
- "-opt/ros/snap/setup.bash"
- "-opt/ros/snap/setup.ps1"
- "-opt/ros/snap/setup.sh"
- "-opt/ros/snap/setup.zsh"
db-server:
plugin: nil
stage-packages:
- dbus
- curl
- netcat
husarion-snap-common:
plugin: dump
source: https://github.com/husarion/husarion-snap-common
source-branch: "0.5.0"
source-type: git
build-environment:
- YQ_VERSION: "v4.35.1"
build-packages:
- curl
organize:
'local-ros/*.sh': usr/bin/
'local-ros/*.xml': usr/share/husarion-snap-common/config/
'local-ros/ros.env': usr/share/husarion-snap-common/config/
override-build: |
craftctl default
curl -L "https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/yq_linux_${CRAFT_ARCH_BUILD_FOR}" -o $CRAFT_PART_BUILD/yq
override-prime: |
craftctl default
cp $CRAFT_PART_BUILD/yq $CRAFT_PRIME/usr/bin/yq
chmod +x $CRAFT_PRIME/usr/bin/yq
rm -rf $CRAFT_PRIME/local-ros
stage:
- "-usr/bin/start_launcher.sh"
- "-usr/bin/stop_launcher.sh"
- "-usr/bin/restart_launcher.sh"
local-files:
plugin: dump
source: snap/local/
organize:
'*.sh': usr/bin/
'*.py': usr/bin/
'*.yaml': usr/share/rosbot-xl/config/
'*.xml': usr/share/rosbot-xl/config/