Skip to content

Commit c4fc3ef

Browse files
Merge branch 'release-1.4.0'. Refs #145.
2 parents 93a6c52 + 2071ab0 commit c4fc3ef

31 files changed

+279
-70
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: ros-ghc-8.6-cabal-2.4
2+
3+
# Trigger the workflow on push or pull request
4+
on:
5+
- pull_request
6+
- push
7+
8+
jobs:
9+
cabal:
10+
name: ${{ matrix.os }} / ghc ${{ matrix.ghc }}
11+
runs-on: ${{ matrix.os }}
12+
strategy:
13+
matrix:
14+
os: [ubuntu-latest]
15+
cabal: ["2.4"]
16+
ghc:
17+
- "8.6"
18+
19+
steps:
20+
21+
- uses: haskell-actions/setup@main
22+
id: setup-haskell-cabal
23+
name: Setup Haskell
24+
with:
25+
ghc-version: ${{ matrix.ghc }}
26+
cabal-version: ${{ matrix.cabal }}
27+
28+
- name: Prepare environment
29+
run: |
30+
echo "$HOME/.ghcup/bin" >> $GITHUB_PATH
31+
echo "$HOME/.cabal/bin" >> $GITHUB_PATH
32+
33+
- uses: actions/checkout@v4
34+
35+
- name: Create sandbox
36+
run: |
37+
echo "$PWD/.cabal-sandbox/bin" >> $GITHUB_PATH
38+
cabal v1-sandbox init
39+
40+
- name: Install dependencies
41+
run: |
42+
cabal v1-install alex happy
43+
44+
- name: Install ogma
45+
run: |
46+
cabal v1-install copilot ogma-**/ --constraint="copilot >= 3.19.1"
47+
48+
- name: Generate ROS app
49+
run: |
50+
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
51+
cabal v1-exec -- runhaskell ogma-cli/examples/ros-copilot/ROS.hs
52+
find demo/
53+
cd demo/
54+
docker build .
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: install-hackage-ghc-8.6-cabal-2.4
2+
3+
# Trigger the workflow on push or pull request
4+
on:
5+
- pull_request
6+
- push
7+
8+
jobs:
9+
cabal:
10+
name: ${{ matrix.os }} / ghc ${{ matrix.ghc }}
11+
runs-on: ${{ matrix.os }}
12+
strategy:
13+
matrix:
14+
os: [ubuntu-latest]
15+
cabal: ["2.4"]
16+
ghc:
17+
- "8.6"
18+
19+
steps:
20+
21+
- uses: haskell-actions/setup@main
22+
id: setup-haskell-cabal
23+
name: Setup Haskell
24+
with:
25+
ghc-version: ${{ matrix.ghc }}
26+
cabal-version: ${{ matrix.cabal }}
27+
28+
- name: Prepare environment
29+
run: |
30+
echo "$HOME/.ghcup/bin" >> $GITHUB_PATH
31+
echo "$HOME/.cabal/bin" >> $GITHUB_PATH
32+
33+
- uses: actions/checkout@v4
34+
35+
- name: Create sandbox
36+
run: |
37+
echo "$PWD/.cabal-sandbox/bin" >> $GITHUB_PATH
38+
cabal v1-sandbox init
39+
40+
- name: Install dependencies
41+
run: |
42+
cabal v1-install alex happy
43+
44+
- name: Install ogma
45+
run: |
46+
# Some tests need the ogma executable to be in the path, which won't
47+
# happen until installation completes successfully (which only happens
48+
# after tests if running tests is enabled). We therefore need to run
49+
# the installation twice: once without --run-tests, and again with
50+
# --run-tests.
51+
#
52+
# We still --enable-tests in the first compilation to make sure that
53+
# the dependencies do not change and cabal does not change the
54+
# installation plan (which would mean we'd be running the tests with a
55+
# version of ogma compiled with different dependencies).
56+
cabal v1-install ogma-**/ --enable-tests
57+
58+
- name: Test all packages
59+
run: |
60+
# We want to document the build process, and get detailed information
61+
# if there is a problem (or if all goes well). We therefore execute the
62+
# installation with -j1.
63+
cabal v1-install ogma-**/ --enable-tests --run-tests -j1

.travis.yml

Lines changed: 0 additions & 40 deletions
This file was deleted.

ogma-cli/CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Revision history for ogma-cli
22

