Commit eae76d0
committed
Merge branch 'develop-ros-logic' into develop. Close #244.
**Description**
The current ROS backend is overly specific, complex and composes data
manually. For example, it assumes a specific structure for the message
handlers. It also extracts data from data structures, manually converts
it to strings, and then packs it into a JSON structure.
This limits user's abilities to adjust the template to fit their needs,
since most of the data is given as fixed strings (e.g., variable
declarations are given as multiple lines, rather than letting users
access each variable declaration and, within them, each type and name
individually.
It would be better to make more raw data available to the template, and
have the template present the data as needed. That would likely also
decrease the differences across backends, making the code easier to
maintain.
**Type**
- Feature: Make backend more versatile.
**Additional context**
None.
**Requester**
- Ivan Perez.
**Method to check presence of bug**
Not applicable (not a bug).
**Expected result**
The ROS template has raw structured data available about the different
portions of the application, and can be adjusted to present it as
needed.
The following Dockerfile checks that generating a ROS 2 application with
and without the feature proposed renders the same result, after which it
prints the message "Success". It requires an additional BASE_COMMIT
variable pointing to a commit prior to merging this feature.
```
FROM ubuntu:focal
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update
RUN apt-get install --yes \
curl g++ gcc git libgmp3-dev libz-dev make pkg-config
RUN mkdir -p $HOME/.local/bin
ENV PATH=$PATH:/root/.local/bin/
RUN curl https://downloads.haskell.org/~ghcup/0.1.17.7/x86_64-linux-ghcup-0.1.17.7 -o $HOME/.local/bin/ghcup
RUN chmod a+x $HOME/.local/bin/ghcup
ENV PATH=$PATH:/root/.ghcup/bin/
RUN ghcup install ghc 9.10
RUN ghcup install cabal 3.12
RUN ghcup set ghc 9.10.1
RUN cabal update
SHELL ["/bin/bash", "-c"]
CMD git clone $REPO \
&& cd $NAME \
&& git checkout $BASE_COMMIT \
&& cabal install ogma-cli:ogma \
&& ogma ros --app-target-dir original --variable-file ogma-cli/examples/ros-copilot/variables --variable-db ogma-cli/examples/ros-copilot/vars-db --handlers-file ogma-cli/examples/ros-copilot/handlers \
&& git checkout $COMMIT \
&& cabal install --overwrite-policy=always ogma-cli:ogma \
&& ogma ros --app-target-dir updated --variable-file ogma-cli/examples/ros-copilot/variables --variable-db ogma-cli/examples/ros-copilot/vars-db --handlers-file ogma-cli/examples/ros-copilot/handlers \
&& diff -rq original updated \
&& echo "Success"
```
Command (substitute variables based on new path after merge):
```sh
$ docker run -e "REPO=https://github.com/NASA/ogma" -e "NAME=ogma" -e "BASE_COMMIT=02e2a4c1439279b700699923c351dac39527e2b5" -e "COMMIT=<HASH>" -it ogma-verify-244
```
**Solution implemented**
Modify ROS backend to leverage `aeson` capabilities to make a data
structure available to the ROS template, and move as much as possible of
the current logic in the ROS backend directly to the template.
**Further notes**
This situation also affects other backends. We limit this issue to the
ROS backend to make the work smaller, easier to complete, and to reduce
risk.File tree
6 files changed
+136
-347
lines changed- ogma-cli
- ogma-core
- src/Command
- templates/ros/copilot/src
6 files changed
+136
-347
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
355 | 355 | | |
356 | 356 | | |
357 | 357 | | |
358 | | - | |
359 | | - | |
360 | | - | |
361 | | - | |
362 | | - | |
363 | | - | |
364 | | - | |
365 | | - | |
366 | | - | |
367 | | - | |
368 | | - | |
369 | | - | |
370 | | - | |
371 | | - | |
372 | | - | |
373 | | - | |
374 | | - | |
375 | | - | |
376 | | - | |
377 | | - | |
378 | | - | |
379 | | - | |
380 | | - | |
381 | | - | |
382 | | - | |
383 | | - | |
384 | | - | |
385 | | - | |
386 | | - | |
387 | | - | |
388 | | - | |
389 | | - | |
390 | | - | |
391 | | - | |
392 | | - | |
393 | | - | |
394 | | - | |
395 | | - | |
396 | | - | |
397 | | - | |
398 | | - | |
399 | | - | |
400 | | - | |
401 | | - | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
402 | 369 | | |
403 | 370 | | |
404 | 371 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
| |||
0 commit comments