diff --git a/.github/workflows/repo-ghc-8.6-cabal-2.4-ros.yml b/.github/workflows/repo-ghc-8.6-cabal-2.4-ros.yml new file mode 100644 index 0000000..be899c4 --- /dev/null +++ b/.github/workflows/repo-ghc-8.6-cabal-2.4-ros.yml @@ -0,0 +1,54 @@ +name: ros-ghc-8.6-cabal-2.4 + +# Trigger the workflow on push or pull request +on: + - pull_request + - push + +jobs: + cabal: + name: ${{ matrix.os }} / ghc ${{ matrix.ghc }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest] + cabal: ["2.4"] + ghc: + - "8.6" + + steps: + + - uses: haskell-actions/setup@main + id: setup-haskell-cabal + name: Setup Haskell + with: + ghc-version: ${{ matrix.ghc }} + cabal-version: ${{ matrix.cabal }} + + - name: Prepare environment + run: | + echo "$HOME/.ghcup/bin" >> $GITHUB_PATH + echo "$HOME/.cabal/bin" >> $GITHUB_PATH + + - uses: actions/checkout@v4 + + - name: Create sandbox + run: | + echo "$PWD/.cabal-sandbox/bin" >> $GITHUB_PATH + cabal v1-sandbox init + + - name: Install dependencies + run: | + cabal v1-install alex happy + + - name: Install ogma + run: | + cabal v1-install copilot ogma-**/ --constraint="copilot >= 3.19.1" + + - name: Generate ROS app + run: | + ogma ros --app-target-dir demo --variable-db ogma-cli/examples/ros-copilot/vars-db --variable-file ogma-cli/examples/ros-copilot/variables --handlers-file ogma-cli/examples/ros-copilot/handlers + cabal v1-exec -- runhaskell ogma-cli/examples/ros-copilot/ROS.hs + find demo/ + cd demo/ + docker build . diff --git a/.github/workflows/repo-ghc-8.6-cabal-2.4.yml b/.github/workflows/repo-ghc-8.6-cabal-2.4.yml new file mode 100644 index 0000000..4eaa7bb --- /dev/null +++ b/.github/workflows/repo-ghc-8.6-cabal-2.4.yml @@ -0,0 +1,63 @@ +name: install-hackage-ghc-8.6-cabal-2.4 + +# Trigger the workflow on push or pull request +on: + - pull_request + - push + +jobs: + cabal: + name: ${{ matrix.os }} / ghc ${{ matrix.ghc }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest] + cabal: ["2.4"] + ghc: + - "8.6" + + steps: + + - uses: haskell-actions/setup@main + id: setup-haskell-cabal + name: Setup Haskell + with: + ghc-version: ${{ matrix.ghc }} + cabal-version: ${{ matrix.cabal }} + + - name: Prepare environment + run: | + echo "$HOME/.ghcup/bin" >> $GITHUB_PATH + echo "$HOME/.cabal/bin" >> $GITHUB_PATH + + - uses: actions/checkout@v4 + + - name: Create sandbox + run: | + echo "$PWD/.cabal-sandbox/bin" >> $GITHUB_PATH + cabal v1-sandbox init + + - name: Install dependencies + run: | + cabal v1-install alex happy + + - name: Install ogma + run: | + # Some tests need the ogma executable to be in the path, which won't + # happen until installation completes successfully (which only happens + # after tests if running tests is enabled). We therefore need to run + # the installation twice: once without --run-tests, and again with + # --run-tests. + # + # We still --enable-tests in the first compilation to make sure that + # the dependencies do not change and cabal does not change the + # installation plan (which would mean we'd be running the tests with a + # version of ogma compiled with different dependencies). + cabal v1-install ogma-**/ --enable-tests + + - name: Test all packages + run: | + # We want to document the build process, and get detailed information + # if there is a problem (or if all goes well). We therefore execute the + # installation with -j1. + cabal v1-install ogma-**/ --enable-tests --run-tests -j1 diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index c15cddc..0000000 --- a/.travis.yml +++ /dev/null @@ -1,40 +0,0 @@ -language: haskell - -ghc: - - "8.8.4" - -env: - - PATH=${HOME}/.cabal/bin:${PATH} - -before_install: - - travis_retry sudo apt-get update - -install: - - travis_retry cabal install alex happy - - travis_retry cabal install --enable-tests --only-dependencies ogma-**/ - -script: - # We want to document the build process, and get detailed information if - # there is a problem (or if all goes well). We therefore execute the - # installation with -j1. - # - # Some tests need the ogma executable to be in the path, which won't happen - # until installation completes successfully (which only happens after tests - # if running tests is enabled). We therefore need to run the installation - # twice: once without --run-tests, and again with --run-tests. - # - # We still --enable-tests in the first compilation to make sure that the - # dependencies do not change and cabal does not change the installation plan - # (which would mean we'd be running the tests with a version of ogma compiled - # with different dependencies). - - cabal install --enable-tests -j1 ogma-**/ - - cabal install --run-tests -j1 ogma-**/ - -after_script: - -branches: - only: - - master - - /^develop.*$/ - - /^hotfix.*$/ - - /^release.*$/ diff --git a/ogma-cli/CHANGELOG.md b/ogma-cli/CHANGELOG.md index 0a59d3f..d0b405d 100644 --- a/ogma-cli/CHANGELOG.md +++ b/ogma-cli/CHANGELOG.md @@ -1,5 +1,13 @@ # Revision history for ogma-cli +## [1.4.0] - 2024-05-21 + +* Version bump 1.4.0 (#145). +* Introduce CI test job (#139). +* Introduce test job for ROS package generation (#136). +* Add a float and a double input variable to ROS example (#138). +* Document format of variable DB (#143). + ## [1.3.0] - 2024-03-21 * Version bump 1.3.0 (#133). diff --git a/ogma-cli/README.md b/ogma-cli/README.md index b008a05..6d22e14 100644 --- a/ogma-cli/README.md +++ b/ogma-cli/README.md @@ -214,13 +214,51 @@ $ ogma ros --handlers filename --variable-file variables --variable-db ros-varia The application generated by Ogma contains the following files: ``` -ros_demo/CMakeLists.txt -ros_demo/src/copilot_monitor.cpp -ros_demo/src/copilot_logger.cpp -ros_demo/src/.keep -ros_demo/package.xml +ros_demo/copilot/CMakeLists.txt +ros_demo/copilot/src/copilot_monitor.cpp +ros_demo/copilot/src/copilot_logger.cpp +ros_demo/copilot/src/.keep +ros_demo/copilot/package.xml +ros_demo/Dockerfile ``` +The Dockerfile can be used to compile the application inside the base image for +the Space ROS distribution. To build the image, first place the core +implementation of the monitors in C inside the directory +`ros_demo/copilot/src/` (see 'Current limitations' for details). After, you can +compile the image with: +``` +docker build . +``` + +### Format of the Variables DB File + +The argument variable DB passed to the ROS backend should contain a list of +variables, together with their types and the corresponding ROS topic in which +those variables are passed. Each line in that file has the format: + +``` +("","","","") +``` + +For example, an input variable called "temperature" of type 64-bit signed +integer coming in a ROS topic called "/battery/temperature" should have a +matching entry in the variable DB file like the following: + +``` +("temperature","int64_t","/battery/temperature","ignore") +``` + +There should never be two lines in the same file with the same variable name. +Variables in the DB that are not not used in any of the properties being +monitored and/or are not listed in the variable file passed as argument to the +ROS command will be ignored. + +For a more concrete example, see the files in `ogma-cli/examples/ros-copilot/` +and the last step of the script +`.github/workflows/repo-ghc-8.6-cabal-2.4-ros.yml`, which generates a ROS +monitor with multiple variables and compiles the resulting code. + ### Current limitations The user must place the code generated by Copilot monitors in two files, diff --git a/ogma-cli/examples/ros-copilot/ROS.hs b/ogma-cli/examples/ros-copilot/ROS.hs new file mode 100644 index 0000000..a035a8a --- /dev/null +++ b/ogma-cli/examples/ros-copilot/ROS.hs @@ -0,0 +1,28 @@ +import Copilot.Compile.C99 +import Copilot.Language +import Language.Copilot (reify) +import Prelude hiding (not, (&&), (>=)) + +inputSignal :: Stream Int64 +inputSignal = extern "input_signal" Nothing + +inputSignalFloat :: Stream Float +inputSignalFloat = extern "input_signal_float" Nothing + +inputSignalDouble :: Stream Double +inputSignalDouble = extern "input_signal_double" Nothing + +propTestCopilot :: Stream Bool +propTestCopilot = inputSignal >= 5 + && inputSignalFloat >= 5 + && inputSignalDouble >= 5 + +spec :: Spec +spec = do + trigger "handlerTestCopilot" (not propTestCopilot) [] + +main :: IO () +main = reify spec >>= compileWith settings "monitor" + where + settings = mkDefaultCSettings + { cSettingsOutputDirectory = "demo/copilot/src/" } diff --git a/ogma-cli/examples/ros-copilot/handlers b/ogma-cli/examples/ros-copilot/handlers new file mode 100644 index 0000000..b56f01b --- /dev/null +++ b/ogma-cli/examples/ros-copilot/handlers @@ -0,0 +1 @@ +handlerTestCopilot diff --git a/ogma-cli/examples/ros-copilot/variables b/ogma-cli/examples/ros-copilot/variables new file mode 100644 index 0000000..aeab3f1 --- /dev/null +++ b/ogma-cli/examples/ros-copilot/variables @@ -0,0 +1,3 @@ +input_signal +input_signal_float +input_signal_double diff --git a/ogma-cli/examples/ros-copilot/vars-db b/ogma-cli/examples/ros-copilot/vars-db new file mode 100644 index 0000000..5fb4e85 --- /dev/null +++ b/ogma-cli/examples/ros-copilot/vars-db @@ -0,0 +1,3 @@ +("input_signal","int64_t","/demo/topic","int64_t") +("input_signal_float","float","/demo/topicf","float") +("input_signal_double","double","/demo/topicd","double") diff --git a/ogma-cli/ogma-cli.cabal b/ogma-cli/ogma-cli.cabal index 8ca756f..3aea7df 100644 --- a/ogma-cli/ogma-cli.cabal +++ b/ogma-cli/ogma-cli.cabal @@ -32,7 +32,7 @@ cabal-version: 2.0 build-type: Simple name: ogma-cli -version: 1.3.0 +version: 1.4.0 homepage: http://nasa.gov license: OtherLicense license-file: LICENSE.pdf @@ -141,7 +141,7 @@ executable ogma build-depends: base >= 4.11.0.0 && < 5 , optparse-applicative - , ogma-core >= 1.3.0 && < 1.4 + , ogma-core >= 1.4.0 && < 1.5 hs-source-dirs: src diff --git a/ogma-core/CHANGELOG.md b/ogma-core/CHANGELOG.md index f8795c8..1090c40 100644 --- a/ogma-core/CHANGELOG.md +++ b/ogma-core/CHANGELOG.md @@ -1,5 +1,11 @@ # Revision history for ogma-core +## [1.4.0] - 2024-05-21 + +* Version bump 1.4.0 (#145). +* Make ros command generate dockerfile (#136). +* Map float and double to the same types in C++ (#138). + ## [1.3.0] - 2024-03-21 * Version bump 1.3.0 (#133). diff --git a/ogma-core/ogma-core.cabal b/ogma-core/ogma-core.cabal index 8a06c11..a89d79e 100644 --- a/ogma-core/ogma-core.cabal +++ b/ogma-core/ogma-core.cabal @@ -32,7 +32,7 @@ cabal-version: 2.0 build-type: Simple name: ogma-core -version: 1.3.0 +version: 1.4.0 homepage: http://nasa.gov license: OtherLicense license-file: LICENSE.pdf @@ -60,9 +60,10 @@ data-files: templates/copilot-cfs/CMakeLists.txt templates/copilot-cfs/fsw/src/copilot_cfs_version.h templates/copilot-cfs/fsw/src/copilot_cfs.h templates/copilot-cfs/fsw/src/copilot_cfs_events.h - templates/ros/CMakeLists.txt - templates/ros/src/.keep - templates/ros/package.xml + templates/ros/Dockerfile + templates/ros/copilot/CMakeLists.txt + templates/ros/copilot/src/.keep + templates/ros/copilot/package.xml templates/fprime/CMakeLists.txt templates/fprime/Dockerfile templates/fprime/instance-copilot @@ -109,13 +110,13 @@ library , IfElse , mtl - , ogma-extra >= 1.3.0 && < 1.4 - , ogma-language-c >= 1.3.0 && < 1.4 - , ogma-language-cocospec >= 1.3.0 && < 1.4 - , ogma-language-copilot >= 1.3.0 && < 1.4 - , ogma-language-jsonspec >= 1.3.0 && < 1.4 - , ogma-language-smv >= 1.3.0 && < 1.4 - , ogma-spec >= 1.3.0 && < 1.4 + , ogma-extra >= 1.4.0 && < 1.5 + , ogma-language-c >= 1.4.0 && < 1.5 + , ogma-language-cocospec >= 1.4.0 && < 1.5 + , ogma-language-copilot >= 1.4.0 && < 1.5 + , ogma-language-jsonspec >= 1.4.0 && < 1.5 + , ogma-language-smv >= 1.4.0 && < 1.5 + , ogma-spec >= 1.4.0 && < 1.5 hs-source-dirs: src diff --git a/ogma-core/src/Command/ROSApp.hs b/ogma-core/src/Command/ROSApp.hs index d53dc0b..9528b34 100644 --- a/ogma-core/src/Command/ROSApp.hs +++ b/ogma-core/src/Command/ROSApp.hs @@ -136,7 +136,7 @@ rosApp' targetDir varNames varDB monitors = foldr f ([], [], [], []) varNames let rosFileName = - targetDir "src" "copilot_monitor.cpp" + targetDir "copilot" "src" "copilot_monitor.cpp" rosFileContents = unlines $ rosMonitorContents varNames vars ids infos datas monitors @@ -144,7 +144,7 @@ rosApp' targetDir varNames varDB monitors = writeFile rosFileName rosFileContents let rosFileName = - targetDir "src" "copilot_logger.cpp" + targetDir "copilot" "src" "copilot_logger.cpp" rosFileContents = unlines $ rosLoggerContents varNames vars ids infos datas monitors @@ -403,8 +403,8 @@ rosMonitorContents varNames variables msgIds msgNames msgDatas monitors = "int16_t" -> "std::int16_t" "int32_t" -> "std::int32_t" "int64_t" -> "std::int64_t" - "float" -> "std::float32" - "double" -> "std::float64" + "float" -> "float" + "double" -> "double" def -> def msgSubscriptionS = unlines diff --git a/ogma-core/templates/ros/Dockerfile b/ogma-core/templates/ros/Dockerfile new file mode 100644 index 0000000..5c14dbd --- /dev/null +++ b/ogma-core/templates/ros/Dockerfile @@ -0,0 +1,16 @@ +FROM osrf/space-ros:latest + +ARG USER=spaceros-user +ARG PACKAGE_PATH=/home/${USER}/monitors +ARG ROS_PATH=/home/${USER}/spaceros/ + +RUN mkdir -p ${PACKAGE_PATH}/src/ +ADD copilot ${PACKAGE_PATH}/src/copilot +USER root +RUN chown -R ${USER} ${PACKAGE_PATH} +USER ${USER} + +SHELL ["/bin/bash", "-c"] +WORKDIR ${PACKAGE_PATH} +RUN source ${ROS_PATH}/install/setup.bash && \ + colcon build diff --git a/ogma-core/templates/ros/CMakeLists.txt b/ogma-core/templates/ros/copilot/CMakeLists.txt similarity index 100% rename from ogma-core/templates/ros/CMakeLists.txt rename to ogma-core/templates/ros/copilot/CMakeLists.txt diff --git a/ogma-core/templates/ros/package.xml b/ogma-core/templates/ros/copilot/package.xml similarity index 100% rename from ogma-core/templates/ros/package.xml rename to ogma-core/templates/ros/copilot/package.xml diff --git a/ogma-core/templates/ros/src/.keep b/ogma-core/templates/ros/copilot/src/.keep similarity index 100% rename from ogma-core/templates/ros/src/.keep rename to ogma-core/templates/ros/copilot/src/.keep diff --git a/ogma-extra/CHANGELOG.md b/ogma-extra/CHANGELOG.md index f9b55e2..43c8a28 100644 --- a/ogma-extra/CHANGELOG.md +++ b/ogma-extra/CHANGELOG.md @@ -1,5 +1,9 @@ # Revision history for ogma-extra +## [1.4.0] - 2024-05-21 + +* Version bump 1.4.0 (#145). + ## [1.3.0] - 2024-03-21 * Version bump 1.3.0 (#133). diff --git a/ogma-extra/ogma-extra.cabal b/ogma-extra/ogma-extra.cabal index 1c0029b..f0abfb0 100644 --- a/ogma-extra/ogma-extra.cabal +++ b/ogma-extra/ogma-extra.cabal @@ -32,7 +32,7 @@ cabal-version: 2.0 build-type: Simple name: ogma-extra -version: 1.3.0 +version: 1.4.0 homepage: http://nasa.gov license: OtherLicense license-file: LICENSE.pdf diff --git a/ogma-language-c/CHANGELOG.md b/ogma-language-c/CHANGELOG.md index f5525fb..e07fdcf 100644 --- a/ogma-language-c/CHANGELOG.md +++ b/ogma-language-c/CHANGELOG.md @@ -1,5 +1,9 @@ # Revision history for ogma-language-c +## [1.4.0] - 2024-05-21 + +* Version bump 1.4.0 (#145). + ## [1.3.0] - 2024-03-21 * Version bump 1.3.0 (#133). diff --git a/ogma-language-c/ogma-language-c.cabal b/ogma-language-c/ogma-language-c.cabal index b2fce13..a7d8ebd 100644 --- a/ogma-language-c/ogma-language-c.cabal +++ b/ogma-language-c/ogma-language-c.cabal @@ -32,7 +32,7 @@ cabal-version: 2.0 build-type: Custom name: ogma-language-c -version: 1.3.0 +version: 1.4.0 homepage: http://nasa.gov license: OtherLicense license-file: LICENSE.pdf diff --git a/ogma-language-cocospec/CHANGELOG.md b/ogma-language-cocospec/CHANGELOG.md index cde71b2..504b729 100644 --- a/ogma-language-cocospec/CHANGELOG.md +++ b/ogma-language-cocospec/CHANGELOG.md @@ -1,5 +1,9 @@ # Revision history for ogma-language-cocospec +## [1.4.0] - 2024-05-21 + +* Version bump 1.4.0 (#145). + ## [1.3.0] - 2024-03-21 * Version bump 1.3.0 (#133). diff --git a/ogma-language-cocospec/ogma-language-cocospec.cabal b/ogma-language-cocospec/ogma-language-cocospec.cabal index b51094e..b5814af 100644 --- a/ogma-language-cocospec/ogma-language-cocospec.cabal +++ b/ogma-language-cocospec/ogma-language-cocospec.cabal @@ -32,7 +32,7 @@ cabal-version: 2.0 build-type: Custom name: ogma-language-cocospec -version: 1.3.0 +version: 1.4.0 homepage: http://nasa.gov license: OtherLicense license-file: LICENSE.pdf diff --git a/ogma-language-copilot/CHANGELOG.md b/ogma-language-copilot/CHANGELOG.md index 0c7ede9..0c18191 100644 --- a/ogma-language-copilot/CHANGELOG.md +++ b/ogma-language-copilot/CHANGELOG.md @@ -1,5 +1,9 @@ # Revision history for ogma-language-copilot +## [1.4.0] - 2024-05-21 + +* Version bump 1.4.0 (#145). + ## [1.3.0] - 2024-03-21 * Version bump 1.3.0 (#133). diff --git a/ogma-language-copilot/ogma-language-copilot.cabal b/ogma-language-copilot/ogma-language-copilot.cabal index 1ca72f5..4ee0539 100644 --- a/ogma-language-copilot/ogma-language-copilot.cabal +++ b/ogma-language-copilot/ogma-language-copilot.cabal @@ -32,7 +32,7 @@ cabal-version: 2.0 build-type: Simple name: ogma-language-copilot -version: 1.3.0 +version: 1.4.0 homepage: http://nasa.gov license: OtherLicense license-file: LICENSE.pdf diff --git a/ogma-language-jsonspec/CHANGELOG.md b/ogma-language-jsonspec/CHANGELOG.md index 370c86b..ed9d1f7 100644 --- a/ogma-language-jsonspec/CHANGELOG.md +++ b/ogma-language-jsonspec/CHANGELOG.md @@ -1,5 +1,9 @@ # Revision history for ogma-language-jsonspec +## [1.4.0] - 2024-05-21 + +* Version bump 1.4.0 (#145). + ## [1.3.0] - 2024-03-21 * Version bump 1.3.0 (#133). diff --git a/ogma-language-jsonspec/ogma-language-jsonspec.cabal b/ogma-language-jsonspec/ogma-language-jsonspec.cabal index 74e5bf0..8817c13 100644 --- a/ogma-language-jsonspec/ogma-language-jsonspec.cabal +++ b/ogma-language-jsonspec/ogma-language-jsonspec.cabal @@ -32,7 +32,7 @@ cabal-version: 2.0 build-type: Simple name: ogma-language-jsonspec -version: 1.3.0 +version: 1.4.0 homepage: http://nasa.gov license: OtherLicense license-file: LICENSE.pdf @@ -70,7 +70,7 @@ library , megaparsec , bytestring - , ogma-spec >= 1.3.0 && < 1.4 + , ogma-spec >= 1.4.0 && < 1.5 hs-source-dirs: src diff --git a/ogma-language-smv/CHANGELOG.md b/ogma-language-smv/CHANGELOG.md index 586ea3d..ef69fe1 100644 --- a/ogma-language-smv/CHANGELOG.md +++ b/ogma-language-smv/CHANGELOG.md @@ -1,5 +1,9 @@ # Revision history for ogma-language-smv +## [1.4.0] - 2024-05-21 + +* Version bump 1.4.0 (#145). + ## [1.3.0] - 2024-03-21 * Version bump 1.3.0 (#133). diff --git a/ogma-language-smv/ogma-language-smv.cabal b/ogma-language-smv/ogma-language-smv.cabal index 236f39d..51c79e6 100644 --- a/ogma-language-smv/ogma-language-smv.cabal +++ b/ogma-language-smv/ogma-language-smv.cabal @@ -32,7 +32,7 @@ cabal-version: 2.0 build-type: Custom name: ogma-language-smv -version: 1.3.0 +version: 1.4.0 homepage: http://nasa.gov license: OtherLicense license-file: LICENSE.pdf diff --git a/ogma-spec/CHANGELOG.md b/ogma-spec/CHANGELOG.md index 046a16f..8340a7c 100644 --- a/ogma-spec/CHANGELOG.md +++ b/ogma-spec/CHANGELOG.md @@ -1,5 +1,9 @@ # Revision history for ogma-spec +## [1.4.0] - 2024-05-21 + +* Version bump 1.4.0 (#145). + ## [1.3.0] - 2024-03-21 * Version bump 1.3.0 (#133). diff --git a/ogma-spec/ogma-spec.cabal b/ogma-spec/ogma-spec.cabal index 26d7ece..b9e0722 100644 --- a/ogma-spec/ogma-spec.cabal +++ b/ogma-spec/ogma-spec.cabal @@ -32,7 +32,7 @@ cabal-version: 2.0 build-type: Simple name: ogma-spec -version: 1.3.0 +version: 1.4.0 homepage: http://nasa.gov license: OtherLicense license-file: LICENSE.pdf