Skip to content

Commit b09b831

Browse files
authored
add json schema for configs (#27)
* add json schema for configs inferred from demos/config_solo12.yaml * json schema: add ALT and AUTO as valid SearchMethods per joint_calibrator comment in demos/config_solo12.yaml * demos: add schema declaration to config files * json schema: allow non-ints for joint_calibrator.{Kp,T} * ci: add a job to validate demos' config files * json schema: fix $schema version * json schema: add descriptions to items from documentation/configuration.md * demos: use actual json schema url
1 parent 24e5f86 commit b09b831

File tree

4 files changed

+216
-0
lines changed

4 files changed

+216
-0
lines changed

.github/workflows/demos.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: Demos
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
validate-configs:
7+
name: Validate configurations
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v4
11+
- name: json-yaml-validate
12+
uses: GrantBirki/[email protected]
13+
with:
14+
json_schema: ./schemas/robot.schema.json
15+
yaml_as_json: true
16+
files: |
17+
demos/config_solo12.yaml
18+
demos/config_testbench.yaml

demos/config_solo12.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# yaml-language-server: $schema=https://raw.githubusercontent.com/open-dynamic-robot-initiative/odri_control_interface/main/schemas/robot.schema.json
2+
13
robot:
24
interface: enp5s0f1
35
joint_modules:

demos/config_testbench.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# yaml-language-server: $schema=https://raw.githubusercontent.com/open-dynamic-robot-initiative/odri_control_interface/main/schemas/robot.schema.json
2+
13
robot:
24
interface: enp2s0
35
joint_modules:

schemas/robot.schema.json

Lines changed: 194 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,194 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema#",
3+
"$ref": "#/definitions/FullConfiguration",
4+
"definitions": {
5+
"FullConfiguration": {
6+
"type": "object",
7+
"additionalProperties": false,
8+
"properties": {
9+
"robot": {
10+
"$ref": "#/definitions/Robot"
11+
},
12+
"joint_calibrator": {
13+
"$ref": "#/definitions/JointCalibrator"
14+
}
15+
},
16+
"required": ["joint_calibrator", "robot"],
17+
"title": "Full configuration",
18+
"description": "Include the robot and joint calibrator configurations"
19+
},
20+
"JointCalibrator": {
21+
"type": "object",
22+
"additionalProperties": false,
23+
"properties": {
24+
"search_methods": {
25+
"type": "array",
26+
"items": {
27+
"$ref": "#/definitions/SearchMethod"
28+
}
29+
},
30+
"position_offsets": {
31+
"type": "array",
32+
"description": "Angular position offset between the position of the index on the coding wheel and the zero position of the actuator.",
33+
"items": {
34+
"type": "number"
35+
}
36+
},
37+
"calib_order": {
38+
"type": "array",
39+
"description": "Optional calibration order for the joints. Joints with the lowest values start looking for the indexes first while the others are not moving. Once they have found it, they wait in their associated position in calib_pos field. You can set all values to 0 if you want to calibrate all joints at the same time. With the example values, the HFE and Knee joints of the leg are calibrated first, then the leg fold up. That way there is less risk to hit something while the HAA joints are moving to find their indexes.",
40+
"items": {
41+
"type": "integer"
42+
}
43+
},
44+
"calib_pos": {
45+
"type": "array",
46+
"description": "The waiting position for joints after they have found their indexes (used with calib_order).",
47+
"items": {
48+
"type": "number"
49+
}
50+
},
51+
"Kp": {
52+
"description": "The proportional gain of the PD controller used during the calibration process, in Nm/rad.",
53+
"type": "number"
54+
},
55+
"Kd": {
56+
"description": "The derivative gain of the PD controller used during the calibration process, in Nm/(rad/s).",
57+
"type": "number"
58+
},
59+
"T": {
60+
"description": "The period of the sinus movement used when looking for indexes, in seconds.",
61+
"type": "number"
62+
},
63+
"dt": {
64+
"description": "The control time step during the calibration process, in seconds.",
65+
"type": "number"
66+
}
67+
},
68+
"required": [
69+
"Kd",
70+
"Kp",
71+
"T",
72+
"calib_order",
73+
"calib_pos",
74+
"dt",
75+
"position_offsets",
76+
"search_methods"
77+
],
78+
"title": "JointCalibrator"
79+
},
80+
"Robot": {
81+
"type": "object",
82+
"description": "general information about the robot such as motor ordering, joint limits or orientation of the IMU with respect to the body frame",
83+
"additionalProperties": false,
84+
"properties": {
85+
"interface": {
86+
"type": "string",
87+
"description": "Name of the interface to communicate with the robot (you can check with ifconfig if you are unsure)."
88+
},
89+
"joint_modules": {
90+
"$ref": "#/definitions/JointModules"
91+
},
92+
"imu": {
93+
"$ref": "#/definitions/Imu"
94+
}
95+
},
96+
"required": ["imu", "interface", "joint_modules"],
97+
"title": "Robot"
98+
},
99+
"Imu": {
100+
"type": "object",
101+
"additionalProperties": false,
102+
"properties": {
103+
"rotate_vector": {
104+
"type": "array",
105+
"description": "Mapping from IMU axes to body axes.",
106+
"items": {
107+
"type": "integer"
108+
}
109+
},
110+
"orientation_vector": {
111+
"type": "array",
112+
"description": "Mapping from IMU orientation (as a quaternion) to body orientation. Can be useful if the IMU is mounted upside-down on the robot.",
113+
"items": {
114+
"type": "integer"
115+
}
116+
}
117+
},
118+
"required": ["orientation_vector", "rotate_vector"],
119+
"title": "Imu"
120+
},
121+
"JointModules": {
122+
"type": "object",
123+
"additionalProperties": false,
124+
"properties": {
125+
"motor_numbers": {
126+
"type": "array",
127+
"description": "Mapping between the hardware order of the motors and their control order",
128+
"items": {
129+
"type": "integer"
130+
}
131+
},
132+
"motor_constants": {
133+
"type": "number",
134+
"description": "Torque constant of the motors in Nm/A"
135+
},
136+
"gear_ratios": {
137+
"type": "number",
138+
"description": "Gear ratio of the actuator modules"
139+
},
140+
"max_currents": {
141+
"type": "number",
142+
"description": "Absolute limit for the current sent to the motors in A"
143+
},
144+
"reverse_polarities": {
145+
"type": "array",
146+
"description": "Whether motors have been assembled on the robot in such a way that their hardware positive direction of rotation is actually reversed compared to the control positive direction of rotation.",
147+
"items": {
148+
"type": "boolean"
149+
}
150+
},
151+
"lower_joint_limits": {
152+
"type": "array",
153+
"description": "Lower joint limits for the actuators, under which the low-level control automatically switches to a security mode which applies damping on all joints.",
154+
"items": {
155+
"type": "number"
156+
}
157+
},
158+
"upper_joint_limits": {
159+
"type": "array",
160+
"description": "Upper joint limits for the actuators, above which the low-level control automatically switches to a security mode which applies damping on all joints.",
161+
"items": {
162+
"type": "number"
163+
}
164+
},
165+
"max_joint_velocities": {
166+
"type": "number",
167+
"description": "Absolute limit for the joint velocities, above which the low-level control automatically switches to a security mode which applies damping on all joints."
168+
},
169+
"safety_damping": {
170+
"type": "number",
171+
"description": "Value of the damping coefficient for the security mode, in Nm/(rad/s)."
172+
}
173+
},
174+
"required": [
175+
"gear_ratios",
176+
"lower_joint_limits",
177+
"max_currents",
178+
"max_joint_velocities",
179+
"motor_constants",
180+
"motor_numbers",
181+
"reverse_polarities",
182+
"safety_damping",
183+
"upper_joint_limits"
184+
],
185+
"title": "JointModules"
186+
},
187+
"SearchMethod": {
188+
"type": "string",
189+
"description": "The index search strategy for each motor, can be POS, NEG, ALT, AUTO. If POS, the motor will search the index by going in the positive direction from its starting position until it reaches it. If NEG, it will go in the negative direction. If ALT, the motor will do back-and-forth movements of increasing amplitude around its starting position till the index is reached. AUTO automatically chooses the strategy based on the position offset value.",
190+
"enum": ["POS", "NEG", "ALT", "AUTO"],
191+
"title": "SearchMethod"
192+
}
193+
}
194+
}

0 commit comments

Comments
 (0)