Skip to content

Commit 5ca8db2

Browse files
Merge branch 'release-1.9.0'. Refs #284.
2 parents 50ca23b + 5ad4704 commit 5ca8db2

File tree

32 files changed

+437
-83
lines changed

32 files changed

+437
-83
lines changed

ogma-cli/CHANGELOG.md

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

3+
## [1.9.0] - 2025-08-06
4+
5+
* Version bump 1.9.0 (#284).
6+
* Extend ROS command with flags to control testing package (#280).
7+
* Bump upper version constraint on optparse-applicative (#279).
8+
39
## [1.8.0] - 2025-07-13
410

511
* Version bump 1.8.0 (#275).

ogma-cli/ogma-cli.cabal

Lines changed: 3 additions & 3 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.8.0
35+
version: 1.9.0
3636
homepage: https://github.com/nasa/ogma
3737
bug-reports: https://github.com/nasa/ogma/issues
3838
license: OtherLicense
@@ -152,11 +152,11 @@ executable ogma
152152
build-depends:
153153
base >= 4.11.0.0 && < 5
154154
, aeson >= 2.0.0.0 && < 2.3
155-
, optparse-applicative >= 0.14 && < 0.19
155+
, optparse-applicative >= 0.14 && < 0.20
156156
, microstache >= 1.0 && < 1.1
157157
, text >= 1.2.3.1 && < 2.2
158158

159-
, ogma-core >= 1.8.0 && < 1.9
159+
, ogma-core >= 1.9.0 && < 1.10
160160

161161
hs-source-dirs:
162162
src

ogma-cli/src/CLI/CommandROSApp.hs

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ module CLI.CommandROSApp
4343
where
4444

4545
-- External imports
46-
import Options.Applicative ( Parser, help, long, metavar, optional, short,
46+
import Options.Applicative ( Parser, help, long, metavar, many, optional, short,
4747
showDefault, strOption, value )
4848

4949
-- External imports: command results
@@ -68,6 +68,8 @@ data CommandOpts = CommandOpts
6868
, rosAppPropFormat :: String
6969
, rosAppPropVia :: Maybe String
7070
, rosAppTemplateVars :: Maybe String
71+
, rosAppTestingApps :: [String]
72+
, rosAppTestingVars :: [String]
7173
}
7274

7375
-- | Create <https://www.ros.org/ Robot Operating System> (ROS) applications
@@ -90,8 +92,17 @@ command c = Command.ROSApp.command options
9092
, Command.ROSApp.commandPropFormat = rosAppPropFormat c
9193
, Command.ROSApp.commandPropVia = rosAppPropVia c
9294
, Command.ROSApp.commandExtraVars = rosAppTemplateVars c
95+
, Command.ROSApp.commandTestingApps = appNames
96+
, Command.ROSApp.commandTestingVars = rosAppTestingVars c
9397
}
9498

99+
-- Turn the qualified app names into tuples of package and node name.
100+
appNames = map splitAppName $ rosAppTestingApps c
101+
102+
splitAppName name = Command.ROSApp.Node package (drop 1 nodeT)
103+
where
104+
(package, nodeT) = break (== ':') name
105+
95106
-- * CLI
96107

97108
-- | ROS command description
@@ -181,6 +192,19 @@ commandOptsParser = CommandOpts
181192
<> help strROSAppTemplateVarsArgDesc
182193
)
183194
)
195+
<*> many (strOption
196+
( long "testing-app"
197+
<> metavar "package:node"
198+
<> help strROSAppROSNodesTestingListArgDesc
199+
)
200+
)
201+
<*> many (strOption
202+
( long "testing-vars"
203+
<> metavar "variable_name"
204+
<> showDefault
205+
<> help strROSAppHandlerListArgDesc
206+
)
207+
)
184208

185209
-- | Argument target directory to ROS app generation command
186210
strROSAppDirArgDesc :: String
@@ -232,3 +256,13 @@ strROSAppPropViaDesc =
232256
strROSAppTemplateVarsArgDesc :: String
233257
strROSAppTemplateVarsArgDesc =
234258
"JSON file containing additional variables to expand in template"
259+
260+
-- | Argument packages to tested list to ROS app generation command
261+
strROSAppROSNodesTestingListArgDesc :: String
262+
strROSAppROSNodesTestingListArgDesc =
263+
"Turn on ROS2 package node during testing"
264+
265+
-- | Argument variables to be tested list to ROS app generation command
266+
strROSAppVarsTestingListArgDesc :: String
267+
strROSAppVarsTestingListArgDesc =
268+
"Limit random input generation to these variables"

ogma-core/CHANGELOG.md

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

3+
## [1.9.0] - 2025-08-06
4+
5+
* Version bump 1.9.0 (#284).
6+
* Extend ROS backend to generate testing package (#280).
7+
38
## [1.8.0] - 2025-07-13
49

510
* Version bump 1.8.0 (#275).

ogma-core/ogma-core.cabal

Lines changed: 15 additions & 11 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-core
35-
version: 1.8.0
35+
version: 1.9.0
3636
homepage: https://github.com/nasa/ogma
3737
bug-reports: https://github.com/nasa/ogma/issues
3838
license: OtherLicense
@@ -69,11 +69,15 @@ data-files: templates/copilot-cfs/CMakeLists.txt
6969
templates/copilot-cfs/fsw/src/copilot_cfs.h
7070
templates/copilot-cfs/fsw/src/copilot_cfs_events.h
7171
templates/ros/Dockerfile
72+
templates/ros/screenrc
7273
templates/ros/copilot/CMakeLists.txt
7374
templates/ros/copilot/src/copilot_logger.cpp
7475
templates/ros/copilot/src/copilot_monitor.cpp
7576
templates/ros/copilot/src/Copilot.hs
7677
templates/ros/copilot/package.xml
78+
templates/ros/test_requirements/CMakeLists.txt
79+
templates/ros/test_requirements/src/test_requirements.cpp
80+
templates/ros/test_requirements/package.xml
7781
templates/diagram/Copilot.hs
7882
templates/fprime/CMakeLists.txt
7983
templates/fprime/Copilot.cpp
@@ -148,16 +152,16 @@ library
148152
, process >= 1.6 && < 1.7
149153
, text >= 1.2.3.1 && < 2.2
150154

151-
, ogma-extra >= 1.8.0 && < 1.9
152-
, ogma-language-c >= 1.8.0 && < 1.9
153-
, ogma-language-copilot >= 1.8.0 && < 1.9
154-
, ogma-language-csv >= 1.8.0 && < 1.9
155-
, ogma-language-jsonspec >= 1.8.0 && < 1.9
156-
, ogma-language-lustre >= 1.8.0 && < 1.9
157-
, ogma-language-smv >= 1.8.0 && < 1.9
158-
, ogma-language-xlsx >= 1.8.0 && < 1.9
159-
, ogma-language-xmlspec >= 1.8.0 && < 1.9
160-
, ogma-spec >= 1.8.0 && < 1.9
155+
, ogma-extra >= 1.9.0 && < 1.10
156+
, ogma-language-c >= 1.9.0 && < 1.10
157+
, ogma-language-copilot >= 1.9.0 && < 1.10
158+
, ogma-language-csv >= 1.9.0 && < 1.10
159+
, ogma-language-jsonspec >= 1.9.0 && < 1.10
160+
, ogma-language-lustre >= 1.9.0 && < 1.10
161+
, ogma-language-smv >= 1.9.0 && < 1.10
162+
, ogma-language-xlsx >= 1.9.0 && < 1.10
163+
, ogma-language-xmlspec >= 1.9.0 && < 1.10
164+
, ogma-spec >= 1.9.0 && < 1.10
161165

162166
hs-source-dirs:
163167
src

ogma-core/src/Command/ROSApp.hs

Lines changed: 50 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
module Command.ROSApp
4545
( command
4646
, CommandOptions(..)
47+
, Node(Node)
4748
, ErrorCode
4849
)
4950
where
@@ -119,10 +120,18 @@ command' options (ExprPair exprT) = do
119120
(map (\x -> (x, Nothing)))
120121
rs
121122

122-
let appData = AppData variables monitors' copilotM
123+
let appData =
124+
AppData variables monitors' copilotM testingAdditionalApps testingVars
125+
123126
variables = mapMaybe (variableMap varDB) varNames
124127
monitors' = mapMaybe (monitorMap varDB) monitors
125128

129+
testingVars
130+
| null testingLimitedVars
131+
= variables
132+
| otherwise
133+
= filter (\x -> varDeclName x `elem` testingLimitedVars) variables
134+
126135
return appData
127136

128137
where
@@ -145,6 +154,9 @@ command' options (ExprPair exprT) = do
145154
processSpec spec' expr' fp' =
146155
Command.Standalone.commandLogic expr' fp' "copilot" [] exprT spec'
147156

157+
testingAdditionalApps = commandTestingApps options
158+
testingLimitedVars = commandTestingVars options
159+
148160
-- ** Argument processing
149161

150162
-- | Options used to customize the conversion of specifications to ROS
@@ -174,6 +186,10 @@ data CommandOptions = CommandOptions
174186
, commandExtraVars :: Maybe FilePath -- ^ File containing additional
175187
-- variables to make available to the
176188
-- template.
189+
, commandTestingApps :: [Node] -- ^ Additional applications to turn
190+
-- on during testing.
191+
, commandTestingVars :: [String] -- ^ Limited list of variables to use
192+
-- for testing.
177193
}
178194

179195
-- | Return the variable information needed to generate declarations
@@ -192,7 +208,7 @@ variableMap varDB varName = do
192208
let typeMsg' = fromMaybe
193209
(topicType topicDef)
194210
(typeFromType <$> findType varDB varName "ros/message" "C")
195-
return $ VarDecl varName typeVar' mid typeMsg'
211+
return $ VarDecl varName typeVar' mid typeMsg' (randomBaseType typeVar')
196212

197213
-- | Return the monitor information needed to generate declarations and
198214
-- publishers for the given monitor info, and variable database.
@@ -212,6 +228,7 @@ data VarDecl = VarDecl
212228
, varDeclType :: String
213229
, varDeclId :: String
214230
, varDeclMsgType :: String
231+
, varDeclRandom :: String
215232
}
216233
deriving Generic
217234

@@ -228,12 +245,40 @@ data Monitor = Monitor
228245

229246
instance ToJSON Monitor
230247

248+
-- | A package-qualified ROS 2 node name.
249+
data Node = Node
250+
{ nodePackage :: String
251+
, nodeName :: String
252+
}
253+
deriving Generic
254+
255+
instance ToJSON Node
256+
231257
-- | Data that may be relevant to generate a ROS application.
232258
data AppData = AppData
233-
{ variables :: [VarDecl]
234-
, monitors :: [Monitor]
235-
, copilot :: Maybe Command.Standalone.AppData
259+
{ variables :: [VarDecl]
260+
, monitors :: [Monitor]
261+
, copilot :: Maybe Command.Standalone.AppData
262+
, testingApps :: [Node]
263+
, testingVariables :: [VarDecl]
236264
}
237265
deriving (Generic)
238266

239267
instance ToJSON AppData
268+
269+
-- | Name of the function to be used to generate random values of a given type.
270+
randomBaseType :: String -- ^ Type to generate random values of.
271+
-> String
272+
randomBaseType ty = case ty of
273+
"bool" -> "randomBool"
274+
"uint8_t" -> "randomInt"
275+
"uint16_t" -> "randomInt"
276+
"uint32_t" -> "randomInt"
277+
"uint64_t" -> "randomInt"
278+
"int8_t" -> "randomInt"
279+
"int16_t" -> "randomInt"
280+
"int32_t" -> "randomInt"
281+
"int64_t" -> "randomInt"
282+
"float" -> "randomFloat"
283+
"double" -> "randomFloat"
284+
def -> def

ogma-core/templates/ros/Dockerfile

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,19 @@ ARG ROS_PATH=/home/${USER}/spaceros/
66

77
RUN mkdir -p ${PACKAGE_PATH}/src/
88
ADD copilot ${PACKAGE_PATH}/src/copilot
9+
ADD test_requirements ${PACKAGE_PATH}/src/test_requirements
910
USER root
1011
RUN chown -R ${USER} ${PACKAGE_PATH}
1112
USER ${USER}
1213

1314
SHELL ["/bin/bash", "-c"]
1415
WORKDIR ${PACKAGE_PATH}
1516
RUN source /opt/spaceros/install/setup.bash && \
16-
colcon build
17+
colcon build --packages-select copilot --install-base /opt/spaceros/install/ && \
18+
colcon build --packages-select test_requirements --install-base /opt/spaceros/install/
19+
20+
ADD screenrc /home/spaceros-user/.screenrc
21+
USER root
22+
ADD screenrc /root/.screenrc
23+
RUN chown -R spaceros-user /home/spaceros-user/.screenrc
24+
USER spaceros-user

ogma-core/templates/ros/screenrc

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
deflogin off
2+
startup_message off
3+
4+
chdir /demo
5+
screen -t "Copilot RV" bash -c 'bash --init-file <(echo "source /home/spaceros-user/spaceros/install/setup.bash; set -x; ros2 run copilot copilot")'
6+
7+
{{#testingApps}}
8+
split
9+
focus
10+
screen -t "{{nodeName}}" bash -c 'bash --init-file <(echo "source /home/spaceros-user/spaceros/install/setup.bash; set -x; ros2 run {{nodePackage}} {{nodeName}}")'
11+
12+
{{/testingApps}}
13+
split
14+
focus
15+
screen -t "Requirements testing" bash -c 'sleep 2; bash --init-file <( echo "source /home/spaceros-user/spaceros/install/setup.bash; set -x; ros2 run test_requirements test_requirements")'
16+
17+
split
18+
focus
19+
screen -t "<interactive shell>" bash -c 'bash --init-file <(echo "echo This is an interactive shell. Send data to topics with ros2 topic pub \<type\> \<data\>; source /home/spaceros-user/spaceros/install/setup.bash")'
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
cmake_minimum_required(VERSION 3.8)
2+
project(test_requirements)
3+
4+
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
5+
add_compile_options(-Wall -Wextra -Wpedantic)
6+
endif()
7+
8+
# find dependencies
9+
find_package(ament_cmake REQUIRED)
10+
find_package(rclcpp REQUIRED)
11+
find_package(std_msgs REQUIRED)
12+
13+
# Uncomment to enable compiling the requirement tests
14+
add_executable(test_requirements src/test_requirements.cpp)
15+
ament_target_dependencies(test_requirements rclcpp std_msgs)
16+
17+
install(TARGETS
18+
test_requirements
19+
DESTINATION lib/${PROJECT_NAME})
20+
21+
if(BUILD_TESTING)
22+
find_package(ament_lint_auto REQUIRED)
23+
ament_lint_auto_find_test_dependencies()
24+
endif()
25+
26+
ament_package()
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?xml version="1.0"?>
2+
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
3+
<package format="3">
4+
<name>test_requirements</name>
5+
<version>0.0.0</version>
6+
<description>TODO: Package description</description>
7+
<maintainer email="[email protected]">root</maintainer>
8+
<license>TODO: License declaration</license>
9+
10+
<buildtool_depend>ament_cmake</buildtool_depend>
11+
<depend>rclcpp</depend>
12+
<depend>std_msgs</depend>
13+
14+
<test_depend>ament_lint_auto</test_depend>
15+
<test_depend>ament_lint_common</test_depend>
16+
17+
<export>
18+
<build_type>ament_cmake</build_type>
19+
</export>
20+
</package>

0 commit comments

Comments
 (0)