ultrasonic_servo_env - Robot with ultrasonic sensor environment¶
-
class
gym_ultrasonic.envs.ultrasonic_servo_env.
UltrasonicEnv
(n_obstacles=4, time_step=0.5, sonar_direction_angles=(0, ))[source]¶ Bases:
gym.core.Env
A differential robot with one Ultrasonic sonar sensor, trying to avoid obstacles. Never stops (no target).
-
metadata
= {'render.modes': ['human', 'rgb_array']}¶
-
action_space
= Box(2,)¶
-
step
(self, action)[source]¶ - Make a single step:
move forward by action[0] mm;
rotate by action[1] radians;
rotate servo by action[2] radians (UltrasonicServoEnv-v1 only).
- Parameters
- action: List[float]
Env action to perform.
- Returns
- observation: List[float]
A list that contains one value - min dist to an obstacle on its way.
- reward: float
A reward, obtained by taking this action.
- done: bool
Whether the episode has ended.
- info: dict
An empty dict. Unused.
-
reward
(self, trajectory, move_step, angle_rotate, servo_turn)[source]¶ Computes the reward.
- Parameters
- trajectory: LineString
Trajectory of this step.
- move_step: float
Move robot with move_step mm along its main axis.
- angle_rotate: float
Turn robot by angle_turn radians.
- servo_turn: float
Turn servo by servo_turn radians, if not None.
- Returns
- reward: float
A reward, obtained by applying this step.
- done: bool
Whether the robot collided with any of obstacles.
-
property
init_state
¶ - Returns
- List[float]
Initial env state (observation) which is the min dist to obstacles. It’s not clear what the default “min dist to obstacles” is - 0, sensor_max_dist or a value in-between. But since we update_state() after each reset(), it should not matter.
-
-
class
gym_ultrasonic.envs.ultrasonic_servo_env.
UltrasonicServoEnv
(n_obstacles=4, time_step=0.5, sonar_direction_angles=(0, ), servo_angular_vel=0.5, observe_servo_angle=True)[source]¶ Bases:
gym_ultrasonic.envs.ultrasonic_servo_env.UltrasonicEnv
A robot with one Ultrasonic sonar sensor and a servo that rotates the sonar. The task is the same: avoid obstacles. Never stops (no target).