(self, cfg)
| 237 | print_torque = lambda tau: print(f"tau (norm, max) = {np.linalg.norm(tau):.2f}, \t{np.max(tau):.2f}", end='\r') |
| 238 | |
| 239 | def __init__(self, cfg): |
| 240 | super().__init__(cfg) |
| 241 | |
| 242 | def signal_handler(sig, frame): |
| 243 | logger.info("Ctrl+C Exiting safely...") |
| 244 | raise RobotExitException("Mujoco Robot Exiting") |
| 245 | signal.signal(signal.SIGINT, signal_handler) |
| 246 | |
| 247 | self.decimation = cfg.simulator.config.sim.control_decimation |
| 248 | self.sim_dt = 1/cfg.simulator.config.sim.fps |
| 249 | assert self.dt == self.decimation * self.sim_dt |
| 250 | # self._subtimer = 0 |
| 251 | |
| 252 | |
| 253 | |
| 254 | self.model = mujoco.MjModel.from_xml_path(os.path.join(cfg.robot.asset.asset_root, cfg.robot.asset.xml_file)) # type: ignore |
| 255 | print("XML", cfg.robot.asset.xml_file) |
| 256 | self.data = mujoco.MjData(self.model) # type: ignore |
| 257 | self.model.opt.timestep = self.sim_dt |
| 258 | print("timestep", self.model.opt.timestep) |
| 259 | if cfg.deploy.render: |
| 260 | self.is_render = True |
| 261 | if cfg.__contains__('recording') and cfg.recording: |
| 262 | self.is_recording = True |
| 263 | self._make_viewer() |
| 264 | else: |
| 265 | self.is_render = False |
| 266 | |
| 267 | self.num_ctrl = self.data.ctrl.shape[0] |
| 268 | assert self.num_ctrl == self.num_actions, f"Number of control DOFs {self.num_ctrl} does not match number of actions {self.num_actions}" |
| 269 | |
| 270 | # noise init |
| 271 | if self.RAND_IMU: |
| 272 | if self.noise_imu_type == 'ou': |
| 273 | sigma = np.sqrt(2*self.noise_imu_ou_theta) |
| 274 | theta = self.noise_imu_ou_theta |
| 275 | elif self.noise_imu_type == 'white': |
| 276 | sigma = 1 |
| 277 | theta = 0 |
| 278 | else: |
| 279 | raise ValueError(f"Invalid noise type: {self.noise_imu_type}") |
| 280 | self.noise_imu = noise_process_dict[self.noise_imu_type]((6,), mu=0,sigma=sigma, theta=theta, dt=self.sim_dt) |
| 281 | |
| 282 | # self.noise_imu = noise_process_dict['empty']((3,)) |
| 283 | # self.noise_imu = noise_process_dict['ou']((3,), mu=0, sigma=250*np.sqrt(0.02), theta=25, dt=self.sim_dt) |
| 284 | # self.noise_imu = noise_process_dict['ou']((3,), mu=0, sigma=250, theta=25, dt=self.sim_dt) |
| 285 | |
| 286 | # self.noise_imu = noise_process_dict['ou']((6,), mu=0, sigma=1, theta=0.15, dt=self.sim_dt) |
| 287 | # self.noise_imu = noise_process_dict['white']((6,), mu=0, sigma=1.825) |
| 288 | |
| 289 | # self.noise_imu = noise_process_dict['ou']((6,), mu=0, sigma=np.sqrt(2*3), theta=3, dt=self.sim_dt) |
| 290 | # self.noise_imu = noise_process_dict['white']((6,), mu=0, sigma=1) |
| 291 | |
| 292 | # self.noise_imu = noise_process_dict['ou']((3,), mu=0, sigma=np.sqrt(250), theta=25, dt=self.sim_dt) |
| 293 | # self.noise_imu = noise_process_dict['white']((3,), mu=0, sigma=35.355) |
| 294 | # self.noise_imu = noise_process_dict['white']((3,), mu=0, sigma=5) |
| 295 | # self.noise_imu = noise_process_dict['white']((3,), mu=0, sigma=2.236) |
| 296 | print(self.noise_imu) |
nothing calls this directly
no test coverage detected