Skip to content

Commit

Permalink
Fix Array parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
ipa-nhg committed Feb 7, 2024
1 parent 6a92417 commit 4b9f44a
Show file tree
Hide file tree
Showing 79 changed files with 6,309 additions and 6,433 deletions.
85 changes: 85 additions & 0 deletions docu/ParametersAPI.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
## Parameters API

The types of parameters supported by the ROS tooling are the following:

* Boolean (true or false)
* Integer
* Double
* String
* Base64
* List
* Array
* Struct

and their description is allowed at ROS and ROSSystem model level.

For the complete definition of parameters the user has to open the ROS model editor, where the language format is the following:
```
**parameters:**
ParameterName:
**type:** ParameterType
**value:** ParameterValue
```

For example (for a .ros2 file):

```
test_parameters:
artifacts:
test_parameters:
node: params_example
parameters:
string_test:
type: String
bool_test:
type: Boolean
array_test:
type: Array [String]
base64_test:
type: Base64
double_test:
type: Double
integer_test:
type: Integer
list_test:
type: List [Integer,Integer,String]
array_test:
type: Array [String]
struct_test:
type: Struct [hello Integer, what String]
```

These parameters can be re-set at Rossystem level (that means for ROS developers, the case of the set of a new parameter value within a node include on a ROS launch file). For the tooling the format is the following:

```
- ParameterName : ParameterReferenceInRos2File
**value:** ParameterValue
```

Continuing the previous example, the parameters redefinition looks:

```
test:
nodes:
params_node:
from: "test_parameters.params_example"
parameters:
- test_s : "test_parameters::string_test"
value: "hello"
- test_b : "test_parameters::bool_test"
value: true
- test_d : "test_parameters::double_test"
value: 1.1
- test_i : "test_parameters::integer_test"
value: 1
- test_l: "test_parameters::list_test"
value: [1,1,"hello"]
- test_a: "test_parameters::array_test"
value: ["hello", "hola", "hallo"]
- test_st: "test_parameters::struct_test"
value: [
hello: 1
what: "test"]
```
The model definition of parameters is also consider for the autogeneration of launch files and the component interfaces. Complementarily, and because of the complexity of the format, the .ros, the .componentinterface and the .rossystem language validators contain rules to check that the value given to the parameter has the correct type and also help messages that together with the auto-complete function (Ctrl+Space) facilitate to the user the creation of parameters.

13 changes: 12 additions & 1 deletion docu/RosModelDescription.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,17 @@ The only remarkable difference with the ROS 1 model is that the quality of servi
- profile: default_qos / sensor_qos / services_qos/ parameter_qos
- reliability: best_effort / reliable

The type of supported parameters are:
- Boolean
- Double
- String
- Integer
- Base64
- List [Type, Type]
- Array [Type]
- Struct [Name Type, Name Type]

For more details please check the following [examples](ParametersAPI.md).

