Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop-ros-templates' into develop. Close #162.
**Description** 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. Allowing users to pick their own ROS template would make Ogma more versatile. **Type** - Feature: Enable customizing output produced. **Additional context** None. **Requester** - Ivan Perez. **Method to check presence of bug** Not applicable (not a bug). **Expected result** Ogma allows users to pick the custom ROS package template they want to use instead of relying on the one provided by default. 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". ```Dockerfile 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): ```sh $ docker run -e "REPO=https://github.com/NASA/ogma" -e "NAME=ogma" -e PAT="ogma-" -e "COMMIT=<HASH>" -it ogma-verify-162 ``` **Solution implemented** Modify `ogma-core` and `ogma-extra` to move the mustache template expansion feature to `ogma-extra`. Adjust the cFS backend accordingly. Modify `ogma-core` to use variable expansion to generate the ROS package. Modify `ogma-core`'s template to use the variables used by the ROS package generation module. Modify `ogma-core` to give users the ability to pick a template directory via an optional input argument. Modify `ogma-cli` to give users the ability to pick a template directory via an optional input argument (exposing the corresponding argument from `ogma-core`). Modify `README` to demonstrate new capability. **Further notes** None.
- Loading branch information