Skip to content

Commit 1481bed

Browse files
authored
Bump template (#11)
1 parent ee53d27 commit 1481bed

File tree

6 files changed

+70
-10
lines changed

6 files changed

+70
-10
lines changed

.cruft.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"template": "https://github.com/UrbanMachine/create-ros-app.git",
3-
"commit": "3d4731e5661e8cbac11d71c60c8e925a989c150c",
3+
"commit": "93e541631403e2c2c091c65d6583d61bd85a472c",
44
"checkout": null,
55
"context": {
66
"cookiecutter": {

docker-compose.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ services:
3838
DISPLAY: $DISPLAY
3939
# Necessary for PulseAudio passthrough
4040
PULSE_SERVER: "unix:/pulse-socket"
41+
# Enable serial passthrough
42+
privileged: true
4143
# Gives the container access to kernel capabilities, useful for most robots
4244
network_mode: host
4345
cap_add:

docker/_shared.sh

+23
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,27 @@ function deploy_and_wait {
7171
done
7272
echo "Another process brought down the stack." >&2
7373
return 1
74+
}
75+
76+
# Shows the user the available launch profiles
77+
function launch_profiles_helper_msg {
78+
echo "Available launch profiles are:" >&2
79+
# shellcheck disable=SC2012
80+
ls -1 launch-profiles/ | sed 's/^/ - /' >&2
81+
echo "" >&2
82+
echo "Read more about 'launch-profiles' under 'docs/about_template.md'" >&2
83+
exit 1
84+
}
85+
86+
# Inform the user that the chosen launch profile is invalid if it is not a directory
87+
function validate_launch_profile {
88+
local chosen_profile
89+
chosen_profile="$1"
90+
91+
# Check if the chosen profile is a directory under 'launch-profiles'
92+
if [[ ! -d "launch-profiles/${chosen_profile}" ]]; then
93+
echo "Error: '${chosen_profile}' is not a valid launch profile." >&2
94+
echo "It should be a directory under 'launch-profiles/'." >&2
95+
launch_profiles_helper_msg
96+
fi
7497
}

docker/launch

+4-9
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,11 @@ set -o errexit
2424
set -o pipefail
2525
set -o nounset
2626

27+
source docker/_shared.sh
28+
2729
function usage {
2830
echo "Usage: docker/launch [--no-pull] <launch-profile>" >&2
29-
echo "Available launch profiles are:" >&2
30-
# shellcheck disable=SC2012
31-
ls -1 launch-profiles/ | sed 's/^/ - /' >&2
32-
echo "" >&2
33-
echo "Read more about 'launch-profiles' under 'docs/about_template.md'" >&2
34-
exit 1
31+
launch_profiles_helper_msg
3532
}
3633

3734
function main {
@@ -64,9 +61,7 @@ function main {
6461
echo "Missing <launch_profile> argument, specify a directory under 'launch-profiles/'" >&2
6562
usage
6663
fi
67-
68-
source docker/_shared.sh
69-
64+
validate_launch_profile "${launch_profile}"
7065

7166
# To reduce downtime, build the latest images before stopping any existing stacks.
7267
if [[ "${pull_upstream_images}" = true ]]; then

docker/reload-ros-nodes

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/usr/bin/env bash
2+
3+
# Builds and re-runs the ROS nodes container. This is useful if you want to restart
4+
# the container over and over, oftentimes when developing on you ROS code.
5+
# The container is only re-run if the image has changed.
6+
#
7+
# Usage:
8+
# docker/reload-ros-nodes <launch-profile>
9+
#
10+
# Examples:
11+
# docker/reload-ros-nodes node_helpers_showcase
12+
13+
set -o errexit
14+
set -o pipefail
15+
set -o nounset
16+
17+
source docker/_shared.sh
18+
19+
function main {
20+
local launch_profile
21+
launch_profile="${1:-}"
22+
23+
if [[ -z "${launch_profile}" ]]; then
24+
echo "Missing <launch_profile> argument, specify a directory under 'launch-profiles/'" >&2
25+
echo "Usage: docker/reload-ros-nodes <launch-profile>" >&2
26+
launch_profiles_helper_msg
27+
fi
28+
validate_launch_profile "${launch_profile}"
29+
30+
build_images # Build any images that need to be built
31+
enable_display_passthrough # Enable passthrough for the stack
32+
33+
export LAUNCH_PROFILE="${launch_profile}"
34+
docker compose up -d --force-recreate ros-nodes
35+
}
36+
37+
main "${@}"

docs/about_template.md

+3
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ Here's a quick guide on the features of this template
3131

3232
# Enter a currently running ROS container to poke around
3333
docker/exec
34+
35+
# Rebuild and restart the ROS nodes in the container, useful for fast development
36+
docker/reload-ros-nodes
3437
```
3538

3639
More usage examples for the above scripts are documented at the top of the script files.

0 commit comments

Comments
 (0)