Purpose
This guide explains how to safely extend and maintain the embObjMotionControl parser after the YARP4 modernization work.
The goals of the refactor are:
- improve maintainability and readability,
- keep behavior explicit and predictable,
- reduce noisy startup logs while preserving full configuration visibility.
Architecture Intent
The parser architecture follows a clear separation of concerns:
A key design point is optional-parameter tracking through registerOptionalParameter().
Instead of flooding yarprobotinterface output with repeated messages such as "parameter X missing, using default Y" for each missing key, the parser records optional/defaulted parameters and prints one consolidated summary table through printOptionalParametersTable().
This keeps logs readable and makes users more aware of the effective configuration at a glance.
Files To Update When Adding Or Changing Parameters
When adding a new parser parameter, or changing an existing one, update all applicable layers:
- Type/schema layer
- Default-value layer
- Parser layer
- Parser interface layer
- Documentation layer
Standard Parser Pattern To Reuse
Use this order consistently:
- Read the group
- Use GetGroupBottle() for mandatory/optional group retrieval.
- Read parameter values
- Use extractGroup() for joint-wise vectors/lists.
- For scalar values, use Bottle find checks and type checks.
- Validate early
- Verify type, cardinality, enum compatibility, and range.
- Fail fast with board-aware and joint-aware error messages.
- Handle optional parameters
- If missing and optional, assign default from _defaultSettings.
- Call registerOptionalParameter(parameterName, defaultValue, wasUsed).
- Assign final values
- Write into typed per-joint/per-group destination structures.
- Report once
- Avoid repeated warning spam for every missing key.
- Use the consolidated optional-parameter summary table.
Optional Parameter Logging Policy
Preferred behavior:
- Mandatory missing or invalid parameter: fail and report clear error.
- Optional missing parameter: apply default and register it.
- End of parsing/open: print a single summary table of optional/defaulted parameters.
Benefits:
- cleaner logs,
- easier troubleshooting,
- better user awareness of effective runtime configuration.
Backward Compatibility Policy
When renaming or changing semantics of a parameter:
- keep old key support for one transition cycle when possible,
- parse new key first and old key as fallback,
- emit a single compatibility warning (not repeated per joint),
- document deprecation and removal timeline.
Validation Checklist For Pull Requests
Use this checklist before merging parser changes:
- Type exists and is correctly placed in embObjMotionControlConfigTypes.h.
- Default exists and is correctly placed in embObjMotionControlDefaults.h.
- Parser reads key and validates value in eomcParser.cpp.
- Optional parameter handling uses registerOptionalParameter() where applicable.
- Error messages include board context and joint context when relevant.
- No noisy per-parameter default warnings were added.
- Summary-table behavior remains intact.
- Related docs were updated.
- Existing robot configuration compatibility was considered.
- The corresponding template for the target version was updated in robots-configuration iCub templates: https://github.com/robotology/robots-configuration/tree/master/iCubTemplates.
Common Pitfalls
- Adding parsing logic without adding typed storage.
- Adding typed storage without adding defaults.
- Using hardcoded magic defaults in parser code.
- Logging one warning per joint for the same optional key.
- Forgetting consistency checks across JOINTSET_CFG constraints.
- Changing key names without compatibility fallback.