def __init__(self, robot, render=False): # print("WalkerBase::__init__ start") self.camera_x = 0 self.walk_target_x = 1e3 # kilometer away self.walk_target_y = 0 self.stateId = -1 MJCFBaseBulletEnv.__init__(self, robot, render) self.time_tick = G_Tick #1ms self.latency = 0.0 # save the latency of most recent returned state self.latency_max = G_delay_max # max latency in ms self.max_num_steps = G_max_num_steps # for steps latency will be fixed or change on reset or done after G_max_num_steps. self.latency_steps = 0 self.steps = 0 self.sampling_interval = G_sampling_min self.sampling_interval_min = G_sampling_min #30 Hz frequency #increase the latency within thresholds self.index = 1 #used to evolve the latency self.prev_action = None self.original_timestep = (0.0165 * 1000.0) / 4.0 #used to enable jitter self.episodic_l = 0.0 self.episodic_si = G_sampling_min
def reset(self): if (self.stateId >= 0): #print("restoreState self.stateId:",self.stateId) self._p.restoreState(self.stateId) r = MJCFBaseBulletEnv.reset(self) self._p.configureDebugVisualizer(pybullet.COV_ENABLE_RENDERING, 0) self.parts, self.jdict, self.ordered_joints, self.robot_body = self.robot.addToScene( self._p, self.stadium_scene.ground_plane_mjcf) self.ground_ids = set([(self.parts[f].bodies[self.parts[f].bodyIndex], self.parts[f].bodyPartIndex) for f in self.foot_ground_object_names]) self._p.configureDebugVisualizer(pybullet.COV_ENABLE_RENDERING, 1) if (self.stateId < 0): self.stateId = self._p.saveState() #print("saving state self.stateId:",self.stateId) self.prev_action =[0.0, 0.0, 0.0, 0.0, 0.0, 0.0] self.steps = 0 #update the state with the timing information if G_TS: r[26] = self.latency/self.latency_max r[27] = self.sampling_interval/self.latency_max return r