linking/*.link.json
6 minute read
There is one link file per feature, named after the feature that reads it. The standard robot application ships fourteen:
/etc/motorcortex/config/
└── linking
├── agv-control.link.json
├── base.link.json
├── collision-detector.link.json
├── force-dimension.link.json
├── joystick.link.json
├── machine-control.link.json
├── manipulator-control.link.json
├── motion-player.link.json
├── referencing.link.json
├── safety-selector.link.json
├── setpoint-generator.link.json
├── signal-generator.link.json
├── space-nav.link.json
└── weaving-motion.link.json
Nothing scans this directory. Each file is named by the Linking key of its feature block in config.json, so a feature with no Linking key reads no link file, and a file nobody names is never loaded:
"ManipulatorControl": { "Linking": "linking/manipulator-control.link.json" },
"UdpComm": { "Linking": "udp/udp.link.json" }
A Linking value may also be an array, which is how base.link.json and referencing.link.json are both loaded for the base feature.
General
In xxx.link.json you can set motorcortex parameters and define links between these parameters. This way you can communicate data from one Module to another Module. This works also across Tasks.
You are only allowed to link parameters that have the same data type and size on both ends of the link. It is not allowed to link parameterType: output as Destination, an output can only be a Source.
Every option a *.link.json accepts is listed in the JSON schema, which you can download here: linking.schema.v4.json. Version 4 is the current one — earlier copies in this folder are kept only for existing files and describe fewer fields.
xxx.link.json example
{
"Version": "1.0.0",
"Groups": [
{
"Name": "LinkExample",
"SystemMode": "All",
"Links": [
{
"Source": {
"Path": "root/Control/boolOutput"
},
"Destination": {
"Path": "root/Logic/boolInput"
}
}
]
},
{
"Name": "Simulation",
"SystemMode": "Simulation",
"Links": [
{
"Source": {
"Path": "root/Simulator/doubleOutput"
},
"Destination": {
"Path": "root/Control/doubleInput"
}
}
]
}
]
}
xxx.link.json explained
Inside the xxx.link.json you can create multiple "Groups", a group contains a "Name" and information about the action like: "links" and/or "setParameters". With the "systemMode" you can specify for which Application mode this group should be active. If you want to disable or enable groups from the xxx.link.json, you can use the "Enable": function.
#Version
You can apply a version to your xxx.link.json with "Version":, check out linking.schema.v4.json for how to set up your versioning.
#Groups
You can create your own "Group":, to assign a link or set a parameter.
#Name
Each group contains a "Name": in here you can specify a name to your liking.
#SystemMode
Inside the config.json you can define the Application Mode, per mode, different links can be created in the xxx.link.json. For each group the "systemMode": can be defined (All, Production or Simulation) with the "systemMode", you can specify in which Application Mode the group is active:
| Application Mode | SystemMode |
|---|---|
Production |
All or Production |
Simulation |
All or Simulation |
#Enable
With the "Enable": flag you can enable or disable the current group, this is done by defining a True, or False statement.
#SetParameters
SetParameters are used to change the the "Value": of the specified "Path":.
| Parameter | Description |
|---|---|
"Value": |
Here you can specify any type of Value that you want to assign to the Path. |
"Force": |
Here you can specify if you want to Force the value, to the Path, This can either be True or False. |
"Path": |
Here you can specify the Path, to which the Value is written. (path example: root/.../...) |
"Index": |
Here you can specify the Index expressed as number, index 0 is equal to the the first element in a array[0]. |
"Length": |
Here you can specify the Length of elements expressed as a number. Example: If the "Index": 1, with "Length": 2, Index 1 and 2 are written to the Destination. |
"Name": "Simulation",
"SystemMode": "Simulation",
"SetParameters":
{
"Path": "root/Logic/:busToState/estop_buttons_channel1",
"Value": [
true,
true,
true,
true,
true,
true,
true,
true
],
"Force": true
}
#Links
"Links": are used to link a source to a destination, it is allowed to link a source to multiple destinations, but it is not allowed to link multiple sources to one destination.
In the "Source": and "Destination":: you fill in your preferred path (root/.../...). To the Source you can specify information like: "Gain":, "Offset":, "Index": , "Length":, "Invert": and for the Destination only a "Index": and "Length".
| Parameter | Description |
|---|---|
"Source": |
Here you can specify the Path of the Source that you want to link to the Destination. |
"Destination": |
Here you can specify the path of the destination. |
"Invert": |
Here you can invert the Source, invert is only applied to a value 0 or 1. |
"Gain": |
Here you can specify the Gain, the Source is multiplied by the defined Gain to get a new Destination value. |
"Offset": |
Here you can specify the Offset applied to the Destination. |
"Index": |
Here you can specify the Index expressed as number, index 0 is equal to the the first element in a array[0]. |
"Length": |
Here you can specify the Length of elements expressed as a number. Example: If the "Index": 1, with "Length": 2, you will write only Index 1 and 2 to the Destination. |
Note
The order of information sending to the Destination is first the Offset, after which the Source * Gain is added.
"Name": "Joystick",
"SystemMode": "All",
"Enable": true,
"Links": [
{
"Gain": 1.0,
"Offset": 0.0,
"Source": {
"Path": "root/Joystick1/axes",
"Index": 4,
"Length": 1
},
"Destination": {
"Path": "root/Control/hostInJointVelocity",
"Index": 0
}
}
]