Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ogma-cli: Allow customizing the ROS application template. Refs #162. #163

Merged
merged 9 commits into from
Nov 21, 2024

Conversation

ivanperez-keera
Copy link
Member

Adjust ogma-cli and ogma-core to allow customizing the ROS application by using custom-provided templates, as prescribed in the solution proposed for #162.

The ROS backend used a fixed template to generate the ROS package. That
template does not fit all use cases, and users are heavily modifying the
output (which is hard to keep up with when there are changes), and or
not using ogma altogether for that reason. To make it possible for users
to customize the ROS output, we want to support using mustache templates
for ROS packages, like we did with the cFS backend.

This commit copies the functionality of template generation and
expansion using mustache from ogma-core's cFS backend to ogma-extra.
…end. Refs nasa#162.

The ROS backend used a fixed template to generate the ROS package. That
template does not fit all use cases, and users are heavily modifying the
output (which is hard to keep up with when there are changes), and or
not using ogma altogether for that reason. To make it possible for users
to customize the ROS output, we want to support using mustache templates
for ROS packages, like we did with the cFS backend.

A prior commit has copied the functionality of template generation and
expansion using mustache from ogma-core's cFS backend to ogma-extra.
This commit makes the cFS backend depend on that feature on ogma-extra,
to avoid duplication.
… Refs nasa#162.

The ROS package generation backend has a fixed template that it uses to
generate the ROS nodes. That template does not fit all use cases, so we
are finding users heavily modifying the output (which is hard to keep up
with when there are changes), and or not using ogma altogether for that
reason.

This commit modifies the ogma-core ros command to use mustache to
generate the ROS monitoring package via a template and variable
expansion. We adapt the template to also use those variables, and we
modify the cabal file to include the new files as data files that are
copied over during installation.
…ation. Refs nasa#162.

The ROS package generation backend has a fixed template that it uses to
generate the ROS package. That template does not fit all use cases, so
we are finding users heavily modifying the output (which is hard to keep
up with when there are changes), and or not using ogma altogether for
that reason.

A recent commit introduced the ability to use mustache to expand
variables in a template. This commit modifies the ros command to accept
an additional argument that points to a user-provided directory with a
custom template.
…irectory to ROS app command. Refs nasa#162.

The ROS package generation backend has a fixed template that it uses to
generate the ROS package. That template does not fit all use cases, so
we are finding users heavily modifying the output (which is hard to keep
up with when there are changes), and or not using ogma altogether for
that reason.

A recent commit introduced into ogma-core the ability to use a custom
provided template and expand variables using mustache.

This commit exposes that new parameter to the user in the CLI.
…n. Refs nasa#162.

The ROS package generation backend used a fixed template to generate the
ROS package. That template did not fit all use cases, and users are
modifying the output (which is hard to keep up with when there are
changes), and or not using ogma altogether for that reason.

Prior commits have expanded the command to allow for customization of
the template using a user-provided directory and expanding variables in
the template using mustache.

This commit documents the new feature in the README.
@ivanperez-keera
Copy link
Member Author

Change Manager: Verified that:

  • Solution is implemented:
    • The code proposed compiles and passes all tests. Details:
    • The solution proposed produces the expected result. Details:
      The following dockerfile generates the ROS package using the default template and using a copy and the default template and checks that both are the same. It then adds a file to the copy of the template and checks that the file is copied to the target directory when the custom template is used, after which it prints the message "Success".
      FROM ubuntu:trusty
      
      ENV DEBIAN_FRONTEND=noninteractive
      
      RUN apt-get update
      
      RUN apt-get install --yes software-properties-common
      RUN add-apt-repository ppa:hvr/ghc
      RUN apt-get update
      
      RUN apt-get install --yes ghc-8.6.5 cabal-install-2.4
      RUN apt-get install --yes libz-dev
      
      ENV PATH=/opt/ghc/8.6.5/bin:/opt/cabal/2.4/bin:$PWD/.cabal-sandbox/bin:$PATH
      
      RUN cabal update
      RUN cabal v1-sandbox init
      RUN cabal v1-install alex happy
      RUN apt-get install --yes git
      
      CMD git clone $REPO && \
          cd $NAME && \
          git checkout $COMMIT && \
          cd .. && \
          cabal v1-sandbox init                                                                       && \
          cabal v1-install $NAME/$PAT**/ --constraint="aeson>=2.0.3.0"                                && \
          cp -r $NAME/ogma-core/templates/ros custom-template-ros                                     && \
          ./.cabal-sandbox/bin/ogma ros --app-target-dir original                                        \
                                        --variable-db $NAME/ogma-cli/examples/ros-copilot/vars-db        \
                                        --variable-file $NAME/ogma-cli/examples/ros-copilot/variables    \
                                        --handlers-file $NAME/ogma-cli/examples/ros-copilot/handlers  && \
          ./.cabal-sandbox/bin/ogma ros --app-target-dir new                                             \
                                        --app-template-dir custom-template-ros                           \
                                        --variable-db $NAME/ogma-cli/examples/ros-copilot/vars-db        \
                                        --variable-file $NAME/ogma-cli/examples/ros-copilot/variables    \
                                        --handlers-file $NAME/ogma-cli/examples/ros-copilot/handlers  && \
          diff -rq original new                                                                       && \
          rm -rf new                                                                                  && \
          echo "Success" >> custom-template-ros/test                                                  && \
          ./.cabal-sandbox/bin/ogma ros --app-target-dir new                                             \
                                        --app-template-dir custom-template-ros                           \
                                        --variable-db $NAME/ogma-cli/examples/ros-copilot/vars-db        \
                                        --variable-file $NAME/ogma-cli/examples/ros-copilot/variables    \
                                        --handlers-file $NAME/ogma-cli/examples/ros-copilot/handlers  && \
          cat new/test
      Command (substitute variables based on new path after merge):
      $ docker run -e "REPO=https://github.com/ivanperez-keera/ogma" -e "NAME=ogma" -e "PAT=ogma"  -e "COMMIT=879f0715798944c146e1d47268844fc60f5d65c9" -it ogma-verify-162
      
  • Implementation is documented. Details:
    The new code has comments.
  • Change history is clear.
  • Commit messages are clear.
  • Changelogs are updated.
  • Examples are updated. Details:
    No updates needed.
  • Required version bumps are evaluated. Details:
    No bump needed. New feature is backwards compatible.

@ivanperez-keera ivanperez-keera merged commit 6325b1d into nasa:develop Nov 21, 2024
2 checks passed
@ivanperez-keera ivanperez-keera deleted the develop-ros-templates branch November 21, 2024 08:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant