Skip to content

Commit

Permalink
Merge branch 'release-1.4.0'. Refs #145.
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanperez-keera committed May 22, 2024
2 parents 93a6c52 + 2071ab0 commit c4fc3ef
Show file tree
Hide file tree
Showing 31 changed files with 279 additions and 70 deletions.
54 changes: 54 additions & 0 deletions .github/workflows/repo-ghc-8.6-cabal-2.4-ros.yml
Original file line number Diff line number Diff line change
@@ -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 .
63 changes: 63 additions & 0 deletions .github/workflows/repo-ghc-8.6-cabal-2.4.yml
Original file line number Diff line number Diff line change
@@ -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
40 changes: 0 additions & 40 deletions .travis.yml

This file was deleted.

8 changes: 8 additions & 0 deletions ogma-cli/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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).
Expand Down
48 changes: 43 additions & 5 deletions ogma-cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

```
("<NAME>","<TYPE>","<TOPIC_NAME>","<RESERVED_FOR_FUTURE_USE>")
```

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,
Expand Down
28 changes: 28 additions & 0 deletions ogma-cli/examples/ros-copilot/ROS.hs
Original file line number Diff line number Diff line change
@@ -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/" }
1 change: 1 addition & 0 deletions ogma-cli/examples/ros-copilot/handlers
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
handlerTestCopilot
3 changes: 3 additions & 0 deletions ogma-cli/examples/ros-copilot/variables
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
input_signal
input_signal_float
input_signal_double
3 changes: 3 additions & 0 deletions ogma-cli/examples/ros-copilot/vars-db
Original file line number Diff line number Diff line change
@@ -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")
4 changes: 2 additions & 2 deletions ogma-cli/ogma-cli.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions ogma-core/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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).
Expand Down
23 changes: 12 additions & 11 deletions ogma-core/ogma-core.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions ogma-core/src/Command/ROSApp.hs
Original file line number Diff line number Diff line change
Expand Up @@ -136,15 +136,15 @@ 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

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
Expand Down Expand Up @@ -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
Expand Down
16 changes: 16 additions & 0 deletions ogma-core/templates/ros/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 4 additions & 0 deletions ogma-extra/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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).
Expand Down
Loading

0 comments on commit c4fc3ef

Please sign in to comment.