obstacle - Obstacle and robot definition¶
-
class
gym_ultrasonic.envs.obstacle.
Obstacle
(position, width, height, angle=0)[source]¶ Bases:
object
A static rectangular obstacle.
-
property
polygon
¶ - Returns
- Polygon
Minimum rotated bounding box polygon.
-
get_polygon_parallel_coords
(self)[source]¶ - Returns
- np.ndarray
Clock-wise vertices of the bounding box polygon, parallel to the world axes.
-
property
-
class
gym_ultrasonic.envs.obstacle.
Servo
(width, height, sonar_direction_angles=(0, ), angle_range=(-0.5235987755982988, 0.5235987755982988), angular_vel=0)[source]¶ Bases:
gym_ultrasonic.envs.obstacle.Obstacle
Servo that holds sonar(s) on board. Servo has only one function - rotate the sonar(s).
-
property
sonar_angles_world
¶
-
property
-
class
gym_ultrasonic.envs.obstacle.
Robot
(width, height, sonar_direction_angles=(0, ), sensor_max_dist=2000)[source]¶ Bases:
gym_ultrasonic.envs.obstacle.Obstacle
Robot with a mounted servo and ultrasonic range sensor.
-
property
servo_shift
¶ - Returns
- float
Shift of the servo along robot’s main axis, mm
-
property
n_sonars
¶ - Returns
- int
Num. of sonars on board.
-
diffdrive
(self, vel_left, vel_right, sim_time)[source]¶ Differential drive. Adapted from http://ais.informatik.uni-freiburg.de/teaching/ss17/robotics/exercises/solutions/03/sheet03sol.pdf
- Parameters
- vel_left: float
Left wheel tangential speed, mm / sec.
- vel_right: float
Right wheel tangential speed, mm / sec.
- sim_time: float
Simulation time step, sec.
- Returns
- move_step: float
Performed move step in mm along robot’s main axis.
- angle_rotate: float
Performed rotation in radians.
- trajectory: LineString
Trajectory of this step.
-
collision
(self, obj)[source]¶ - Parameters
- obj: Obstacle or List[Obstacle]
An obstacle(s) to check for a collision.
- Returns
- bool
If robot’s minimum rotated bounding box collides with an obstacle(s).
-
property
direction_vector
¶ - Returns
- np.ndarray
Robot’s direction vector, (x, y)
-
property
servo_position
¶ - Returns
- np.ndarray
World coordinates of Servo with embedded Ultrasonic sensor, (x, y)
-
ray_cast
(self, obstacles)[source]¶ Casts a ray along servo sensor direction and checks if there an intersection with obstacles. Simulates Ultrasonic range sonar, mounted on top of the servo, in a real robot.
- Parameters
- obstacles: List[Obstacle]
List of obstacles in the scene.
- Returns
- min_dist: List[float]
Min dist to an obstacle. If no obstacle is found at the ray intersection, max_dist is returned.
- intersection_xy: List[np.ndarray]
X and Y of the intersection point with an obstacle.
-
property