@@ -2091,34 +2091,34 @@ def __init__(
20912091 self .mjw_model .opt .run_collision_detection = use_mujoco_contacts
20922092
20932093 @event_scope
2094- def mujoco_warp_step (self ):
2094+ def _mujoco_warp_step (self ):
20952095 self ._mujoco_warp .step (self .mjw_model , self .mjw_data )
20962096
20972097 @event_scope
20982098 @override
20992099 def step (self , state_in : State , state_out : State , control : Control , contacts : Contacts , dt : float ):
21002100 if self .use_mujoco_cpu :
2101- self .apply_mjc_control (self .model , state_in , control , self .mj_data )
2101+ self ._apply_mjc_control (self .model , state_in , control , self .mj_data )
21022102 if self .update_data_interval > 0 and self ._step % self .update_data_interval == 0 :
21032103 # XXX updating the mujoco state at every step may introduce numerical instability
2104- self .update_mjc_data (self .mj_data , self .model , state_in )
2104+ self ._update_mjc_data (self .mj_data , self .model , state_in )
21052105 self .mj_model .opt .timestep = dt
21062106 self ._mujoco .mj_step (self .mj_model , self .mj_data )
2107- self .update_newton_state (self .model , state_out , self .mj_data )
2107+ self ._update_newton_state (self .model , state_out , self .mj_data )
21082108 else :
21092109 self .enable_rne_postconstraint (state_out )
2110- self .apply_mjc_control (self .model , state_in , control , self .mjw_data )
2110+ self ._apply_mjc_control (self .model , state_in , control , self .mjw_data )
21112111 if self .update_data_interval > 0 and self ._step % self .update_data_interval == 0 :
2112- self .update_mjc_data (self .mjw_data , self .model , state_in )
2112+ self ._update_mjc_data (self .mjw_data , self .model , state_in )
21132113 self .mjw_model .opt .timestep .fill_ (dt )
21142114 with wp .ScopedDevice (self .model .device ):
21152115 if self .mjw_model .opt .run_collision_detection :
2116- self .mujoco_warp_step ()
2116+ self ._mujoco_warp_step ()
21172117 else :
2118- self .convert_contacts_to_mjwarp (self .model , state_in , contacts )
2119- self .mujoco_warp_step ()
2118+ self ._convert_contacts_to_mjwarp (self .model , state_in , contacts )
2119+ self ._mujoco_warp_step ()
21202120
2121- self .update_newton_state (self .model , state_out , self .mjw_data )
2121+ self ._update_newton_state (self .model , state_out , self .mjw_data )
21222122 self ._step += 1
21232123 return state_out
21242124
@@ -2135,7 +2135,7 @@ def enable_rne_postconstraint(self, state_out: State):
21352135 print ("Setting model.sensor_rne_postconstraint True" )
21362136 m .sensor_rne_postconstraint = True
21372137
2138- def convert_contacts_to_mjwarp (self , model : Model , state_in : State , contacts : Contacts ):
2138+ def _convert_contacts_to_mjwarp (self , model : Model , state_in : State , contacts : Contacts ):
21392139 # Ensure the inverse shape mapping exists (lazy creation)
21402140 if self .newton_shape_to_mjc_geom is None :
21412141 self ._create_inverse_shape_mapping ()
@@ -2194,16 +2194,16 @@ def convert_contacts_to_mjwarp(self, model: Model, state_in: State, contacts: Co
21942194 @override
21952195 def notify_model_changed (self , flags : int ):
21962196 if flags & SolverNotifyFlags .BODY_INERTIAL_PROPERTIES :
2197- self .update_model_inertial_properties ()
2197+ self ._update_model_inertial_properties ()
21982198 if flags & SolverNotifyFlags .JOINT_PROPERTIES :
2199- self .update_joint_properties ()
2199+ self ._update_joint_properties ()
22002200 if flags & SolverNotifyFlags .JOINT_DOF_PROPERTIES :
2201- self .update_joint_dof_properties ()
2201+ self ._update_joint_dof_properties ()
22022202 if flags & SolverNotifyFlags .SHAPE_PROPERTIES :
2203- self .update_geom_properties ()
2203+ self ._update_geom_properties ()
22042204 self .update_pair_properties ()
22052205 if flags & SolverNotifyFlags .MODEL_PROPERTIES :
2206- self .update_model_properties ()
2206+ self ._update_model_properties ()
22072207 if flags & SolverNotifyFlags .CONSTRAINT_PROPERTIES :
22082208 self .update_eq_properties ()
22092209 self .update_mimic_eq_properties ()
@@ -2241,7 +2241,7 @@ def _data_is_mjwarp(data):
22412241 # Check if the data is a mujoco_warp Data object
22422242 return hasattr (data , "nworld" )
22432243
2244- def apply_mjc_control (self , model : Model , state : State , control : Control | None , mj_data : MjWarpData | MjData ):
2244+ def _apply_mjc_control (self , model : Model , state : State , control : Control | None , mj_data : MjWarpData | MjData ):
22452245 if control is None or control .joint_f is None :
22462246 if state .body_f is None :
22472247 return
@@ -2337,7 +2337,7 @@ def apply_mjc_control(self, model: Model, state: State, control: Control | None,
23372337 mj_data .ctrl [:] = ctrl .numpy ().flatten ()
23382338 mj_data .qfrc_applied [:] = qfrc .numpy ()
23392339
2340- def update_mjc_data (self , mj_data : MjWarpData | MjData , model : Model , state : State | None = None ):
2340+ def _update_mjc_data (self , mj_data : MjWarpData | MjData , model : Model , state : State | None = None ):
23412341 is_mjwarp = SolverMuJoCo ._data_is_mjwarp (mj_data )
23422342 if is_mjwarp :
23432343 # we have an MjWarp Data object
@@ -2380,7 +2380,7 @@ def update_mjc_data(self, mj_data: MjWarpData | MjData, model: Model, state: Sta
23802380 mj_data .qpos [:] = qpos .numpy ().flatten ()[: len (mj_data .qpos )]
23812381 mj_data .qvel [:] = qvel .numpy ().flatten ()[: len (mj_data .qvel )]
23822382
2383- def update_newton_state (
2383+ def _update_newton_state (
23842384 self ,
23852385 model : Model ,
23862386 state : State ,
@@ -2468,7 +2468,7 @@ def update_newton_state(
24682468 )
24692469
24702470 @staticmethod
2471- def find_body_collision_filter_pairs (
2471+ def _find_body_collision_filter_pairs (
24722472 model : Model ,
24732473 selected_bodies : nparray ,
24742474 colliding_shapes : nparray ,
@@ -2504,7 +2504,7 @@ def find_body_collision_filter_pairs(
25042504 return body_exclude_pairs
25052505
25062506 @staticmethod
2507- def color_collision_shapes (
2507+ def _color_collision_shapes (
25082508 model : Model , selected_shapes : nparray , visualize_graph : bool = False , shape_keys : list [str ] | None = None
25092509 ) -> nparray :
25102510 """
@@ -3083,13 +3083,13 @@ def get_custom_attribute(name: str) -> nparray | None:
30833083 colliding_shapes_per_world = len (colliding_shapes )
30843084
30853085 # filter out non-colliding bodies using excludes
3086- body_filters = self .find_body_collision_filter_pairs (
3086+ body_filters = self ._find_body_collision_filter_pairs (
30873087 model ,
30883088 selected_bodies ,
30893089 colliding_shapes ,
30903090 )
30913091
3092- shape_color = self .color_collision_shapes (
3092+ shape_color = self ._color_collision_shapes (
30933093 model , colliding_shapes , visualize_graph = False , shape_keys = model .shape_key
30943094 )
30953095
@@ -3819,9 +3819,9 @@ def get_body_name(body_idx: int) -> str:
38193819 self .mj_model = spec .compile ()
38203820 self .mj_data = mujoco .MjData (self .mj_model )
38213821
3822- self .update_mjc_data (self .mj_data , model , state )
3822+ self ._update_mjc_data (self .mj_data , model , state )
38233823
3824- # fill some MjWarp model fields that are outdated after update_mjc_data .
3824+ # fill some MjWarp model fields that are outdated after _update_mjc_data .
38253825 # just setting qpos0 to d.qpos leads to weird behavior here, needs
38263826 # to be investigated.
38273827
@@ -4090,7 +4090,7 @@ def get_body_name(body_idx: int) -> str:
40904090 )
40914091
40924092 # expand model fields that can be expanded:
4093- self .expand_model_fields (self .mjw_model , nworld )
4093+ self ._expand_model_fields (self .mjw_model , nworld )
40944094
40954095 # update solver options from Newton model (only if not overridden by constructor)
40964096 self ._update_solver_options (overridden_options = overridden_options )
@@ -4099,7 +4099,7 @@ def get_body_name(body_idx: int) -> str:
40994099 # now complete the data from the Newton model
41004100 self .notify_model_changed (SolverNotifyFlags .ALL )
41014101
4102- def expand_model_fields (self , mj_model : MjWarpModel , nworld : int ):
4102+ def _expand_model_fields (self , mj_model : MjWarpModel , nworld : int ):
41034103 if nworld == 1 :
41044104 return
41054105
@@ -4309,7 +4309,7 @@ def get_option(name: str):
43094309 device = self .model .device ,
43104310 )
43114311
4312- def update_model_inertial_properties (self ):
4312+ def _update_model_inertial_properties (self ):
43134313 if self .model .body_count == 0 :
43144314 return
43154315
@@ -4357,7 +4357,7 @@ def update_model_inertial_properties(self):
43574357 # - cam_pos0, light_pos0, actuator_acc0: other derived quantities
43584358 self ._mujoco_warp .set_const (self .mjw_model , self .mjw_data )
43594359
4360- def update_joint_dof_properties (self ):
4360+ def _update_joint_dof_properties (self ):
43614361 """Update all joint DOF properties including effort limits, friction, armature, solimplimit, solref, passive stiffness and damping, and joint limit ranges in the MuJoCo model."""
43624362 if self .model .joint_dof_count == 0 :
43634363 return
@@ -4482,7 +4482,7 @@ def update_joint_dof_properties(self):
44824482 # - cam_pos0, light_pos0, actuator_acc0: other derived quantities
44834483 self ._mujoco_warp .set_const (self .mjw_model , self .mjw_data )
44844484
4485- def update_joint_properties (self ):
4485+ def _update_joint_properties (self ):
44864486 """Update joint properties including joint positions, joint axes, and relative body transforms in the MuJoCo model."""
44874487 if self .model .joint_count == 0 :
44884488 return
@@ -4535,7 +4535,7 @@ def update_joint_properties(self):
45354535 device = self .model .device ,
45364536 )
45374537
4538- def update_geom_properties (self ):
4538+ def _update_geom_properties (self ):
45394539 """Update geom properties including collision radius, friction, and contact parameters in the MuJoCo model."""
45404540
45414541 # Get number of geoms and worlds from MuJoCo model
@@ -4650,7 +4650,7 @@ def update_pair_properties(self):
46504650 device = self .model .device ,
46514651 )
46524652
4653- def update_model_properties (self ):
4653+ def _update_model_properties (self ):
46544654 """Update model properties including gravity in the MuJoCo model."""
46554655 if self .use_mujoco_cpu :
46564656 self .mj_model .opt .gravity [:] = np .array ([* self .model .gravity .numpy ()[0 ]])
@@ -4843,7 +4843,7 @@ def update_actuator_properties(self):
48434843 """Update CTRL_DIRECT actuator properties (gainprm, biasprm) in the MuJoCo model.
48444844
48454845 Only updates actuators that use CTRL_DIRECT mode. JOINT_TARGET actuators are
4846- updated via update_joint_dof_properties () using joint_target_ke/kd.
4846+ updated via _update_joint_dof_properties () using joint_target_ke/kd.
48474847 """
48484848 if self .mjc_actuator_ctrl_source is None or self .mjc_actuator_to_newton_idx is None :
48494849 return
0 commit comments