[Newton] Splits the Contact Sensor Configurations into base and Newton#4708
[Newton] Splits the Contact Sensor Configurations into base and Newton#4708camevor wants to merge 6 commits intoisaac-sim:dev/newtonfrom
Conversation
- Extract NewtonContactSensorCfg into its own file with shape-level fields (sensor_shape_prim_expr, filter_shape_prim_expr), sensor_body_prim_expr property alias, from_base_cfg factory, and __post_init__ guards for unsupported options - Rename base ContactSensorCfg fields: filter_prim_paths_expr → filter_body_prim_expr, drop shape_path and filter_shape_paths_expr (moved to Newton subclass) - Resolve regex expressions to list[int] indices in add_contact_sensor via resolve_matching_names, removing flipped_match / match_fn - Simplify ContactSensor._initialize_impl — pass cfg fields directly instead of building joined regex strings - Update interactive_scene.py env-regex expansion to use renamed fields - Update docstring references in contact_sensor_data.py
Greptile SummaryRefactors contact sensor configuration to separate base (body-level) and Newton (shape-level) implementations, renames config fields for consistency ( Key Changes:
Issues Found:
Confidence Score: 4/5
Important Files Changed
Class Diagram%%{init: {'theme': 'neutral'}}%%
classDiagram
class ContactSensorCfg {
+str prim_path
+list[str] filter_prim_paths_expr
+bool track_air_time
+float force_threshold = 1.0
Body-level sensing only
}
class NewtonContactSensorCfg {
+list[str] sensor_shape_prim_expr
+list[str] filter_shape_prim_expr
+float force_threshold = 0.0
+sensor_body_prim_expr property
+from_base_cfg() classmethod
+__post_init__()
Shape-level sensing support
}
class NewtonManager {
+add_contact_sensor(body_names_expr, shape_names_expr, contact_partners_body_expr, contact_partners_shape_expr)
Resolves regex to list[int] indices
}
class ContactSensor {
+__init__(cfg)
Auto-converts ContactSensorCfg
}
ContactSensorCfg <|-- NewtonContactSensorCfg : extends
NewtonContactSensorCfg --> ContactSensor : configures
ContactSensor --> NewtonManager : uses add_contact_sensor()
NewtonManager --> NewtonContactSensor : creates Newton sensor with indices
Last reviewed commit: 241caa0 |
source/isaaclab_newton/isaaclab_newton/sensors/contact_sensor/contact_sensor.py
Outdated
Show resolved
Hide resolved
source/isaaclab/isaaclab/sensors/contact_sensor/contact_sensor_cfg.py
Outdated
Show resolved
Hide resolved
| cfg: NewtonContactSensorCfg | ||
| """The configuration parameters.""" | ||
|
|
||
| def __init__(self, cfg: ContactSensorCfg): | ||
| def __init__(self, cfg: ContactSensorCfg | NewtonContactSensorCfg): | ||
| """Initializes the contact sensor object. | ||
|
|
||
| Args: | ||
| cfg: The configuration parameters. | ||
| """ | ||
| # initialize base class | ||
| from isaaclab.sensors.contact_sensor.contact_sensor_cfg import ContactSensorCfg | ||
|
|
||
| from .contact_sensor_cfg import NewtonContactSensorCfg | ||
|
|
||
| if isinstance(cfg, NewtonContactSensorCfg): | ||
| pass | ||
| elif isinstance(cfg, ContactSensorCfg): | ||
| cfg = NewtonContactSensorCfg.from_base_cfg(cfg) | ||
| else: | ||
| raise TypeError("Invalid config: {cfg}") |
There was a problem hiding this comment.
Might need to add:
# check if max_contact_data_count_per_prim is set
if self.cfg.max_contact_data_count_per_prim is not None:
raise ValueError("Newton doesn't use max_contact_data_count_per_prim, setting this parameter has no impact on the simulation.")
# check if force_threshold is set
if self.cfg.force_threshold is None:
self.cfg.force_threshold = 0.0There was a problem hiding this comment.
No sure if the raise is not a bit too violent. A warning might be enough.
There was a problem hiding this comment.
Actually, the if self.cfg.force_threshold is None: self.cfg.force_threshold = 0.0 is not needed nevermind that. You apply the overload.
There was a problem hiding this comment.
The data count per prim is handled in the NewtonContactSensorCfg's __post_init__. Will handle the force here though 👍
3805d55 to
589af7a
Compare
Description
Separate
NewtonContactSensorCfgwith shape-level fields, rename base config fields for consistency, and resolve regex expressions to integer indices in
add_contact_sensorinstead of passing raw patternsthrough
match_fn.NewtonContactSensorCfginto its own file with shape-level fields (sensor_shape_prim_expr,filter_shape_prim_expr),sensor_body_prim_exprproperty alias,from_base_cfgfactory, and__post_init__guards for unsupported optionsContactSensorCfgfields:filter_prim_paths_expr→filter_body_prim_expr, dropshape_pathandfilter_shape_paths_expr(moved to Newton subclass)list[int]indices inadd_contact_sensorviaresolve_matching_names, removingflipped_match/match_fnContactSensor._initialize_impl— pass cfg fields directly instead of building joined regex stringsinteractive_scene.pyenv-regex expansion to use renamed fieldscontact_sensor_data.pyFixes # (issue)
Type of change
Screenshots
Please attach before and after screenshots of the change if applicable.
Checklist
pre-commitchecks with./isaaclab.sh --formatconfig/extension.tomlfileCONTRIBUTORS.mdor my name already exists there