3+
## [1.4.0] - 2024-05-21
4+
5+
* Version bump 1.4.0 (#145).
6+
* Introduce CI test job (#139).
7+
* Introduce test job for ROS package generation (#136).
8+
* Add a float and a double input variable to ROS example (#138).
9+
* Document format of variable DB (#143).
10+
311
## [1.3.0] - 2024-03-21
412

513
* Version bump 1.3.0 (#133).

ogma-cli/README.md

Lines changed: 43 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -214,13 +214,51 @@ $ ogma ros --handlers filename --variable-file variables --variable-db ros-varia
214214

215215
The application generated by Ogma contains the following files:
216216
```
217-
ros_demo/CMakeLists.txt
218-
ros_demo/src/copilot_monitor.cpp
219-
ros_demo/src/copilot_logger.cpp
220-
ros_demo/src/.keep
221-
ros_demo/package.xml
217+
ros_demo/copilot/CMakeLists.txt
218+
ros_demo/copilot/src/copilot_monitor.cpp
219+
ros_demo/copilot/src/copilot_logger.cpp
220+
ros_demo/copilot/src/.keep
221+
ros_demo/copilot/package.xml
222+
ros_demo/Dockerfile
222223
```
223224

225+
The Dockerfile can be used to compile the application inside the base image for
226+
the Space ROS distribution. To build the image, first place the core
227+
implementation of the monitors in C inside the directory
228+
`ros_demo/copilot/src/` (see 'Current limitations' for details). After, you can
229+
compile the image with:
230+
```
231+
docker build .
232+
```
233+
234+
### Format of the Variables DB File
235+
236+
The argument variable DB passed to the ROS backend should contain a list of
237+
variables, together with their types and the corresponding ROS topic in which
238+
those variables are passed. Each line in that file has the format:
239+
240+
```
241+
("<NAME>","<TYPE>","<TOPIC_NAME>","<RESERVED_FOR_FUTURE_USE>")
242+
```
243+
244+
For example, an input variable called "temperature" of type 64-bit signed
245+
integer coming in a ROS topic called "/battery/temperature" should have a
246+
matching entry in the variable DB file like the following:
247+
248+
```
249+
("temperature","int64_t","/battery/temperature","ignore")
250+
```
251+
252+
There should never be two lines in the same file with the same variable name.
253+
Variables in the DB that are not not used in any of the properties being
254+
monitored and/or are not listed in the variable file passed as argument to the
255+
ROS command will be ignored.
256+
257+
For a more concrete example, see the files in `ogma-cli/examples/ros-copilot/`
258+
and the last step of the script
259+
`.github/workflows/repo-ghc-8.6-cabal-2.4-ros.yml`, which generates a ROS
260+
monitor with multiple variables and compiles the resulting code.
261+
224262
### Current limitations
225263

226264
The user must place the code generated by Copilot monitors in two files,
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import Copilot.Compile.C99
2+
import Copilot.Language
3+
import Language.Copilot (reify)
4+
import Prelude hiding (not, (&&), (>=))
5+
6+
inputSignal :: Stream Int64
7+
inputSignal = extern "input_signal" Nothing
8+
9+
inputSignalFloat :: Stream Float
10+
inputSignalFloat = extern "input_signal_float" Nothing
11+
12+
inputSignalDouble :: Stream Double
13+
inputSignalDouble = extern "input_signal_double" Nothing
14+
15+
propTestCopilot :: Stream Bool
16+
propTestCopilot = inputSignal >= 5
17+
&& inputSignalFloat >= 5
18+
&& inputSignalDouble >= 5
19+
20+
spec :: Spec
21+
spec = do
22+
trigger "handlerTestCopilot" (not propTestCopilot) []
23+
24+
main :: IO ()
25+
main = reify spec >>= compileWith settings "monitor"
26+
where
27+
settings = mkDefaultCSettings
28+
{ cSettingsOutputDirectory = "demo/copilot/src/" }
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
handlerTestCopilot
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
input_signal
2+
input_signal_float
3+
input_signal_double
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
("input_signal","int64_t","/demo/topic","int64_t")
2+
("input_signal_float","float","/demo/topicf","float")
3+
("input_signal_double","double","/demo/topicd","double")

ogma-cli/ogma-cli.cabal

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ cabal-version: 2.0
3232
build-type: Simple
3333

3434
name: ogma-cli
35-
version: 1.3.0
35+
version: 1.4.0
3636
homepage: http://nasa.gov
3737
license: OtherLicense
3838
license-file: LICENSE.pdf
@@ -141,7 +141,7 @@ executable ogma
141141
build-depends:
142142
base >= 4.11.0.0 && < 5
143143
, optparse-applicative
144-
, ogma-core >= 1.3.0 && < 1.4
144+
, ogma-core >= 1.4.0 && < 1.5
145145

146146
hs-source-dirs:
147147
src

0 commit comments

Comments
 (0)