-
Notifications
You must be signed in to change notification settings - Fork 4
/
Makefile
100 lines (84 loc) · 2.39 KB
/
Makefile
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
# Run 'make help' in the terminal to see a list of script options
SHELL := /bin/bash
PACKAGE=swerve-sim-container
VERSION:=0.1.0
CONTAINER:=ghcr.io/freshrobotics/${PACKAGE}:${VERSION}
TARFILE:=${PACKAGE}-${VERSION}.tar
WORKSPACE=/workspace
XAUTH := /tmp/.docker.xauth
XAUTH_STRIP := xauth nlist :0 | sed -e 's/^..../ffff/' | xauth -f $(XAUTH) nmerge -
GPU_FLAGS := --gpus=all \
--env="NVIDIA_DRIVER_CAPABILITIES=all"
DOCKER_RUN = docker run --rm -it \
--network host \
--privileged \
--volume="/dev:/dev:rw" \
--env="DISPLAY=$(DISPLAY)" \
--env="QT_X11_NO_MITSHM=1" \
--env="XAUTHORITY=$(XAUTH)" \
--mount="type=bind,source="/tmp",target=/tmp:rw" \
--name $(PACKAGE)
.PHONY: help
help: ## show help message
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' ${MAKEFILE_LIST} | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
.PHONY: version
version: ## print the package version
@echo $(VERSION)
.PHONY: run
run: ## start container with shell
@xhost +local:root
@$(XAUTH_STRIP)
@$(DOCKER_RUN) \
$(CONTAINER) \
/bin/bash
@xhost -local:root
.PHONY: run-gpu
run-gpu: ## runs sim in container for systems with NVIDIA GPU
@xhost +local:root
@$(XAUTH_STRIP)
@$(DOCKER_RUN) \
$(GPU_FLAGS) \
$(CONTAINER) \
/bin/bash
@xhost -local:root
.PHONY: launch
launch: ## start container and launch ros bringup
@xhost +local:root
@$(XAUTH_STRIP)
$(DOCKER_RUN) \
$(CONTAINER) \
/bin/bash -ic \
"ros2 launch swerve_robot_gazebo sim.launch.py"
@xhost -local:root
.PHONY: launch-gpu
launch-gpu: ## start container and launch ros bringup
@xhost +local:root
@$(XAUTH_STRIP)
$(DOCKER_RUN) \
$(GPU_FLAGS) \
$(CONTAINER) \
/bin/bash -ic \
"ros2 launch swerve_robot_gazebo sim.launch.py"
@xhost -local:root
.PHONY: teleop-keyboard
teleop-keyboard: ## get (another) shell with teleop twist keyboard
docker exec -it ${PACKAGE} /bin/bash -ic \
"ros2 run teleop_twist_keyboard teleop_twist_keyboard"
.PHONY: teleop-joy
teleop-joy:
docker exec -it ${PACKAGE} /bin/bash -ic \
"ros2 launch swerve_robot_gazebo teleop_joy.launch.py"
.PHONY: stop
stop: ## stops running container
docker stop ${PACKAGE}
.PHONY: shell
shell: ## get (another) shell to running container
docker exec -it ${PACKAGE} /bin/bash
.PHONY: pull
pull: ## pulls the docker image from cloud package repo
docker pull $(CONTAINER)
.PHONY: build
build: ## builds the docker image
docker build \
--tag $(CONTAINER) \
.