irsim.world.robots.robot_diff#
Classes#
Base class representing a generic object in the robot simulator. |
Module Contents#
- class irsim.world.robots.robot_diff.RobotDiff(color: str = 'g', state_dim: int = 3, **kwargs: Any)[source]#
Bases:
irsim.world.object_base.ObjectBaseBase class representing a generic object in the robot simulator.
This class encapsulates common attributes and behaviors for all objects, including robots and obstacles, managing their state, velocity, goals, and kinematics.
- Parameters:
shape (dict) – Parameters defining the shape of the object for geometry creation. The dictionary should contain keys and values required by the GeometryFactory to create the object’s geometry, such as ‘type’ (e.g., ‘circle’, ‘rectangle’) and associated parameters. Defaults to None.
kinematics (dict) – Parameters defining the kinematics of the object. Includes kinematic model and any necessary parameters. If None, no kinematics model is applied. Defaults to None.
state (list of float) – Initial state vector [x, y, theta, …]. The state can have more dimensions depending on state_dim. Excess dimensions are truncated, and missing dimensions are filled with zeros. Defaults to [0, 0, 0].
velocity (list of float) – Initial velocity vector [vx, vy] or according to the kinematics model. Defaults to [0, 0].
goal (list of float or list of list of float) – Goal state vector [x, y, theta, …] or [[x, y, theta], [x, y, theta], …] for multiple goals Used by behaviors to determine the desired movement. Defaults to [10, 10, 0].
role (str) – Role of the object in the simulation, e.g., “robot” or “obstacle”. Defaults to “obstacle”.
color (str) – Color of the object when plotted. Defaults to “k” (black).
static (bool) – Indicates if the object is static (does not move). Defaults to False.
vel_min (list of float) – Minimum velocity limits for each control dimension. Used to constrain the object’s velocity. Defaults to [-1, -1].
vel_max (list of float) – Maximum velocity limits for each control dimension. Used to constrain the object’s velocity. Defaults to [1, 1].
acce (list of float) – Acceleration limits, specifying the maximum change in velocity per time step. Defaults to [inf, inf].
angle_range (list of float) – Allowed range of orientation angles [min, max] in radians. The object’s orientation will be wrapped within this range. Defaults to [-pi, pi].
behavior (dict or str) – Behavioral mode or configuration of the object. Can be a behavior name (str) or a dictionary with behavior parameters. If None, default behavior is applied. Defaults to {‘name’: ‘dash’}, moving to the goal directly.
group_behavior (dict) – Shared behavior defaults for objects in the same group. When an object’s own behavior configuration is empty or missing, the group behavior will be used as a fallback and exposed via beh_config.
goal_threshold (float) – Threshold distance to determine if the object has reached its goal. When the object is within this distance to the goal, it’s considered to have arrived. Defaults to 0.1.
sensors (list of dict) – List of sensor configurations attached to the object. Each sensor configuration is a dictionary specifying sensor type and parameters. Defaults to None.
arrive_mode (str) – Mode for arrival detection, either “position” or “state”. Determines how arrival at the goal is evaluated. Defaults to “position”.
description (str) – Description or label for the object. Can be used for identification or attaching images in plotting. Defaults to None.
group (int) – Group identifier for organizational purposes, allowing objects to be grouped. Defaults to 0.
state_dim (int) – Dimension of the state vector. If None, it is inferred from the class attribute state_shape. Defaults to None.
vel_dim (int) – Dimension of the velocity vector. If None, it is inferred from the class attribute vel_shape. Defaults to None.
unobstructed (bool) – Indicates if the object should be considered to have an unobstructed path, ignoring obstacles in certain scenarios. Defaults to False.
fov (float) – Field of view angles in radians for the object’s sensors. Defaults to None. If set lidar, the default value is angle range of lidar.
fov_radius (float) – Field of view radius for the object’s sensors. Defaults to None. If set lidar, the default value is range_max of lidar.
**kwargs –
Additional keyword arguments for extended functionality.
plot (dict): Plotting options for the object. May include ‘show_goal’, ‘show_text’, ‘show_arrow’, ‘show_uncertainty’, ‘show_trajectory’, ‘trail_freq’, etc.
- Raises:
ValueError – If dimension parameters do not match the provided shapes or if input parameters are invalid.
- state_dim#
Dimension of the state vector.
- Type:
int
- state_shape#
Shape of the state array.
- Type:
tuple
- vel_dim#
Dimension of the velocity vector.
- Type:
int
- vel_shape#
Shape of the velocity array.
- Type:
tuple
- state#
Current state of the object.
- Type:
np.ndarray
- _init_state#
Initial state of the object.
- Type:
np.ndarray
- _velocity#
Current velocity of the object.
- Type:
np.ndarray
- _init_velocity#
Initial velocity of the object.
- Type:
np.ndarray
- _goal#
Goal state of the object.
- Type:
np.ndarray
- _init_goal#
Initial goal state of the object.
- Type:
np.ndarray
- _geometry#
Geometry representation of the object.
- Type:
any
- group#
Group identifier for the object.
- Type:
int
- stop_flag#
Flag indicating if the object should stop.
- Type:
bool
- arrive_flag#
Flag indicating if the object has arrived at the goal.
- Type:
bool
- collision_flag#
Flag indicating a collision has occurred.
- Type:
bool
- unobstructed#
Indicates if the object has an unobstructed path.
- Type:
bool
- static#
Indicates if the object is static.
- Type:
bool
- vel_min#
Minimum velocity limits.
- Type:
np.ndarray
- vel_max#
Maximum velocity limits.
- Type:
np.ndarray
- color#
Color of the object.
- Type:
str
- role#
Role of the object (e.g., “robot”, “obstacle”).
- Type:
str
- info#
Information container for the object.
- Type:
- wheelbase#
Distance between the front and rear wheels. Specified for ackermann robots.
- Type:
float
- fov#
Field of view angles in radians.
- Type:
float
- fov_radius#
Field of view radius.
- Type:
float
Create a differential-drive robot.
- Parameters:
color (str) – Display color. Default “g”.
state_dim (int) – State vector dimension (>=3 for [x,y,theta]).
**kwargs – Forwarded to
ObjectBase(e.g., kinematics, sensors, goal).