1
- # This Makefile is used as a Docker container orchestration tool to deploy
2
- # various Docker Compose services that support GISNav.
3
- #
4
- # The terminology used in this Makefile includes the following:
5
- # - FMU: Flight Management Unit, the onboard flight controller computer
6
- # board (e.g., Pixhawk) that runs the autopilot software.
7
- # - HIL: Hardware-In-The-Loop, a simulation mode where the autopilot runs
8
- # onboard the FMU.
9
- # - SITL: Software-In-The-Loop, a simulation mode where the autopilot is
10
- # executed offboard on a separate computer, replicating the drone's
11
- # flight dynamics and sensors, enabling testing and development without
12
- # using actual hardware.
13
- # - Offboard: Refers to services that run on a computer not carried by the
14
- # drone and not powered by the drone battery (e.g., a powerful desktop).
15
- # - Onboard: Refers to services that run on the drone itself, powered by the
16
- # drone's battery, like the FMU and onboard companion computer (e.g.,
17
- # Nvidia Jetson Nano). In the case of GISNav, all onboard services are
18
- # intended to run on the companion computer and not e.g. on the FMU.
19
- # - Middleware: Software that sits between the autopilot and GISNav, enabling
20
- # communication between them.
21
- # - QGC: QGroundControl, a ground control station software used to monitor
22
- # and control drones.
23
- # - Gazebo: A robotics simulator used to simulate the drone's environment and
24
- # its interactions with the world.
25
- #
26
- # The target options in the Makefile are as follows:
27
- # - onboard-hil-*: Targets for onboard hardware-in-the-loop services,
28
- # including GIS server, ROS middleware, autoheal, and GISNav.
29
- # - onboard-sitl-*: Targets for onboard software-in-the-loop services, with
30
- # the same services as onboard HIL but using a different middleware
31
- # configuration.
32
- # - offboard-sitl-*: Targets for offboard software-in-the-loop services,
33
- # including Gazebo simulation and QGroundControl.
34
- # - offboard-sitl-test-*: Targets for SITL testing services, which exclude
35
- # GISNav and QGC for automated testing scenarios. Gazebo in headless mode.
36
- # - offboard-sitl-dev-*: Targets for SITL development services, including
37
- # Gazebo simulation, ROS middleware, mapserver, and QGC, but
38
- # excluding GISNav whose development version is assumed to be run locally.
39
- # - demo-*: Shortcut targets for demo purposes, setting up all SITL services
40
- # offboard, including GIS server, ROS middleware, Gazebo simulation, QGC,
41
- # and GISNav.
42
-
43
1
SHELL := /bin/bash
44
2
45
3
# Supported autopilots, must match docker/docker-compose.yaml service name
@@ -48,125 +6,6 @@ AUTOPILOTS := px4 ardupilot
48
6
# Prefix for Docker Compose service images
49
7
PROJECT_NAME := gisnav
50
8
51
- # Define a reusable template for creating Docker Compose targets
52
- # Parameters:
53
- # 1. The prefix for the target name.
54
- # 2. The dependency target.
55
- # 3. The optional Docker Compose override files to include (if any).
56
- # 4. The Docker Compose services to start or build - use $$* here for
57
- # autopilot, the first '$' is to escape the second '$'.
58
- define compose_template
59
-
60
- # Create phony create targets with the specified prefix for each autopilot
61
- .PHONY: $(addprefix create-$(1 ) -, $(AUTOPILOTS ) )
62
-
63
- # Generate rules for the build prefixed targets, depending on the specified build dependency target
64
- $(addprefix create-$(1 ) -, $(AUTOPILOTS ) ) : $(if $(2 ) ,create-$(1 ) -% : create-$(2 ) -% ,create-$(2 ) -% )
65
- # Evaluate the additional Docker Compose files
66
- $$(eval compose_files := $(if $(3 ) ,-f docker-compose.yaml $(foreach file,$(3 ) ,-f $(file ) ) ) )
67
- # Build the specified Docker Compose services and create the containers
68
- @docker compose -p $(PROJECT_NAME ) $$(compose_files ) create $(4 )
69
-
70
- # Create phony build targets with the specified prefix for each autopilot
71
- .PHONY: $(addprefix build-$(1 ) -, $(AUTOPILOTS ) )
72
-
73
- # Generate rules for the build prefixed targets, depending on the specified build dependency target
74
- $(addprefix build-$(1 ) -, $(AUTOPILOTS ) ) : $(if $(2 ) ,build-$(1 ) -% : build-$(2 ) -% ,build-$(2 ) -% )
75
- # Evaluate the additional Docker Compose files
76
- $$(eval compose_files := $(if $(3 ) ,-f docker-compose.yaml $(foreach file,$(3 ) ,-f $(file ) ) ) )
77
- # Build the specified Docker Compose services
78
- @docker compose -p $(PROJECT_NAME ) $$(compose_files ) build $(4 )
79
-
80
- # Create phony up targets with the specified prefix for each autopilot
81
- .PHONY: $(addprefix up-$(1 ) -, $(AUTOPILOTS ) )
82
-
83
- # Generate rules for the prefixed up targets, depending on the specified up
84
- # dependency target
85
- # IMPORTANT: Need to depend on create targets here before up targets to first
86
- # expose xhost to containers before running them
87
- $(addprefix up-$(1 ) -, $(AUTOPILOTS ) ) : $(if $(2 ) ,up-$(1 ) -% : create-$(1 ) -% expose-xhost up-$(2 ) -% ,up-$(1 ) -% : create-$(1 ) -% expose-xhost)
88
- # Evaluate the additional Docker Compose files
89
- $$(eval compose_files := $(if $(3 ) ,-f docker-compose.yaml $(foreach file,$(3 ) ,-f $(file ) ) ) )
90
- # Run Docker Compose with the specified services
91
- @docker compose -p $(PROJECT_NAME ) $$(compose_files ) up -d $(4 )
92
- endef
93
-
94
- # Define a reusable template for creating Docker Compose middleware targets
95
- #
96
- # Parameters:
97
- # 1. The prefix for the target name.
98
- # 2. The additional Docker Compose options, such as file overrides.
99
- define middleware_template
100
- .PHONY: up-$(1 ) -% build-$(1 ) -% create-$(1 ) -%
101
-
102
- up-$(1 ) -%:
103
- $$(call run_middleware, $(2 ) , up -d)
104
-
105
- build-$(1 ) -%:
106
- $$(call run_middleware, $(2 ) , build)
107
-
108
- create-$(1 ) -%:
109
- $$(call run_middleware, $(2 ) , create)
110
- endef
111
-
112
- # The run_middleware function is a helper function for executing middleware
113
- # targets with the necessary Docker Compose options.
114
- #
115
- # Parameters:
116
- # 1. Additional Docker Compose options, such as file overrides.
117
- # 2. The Docker Compose command to execute (either 'up -d' or 'build').
118
- define run_middleware
119
- @if [ "$* " = "px4" ]; then \
120
- docker compose -p $(PROJECT_NAME ) $(1 ) $(2 ) mavros; \
121
- elif [ "$* " = "ardupilot" ]; then \
122
- docker compose -p $(PROJECT_NAME ) $(1 ) $(2 ) mavros; \
123
- else \
124
- echo "Unsupported target '$* ' (try 'px4' or 'ardupilot')."; \
125
- fi
126
- endef
127
-
128
- # The empty argument check for some reason is not working in the compose_template.
129
- # So we will pass a dummy dependency as a dependency target instead of an empty
130
- # argument.
131
- .PHONY : $(addprefix build-dummy-dependency-, $(AUTOPILOTS ) )
132
- .PHONY : $(addprefix create-dummy-dependency-, $(AUTOPILOTS ) )
133
- .PHONY : $(addprefix up-dummy-dependency-, $(AUTOPILOTS ) )
134
-
135
- build-dummy-dependency-px4 :
136
-
137
- create-dummy-dependency-px4 :
138
-
139
- up-dummy-dependency-px4 :
140
-
141
- build-dummy-dependency-ardupilot :
142
-
143
- create-dummy-dependency-ardupilot :
144
-
145
- up-dummy-dependency-ardupilot :
146
-
147
- # Define middleware targets
148
- $(eval $(call middleware_template,onboard-hil-middleware,-f docker-compose.yaml -f docker-compose.serial.yaml))
149
- $(eval $(call middleware_template,onboard-sitl-middleware,))
150
- $(eval $(call middleware_template,offboard-sitl-middleware,)) # same as onboard
151
-
152
- # onboard HIL services: GIS server, ROS middleware, autoheal, gscam and GISNav
153
- $(eval $(call compose_template,onboard-hil,onboard-hil-middleware,docker-compose.arm64.yaml,mapserver autoheal gscam gisnav))
154
-
155
- # onboard SITL services: Same as with HIL but middleware is same as offboard (UDP, not serial)
156
- $(eval $(call compose_template,onboard-sitl,offboard-sitl-middleware,docker-compose.arm64.yaml,mapserver gscam gisnav))
157
-
158
- # offboard SITL services: Gazebo simulation, QGC
159
- $(eval $(call compose_template,offboard-sitl,dummy-dependency,,$$* qgc))
160
-
161
- # SITL testing services: Gazebo simulation, ROS middleware, mapserver, gscam, but excluding GISNav and QGC
162
- $(eval $(call compose_template,offboard-sitl-test,offboard-sitl-middleware,docker-compose.headless.yaml,$$* gscam mapserver))
163
-
164
- # SITL development services: Gazebo simulation, ROS middleware, mapserver, QGC, gscam rviz, but excluding GISNav
165
- $(eval $(call compose_template,offboard-sitl-dev,offboard-sitl-middleware,,$$* qgc gscam mapserver rviz))
166
-
167
- # All SITL services offboard: GIS server, ROS middleware, Gazebo simulation, QGC, gscam, gisnav
168
- $(eval $(call compose_template,demo,offboard-sitl-dev,,gisnav))
169
-
170
9
# List of Docker Compose service names that need GUI access
171
10
GUI_SERVICES = px4 ardupilot qgc rviz gisnav fileserver
172
11
@@ -182,48 +21,3 @@ expose-xhost:
182
21
fi ; \
183
22
done ; \
184
23
fi
185
-
186
-
187
- # shutdown any and all services (stop and remove containers)
188
- .PHONY : down
189
- down :
190
- @docker compose -p $(PROJECT_NAME ) down
191
-
192
- # start existing containers
193
- # Note: You should create the containers with the "make create-..." first,
194
- # otherwise you will get an error like "no container found for project "gisnav":
195
- # not found"
196
- .PHONY : start
197
- start :
198
- @docker compose -p $(PROJECT_NAME ) start
199
-
200
- # shutdown any and all services (stop but do not remove containers)
201
- .PHONY : stop
202
- stop :
203
- @docker compose -p $(PROJECT_NAME ) stop
204
-
205
- # build all services
206
- # Note: This builds many services with overlapping functionality such as px4 and
207
- # arudpilot, you may want to be more specific about what to build
208
- .PHONY : build
209
- build :
210
- @docker compose -p $(PROJECT_NAME ) build
211
-
212
- .PHONY : dev-nmea
213
- dev-nmea :
214
- @echo " Setting up NMEA output..."
215
- @socat pty,link=/tmp/gisnav-pty-link,raw,echo=0 tcp:localhost:15000 || echo " Could not establish serial-to-TCP bridge" &
216
- @sleep 3 # Give socat time to create the pty
217
- @echo PTS device created at: ` readlink /tmp/gisnav-pty-link`
218
- @ros2 launch gisnav local.launch.py protocol:=nmea port:=` readlink /tmp/gisnav-pty-link` baudrate:=9600
219
-
220
- .PHONY : dev-uorb
221
- dev-uorb :
222
- @ros2 launch gisnav local.launch.py protocol:=uorb
223
-
224
- # shortcut for demo
225
- .PHONY : demo
226
- demo :
227
- docker compose -p gisnav create gisnav
228
- $(MAKE ) expose-xhost
229
- docker compose -p gisnav up gisnav px4
0 commit comments