See the following example for the [arucos_ros](https://github.com/pal-robotics/aruco_ros) driver:

Expand Down Expand Up @@ -188,4 +199,4 @@ The textual editor contains checker embedded, for example:

It incorporates also the auto-complete function. This is available by pressing **Ctrl** + the space bar:

![alt text](images/RosModelAutocomplete.gif)
![alt text](images/RosModelAutocomplete.gif)
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ private static void init(ImmutableMap.Builder<AbstractElement, String> builder,
builder.put(grammarAccess.getParameterAnyTypeAccess().getGroup(), "rule__ParameterAnyType__Group__0");
builder.put(grammarAccess.getParameterAnyTypeAccess().getGroup_2(), "rule__ParameterAnyType__Group_2__0");
builder.put(grammarAccess.getParameterArrayTypeAccess().getGroup(), "rule__ParameterArrayType__Group__0");
builder.put(grammarAccess.getParameterArrayTypeAccess().getGroup_3(), "rule__ParameterArrayType__Group_3__0");
builder.put(grammarAccess.getParameterArrayTypeAccess().getGroup_4(), "rule__ParameterArrayType__Group_4__0");
builder.put(grammarAccess.getParameterListAccess().getGroup(), "rule__ParameterList__Group__0");
builder.put(grammarAccess.getParameterListAccess().getGroup_3(), "rule__ParameterList__Group_3__0");
builder.put(grammarAccess.getParameterAnyAccess().getGroup(), "rule__ParameterAny__Group__0");
Expand Down Expand Up @@ -137,7 +137,7 @@ private static void init(ImmutableMap.Builder<AbstractElement, String> builder,
builder.put(grammarAccess.getParameterBase64TypeAccess().getDefaultAssignment_2_1(), "rule__ParameterBase64Type__DefaultAssignment_2_1");
builder.put(grammarAccess.getParameterAnyTypeAccess().getDefaultAssignment_2_1(), "rule__ParameterAnyType__DefaultAssignment_2_1");
builder.put(grammarAccess.getParameterArrayTypeAccess().getTypeAssignment_2(), "rule__ParameterArrayType__TypeAssignment_2");
builder.put(grammarAccess.getParameterArrayTypeAccess().getDefaultAssignment_3_1(), "rule__ParameterArrayType__DefaultAssignment_3_1");
builder.put(grammarAccess.getParameterArrayTypeAccess().getDefaultAssignment_4_1(), "rule__ParameterArrayType__DefaultAssignment_4_1");
builder.put(grammarAccess.getParameterListAccess().getValueAssignment_2(), "rule__ParameterList__ValueAssignment_2");
builder.put(grammarAccess.getParameterListAccess().getValueAssignment_3_1(), "rule__ParameterList__ValueAssignment_3_1");
builder.put(grammarAccess.getParameterAnyAccess().getValueAssignment_2_1(), "rule__ParameterAny__ValueAssignment_2_1");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ private static void init(ImmutableMap.Builder<AbstractElement, String> builder,
builder.put(grammarAccess.getParameterAnyTypeAccess().getGroup(), "rule__ParameterAnyType__Group__0");
builder.put(grammarAccess.getParameterAnyTypeAccess().getGroup_2(), "rule__ParameterAnyType__Group_2__0");
builder.put(grammarAccess.getParameterArrayTypeAccess().getGroup(), "rule__ParameterArrayType__Group__0");
builder.put(grammarAccess.getParameterArrayTypeAccess().getGroup_3(), "rule__ParameterArrayType__Group_3__0");
builder.put(grammarAccess.getParameterArrayTypeAccess().getGroup_4(), "rule__ParameterArrayType__Group_4__0");
builder.put(grammarAccess.getParameterListAccess().getGroup(), "rule__ParameterList__Group__0");
builder.put(grammarAccess.getParameterListAccess().getGroup_3(), "rule__ParameterList__Group_3__0");
builder.put(grammarAccess.getParameterAnyAccess().getGroup(), "rule__ParameterAny__Group__0");
Expand Down Expand Up @@ -229,7 +229,7 @@ private static void init(ImmutableMap.Builder<AbstractElement, String> builder,
builder.put(grammarAccess.getParameterBase64TypeAccess().getDefaultAssignment_2_1(), "rule__ParameterBase64Type__DefaultAssignment_2_1");
builder.put(grammarAccess.getParameterAnyTypeAccess().getDefaultAssignment_2_1(), "rule__ParameterAnyType__DefaultAssignment_2_1");
builder.put(grammarAccess.getParameterArrayTypeAccess().getTypeAssignment_2(), "rule__ParameterArrayType__TypeAssignment_2");
builder.put(grammarAccess.getParameterArrayTypeAccess().getDefaultAssignment_3_1(), "rule__ParameterArrayType__DefaultAssignment_3_1");
builder.put(grammarAccess.getParameterArrayTypeAccess().getDefaultAssignment_4_1(), "rule__ParameterArrayType__DefaultAssignment_4_1");
builder.put(grammarAccess.getParameterListAccess().getValueAssignment_2(), "rule__ParameterList__ValueAssignment_2");
builder.put(grammarAccess.getParameterListAccess().getValueAssignment_3_1(), "rule__ParameterList__ValueAssignment_3_1");
builder.put(grammarAccess.getParameterAnyAccess().getValueAssignment_2_1(), "rule__ParameterAny__ValueAssignment_2_1");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@ import de.fraunhofer.ipa.ros.services.BasicsGrammarAccess;
tokenNameToValue.put("Node", "'node'");
tokenNameToValue.put("Time", "'time'");
tokenNameToValue.put("Type", "'type'");
tokenNameToValue.put("Array", "'Array'");
tokenNameToValue.put("Int16", "'int16'");
tokenNameToValue.put("Int32", "'int32'");
tokenNameToValue.put("Int64", "'int64'");
tokenNameToValue.put("Type_1", "'type:'");
tokenNameToValue.put("Uint8", "'uint8'");
tokenNameToValue.put("Value", "'value'");
tokenNameToValue.put("Array", "'Array:'");
tokenNameToValue.put("Base64", "'Base64'");
tokenNameToValue.put("Double", "'Double'");
tokenNameToValue.put("Header", "'Header'");
Expand Down Expand Up @@ -4083,9 +4083,9 @@ rule__ParameterArrayType__Group__0__Impl
}
:
(
{ before(grammarAccess.getParameterArrayTypeAccess().getBEGINTerminalRuleCall_0()); }
RULE_BEGIN
{ after(grammarAccess.getParameterArrayTypeAccess().getBEGINTerminalRuleCall_0()); }
{ before(grammarAccess.getParameterArrayTypeAccess().getArrayKeyword_0()); }
Array
{ after(grammarAccess.getParameterArrayTypeAccess().getArrayKeyword_0()); }
)
;
finally {
Expand All @@ -4110,9 +4110,9 @@ rule__ParameterArrayType__Group__1__Impl
}
:
(
{ before(grammarAccess.getParameterArrayTypeAccess().getArrayKeyword_1()); }
Array
{ after(grammarAccess.getParameterArrayTypeAccess().getArrayKeyword_1()); }
{ before(grammarAccess.getParameterArrayTypeAccess().getLeftSquareBracketKeyword_1()); }
LeftSquareBracket
{ after(grammarAccess.getParameterArrayTypeAccess().getLeftSquareBracketKeyword_1()); }
)
;
finally {
Expand Down Expand Up @@ -4164,9 +4164,9 @@ rule__ParameterArrayType__Group__3__Impl
}
:
(
{ before(grammarAccess.getParameterArrayTypeAccess().getGroup_3()); }
(rule__ParameterArrayType__Group_3__0)?
{ after(grammarAccess.getParameterArrayTypeAccess().getGroup_3()); }
{ before(grammarAccess.getParameterArrayTypeAccess().getRightSquareBracketKeyword_3()); }
RightSquareBracket
{ after(grammarAccess.getParameterArrayTypeAccess().getRightSquareBracketKeyword_3()); }
)
;
finally {
Expand All @@ -4190,63 +4190,63 @@ rule__ParameterArrayType__Group__4__Impl
}
:
(
{ before(grammarAccess.getParameterArrayTypeAccess().getENDTerminalRuleCall_4()); }
RULE_END
{ after(grammarAccess.getParameterArrayTypeAccess().getENDTerminalRuleCall_4()); }
{ before(grammarAccess.getParameterArrayTypeAccess().getGroup_4()); }
(rule__ParameterArrayType__Group_4__0)?
{ after(grammarAccess.getParameterArrayTypeAccess().getGroup_4()); }
)
;
finally {
restoreStackSize(stackSize);
}


rule__ParameterArrayType__Group_3__0
rule__ParameterArrayType__Group_4__0
@init {
int stackSize = keepStackSize();
}
:
rule__ParameterArrayType__Group_3__0__Impl
rule__ParameterArrayType__Group_3__1
rule__ParameterArrayType__Group_4__0__Impl
rule__ParameterArrayType__Group_4__1
;
finally {
restoreStackSize(stackSize);
}

rule__ParameterArrayType__Group_3__0__Impl
rule__ParameterArrayType__Group_4__0__Impl
@init {
int stackSize = keepStackSize();
}
:
(
{ before(grammarAccess.getParameterArrayTypeAccess().getDefaultKeyword_3_0()); }
{ before(grammarAccess.getParameterArrayTypeAccess().getDefaultKeyword_4_0()); }
Default
{ after(grammarAccess.getParameterArrayTypeAccess().getDefaultKeyword_3_0()); }
{ after(grammarAccess.getParameterArrayTypeAccess().getDefaultKeyword_4_0()); }
)
;
finally {
restoreStackSize(stackSize);
}

rule__ParameterArrayType__Group_3__1
rule__ParameterArrayType__Group_4__1
@init {
int stackSize = keepStackSize();
}
:
rule__ParameterArrayType__Group_3__1__Impl
rule__ParameterArrayType__Group_4__1__Impl
;
finally {
restoreStackSize(stackSize);
}

rule__ParameterArrayType__Group_3__1__Impl
rule__ParameterArrayType__Group_4__1__Impl
@init {
int stackSize = keepStackSize();
}
:
(
{ before(grammarAccess.getParameterArrayTypeAccess().getDefaultAssignment_3_1()); }
(rule__ParameterArrayType__DefaultAssignment_3_1)
{ after(grammarAccess.getParameterArrayTypeAccess().getDefaultAssignment_3_1()); }
{ before(grammarAccess.getParameterArrayTypeAccess().getDefaultAssignment_4_1()); }
(rule__ParameterArrayType__DefaultAssignment_4_1)
{ after(grammarAccess.getParameterArrayTypeAccess().getDefaultAssignment_4_1()); }
)
;
finally {
Expand Down Expand Up @@ -6870,15 +6870,15 @@ finally {
restoreStackSize(stackSize);
}

rule__ParameterArrayType__DefaultAssignment_3_1
rule__ParameterArrayType__DefaultAssignment_4_1
@init {
int stackSize = keepStackSize();
}
:
(
{ before(grammarAccess.getParameterArrayTypeAccess().getDefaultParameterListParserRuleCall_3_1_0()); }
{ before(grammarAccess.getParameterArrayTypeAccess().getDefaultParameterListParserRuleCall_4_1_0()); }
ruleParameterList
{ after(grammarAccess.getParameterArrayTypeAccess().getDefaultParameterListParserRuleCall_3_1_0()); }
{ after(grammarAccess.getParameterArrayTypeAccess().getDefaultParameterListParserRuleCall_4_1_0()); }
)
;
finally {
Expand Down
Loading

0 comments on commit 4b9f44a

Please sign in to comment.