Stickbug Robot¶
Base¶
This module contains the model for Stickbug base
- class irl_gym.support.stickbug.sb_base.SBBase(params: Optional[dict] = None)¶
Bases:
object- get_abs_state()¶
Gets state of base (pose, velocity) and position of supports in global frame
- Returns:
(dict) Dictionary containing the state of the agent
- get_abs_support()¶
Get the support points of the agent in global frame.
- Parameters:
supports – ({“left”:[x,y,z,h],…}) Support points of the agent. default: None
- Returns:
({“left”:[x,y,z,h],…}) Support points of the agent.
- get_rel_support()¶
Get the support points of the agent.
- Returns:
({“left”:[x,y,z,h],…}) Support points of the agent.
- go_2_position(x: Optional[list] = None, dt=0.1)¶
Drives base with position command.
- Parameters:
x – ([x,y,h]) Position of the agent. default: None
dt – (float) Time step. default: 0.1
- Returns:
(dict) Dictionary containing the pose and velocity of the agent.
- go_2_velocity(v: Optional[list] = None, w: Optional[float] = None, dt=0.1)¶
Drives base with velocity command.
- Parameters:
v – ([x,y]) Linear velocity of the agent. default: None
w – (float) Angular velocity of the agent. default: None
- Returns:
(dict) Dictionary containing the pose and velocity of the agent.
- plot(fig, ax, plot)¶
Plots the agent on an existing 3D plot.
- Parameters:
fig – (figure) Figure to plot on.
ax – (axis) Axis to plot on.
plot – (bool) Whether or not to plot.
- step(action: Optional[dict] = None, dt=0.1)¶
Step the agent in time.
- Parameters:
action – (dict) Dictionary of actions to take. default: None
dt – (float) Time step. default: 0.1
- Returns:
(dict) Dictionary containing the pose and velocity of the agent.
- update_inertial_properties(a: Optional[float] = None, alpha: Optional[float] = None)¶
Update the inertial properties of the agent.
- Parameters:
a – (float) Linear acceleration of the agent. default: None
alpha – (float) Angular acceleration of the agent. default: None
Support¶
This module contains the model for Stickbug arms
- class irl_gym.support.stickbug.sb_support.SBSupport(params: dict = {}, observation_params: dict = {})¶
Bases:
objectStickbug Support class for managing movement of arms.
Note: For velocity and acceleration limits, these are assumed independent because the model is holonomic even though the robot is not.
Input
- Parameters:
pose – (“left”: [x,y,z,h], “right”: [x,y,z,h]) Initial pose of the agent in the environment. default: {“left”: [0,0,0,0], “right”: [0,0,0,0]}
buffer – (float) Minimum distance between the members. default: 0.05
support_height – (float) Height of the support. default: 3
num_arms – (int) Number of arms on the agent. default: 6
max_accel – (float) Maximum acceleration of the agent. default: 1 (assume this includes arms and such too. Can be updated with update_inertial_properties())
max_speed – (dict) Maximum speed of the agent. default: {“v”: 1, “w”: 1}
pid – (dict) Dictionary of PID parameters for the agent. default: {“p”: 1, “i”: 0, “d”: 0, “db”: 0.01}
pid_angular – (dict) Dictionary of PID parameters for the agent. default: {“p”: 1, “i”: 0, “d”: 0, “db”: 0.01}
mem_length – (dict) Length of the members. default: {“bicep”: 0.5, “forearm”: 0.5}
joint_rest – (list) Rest point of the joints. default: [0.1,0.5]
joint_constraints – (dict) Constraints on the joints. default: {“z”: {“min: <lower_joint>,”max”: <upper_joint>},”th1”: {“min”: -np.pi, “max”: np.pi}, “th2”: {“min”: -np.pi, “max”: np.pi}}
show_bounds – (bool) Whether to show the bounds of the agent. default: False
observation_params – (dict) Parameters for the observation model. default: {“log_level”: “WARNING”}
log_level – (str) Level of logging to use. For more info see logging levels, default: “WARNING”
- init_arms(num: int = 6)¶
Initialize the arms on the agent.
- Parameters:
num – (int) Number of arms to initialize. default: 6
- Returns:
(list) List of arms
- observe_flowers(flowers=None)¶
Observe the flowers in the environment
- Parameters:
flowers – (list) List of flowers in the environment
- Returns:
(list) List of observations for each arm
- plot(fig, ax, plot)¶
Plot the agent in the environment.
- Parameters:
fig – (matplotlib.figure.Figure) Figure to plot on
ax – (matplotlib.axes.Axes) Axes to plot on
plot – (bool) Whether to plot the agent
- step(action: dict = {}, dt=0.1, flowers=[])¶
Step the agent forward in time.
- Parameters:
action – (dict) Action to take. default: {}}
dt – (float) Time step to use. default: 0.1
flowers – (list) List of flowers in the environment. default: []
- update(pose)¶
Update the pose of the agent.
- Parameters:
pose – (“left”: [x,y,z,h], “right”: [x,y,z,h]) Pose of the agent in the environment.
Arms¶
This module contains the model for Stickbug arms
- class irl_gym.support.stickbug.sb_arm.SBArm(params: dict = {}, observation_params: dict = {})¶
Bases:
objectStickbug Arm class for moving arms on the robot.
Rest point is set to initial pose Unless obstructed, then z is fixed.
Note: For velocity and acceleration limits, these are assumed independent because the model is holonomic even though the robot is not.
Input
- Parameters:
location – (dict) Which column arm is on, and if upper, middle, lower
pose – (dict) Initial pose of the arm. default: {“linear”:[0,0,0], “angular”:[0,0,0,0,0]]} # col angle, th1, th2, yaw,pitch
velocity – ([v,w1,w2]) Initial velocity of the arm. default: [0,0,0]
max_accel – (float) Maximum acceleration of the agent. default: 1
max_speed – (dict) Maximum speed of the agent. default: {“v”: 1, “w”: 1}
pid – (dict) Dictionary of PID parameters for the agent. default: {“p”: 1, “i”: 0, “d”: 0, “db”: 0.01}
pid_angular – (dict) Dictionary of PID parameters for the agent. default: {“p”: 1, “i”: 0, “d”: 0, “db”: 0.01}
mem_length – (dict) Length of the members. default: {“bicep”: 0.5, “forearm”: 0.5}
rest_point – (list) Rest point of the arm. default: [0,0,0]
buffer – (float) Buffer for the arm. default: 0.1
joint_constraints – (dict) Constraints on the joints. default: {“z”: {“min: <lower_joint>,”max”: <upper_joint>},”th1”: {“min”: -np.pi, “max”: np.pi}, “th2”: …, “yaw”: …, “pitch”: …}
show_bounds – (bool) Whether to show the bounds of the agent. default: False
show_camera – (bool) Whether to show the camera of the agent. default: False
observation_params – (dict) Parameters for observing flowers. default: {“position”: [0,0,0], “orientation”: [0,0,0]}
log_level –
(str) Level of logging to use. For more info see logging levels, default: “WARNING”
- forward_kinematics_absolute(joints: Optional[list] = None)¶
Calculate the forward kinematics of the arm.
- Parameters:
joints – ([z, shoulder, elbow]) Joint angles of the arm.
- Returns:
(list) list containing the absolute pose of each joint.
- forward_kinematics_relative(joints)¶
Calculate the forward kinematics of the arm.
- Parameters:
joints – ([z, shoulder, elbow]) Joint angles of the arm.
- Returns:
(list) list containing the relative pose of each joint.
- get_absolute_state()¶
Get the state of the arm and bounding boxes in global frame.
- Returns:
(dict) Dictionary containing the state of the agent {“arm”: {}, “camera”: [roll,pitch,yaw], “bounds”: {“bicep”: {“center”: [x,y,z], “radius”: r, “height”: h, “angle”: a}, “forearm”: {“center”: [x,y,z], “radius”: r, “height”: h, “angle”: a}}
- get_bounds()¶
Get the bounds of the arm.
- Returns:
(dict) Dictionary containing the bounds of the agent.
- get_joint_angles(point)¶
Calculate the inverse kinematics of the arm.
- Parameters:
point – (list) [x,y,z] position of the hand.
- Returns:
(list) list containing the joint angles of the arm.
- hand_2_position(point, dt=0.1)¶
Move the hand to position.
- Parameters:
point – (list) [x,y,z,th1,th2,cam_yaw,cam_pitch] position of the hand.
dt – (float) time step
- hand_2_relative_position(point, dt=0.1)¶
Move the hand to position.
- Parameters:
point – (list) [x,y,z] position of the hand.
dt – (float) time step
- hand_2_velocity(velocity, dt=0.1)¶
Move the hand to velocity. (Need to check if this is accurate.)
- Parameters:
velocity – (list) [x, y, z, th1,th2,pitch,yaw] velocity of the hand.
dt – (float) time step
- joint_2_position(point: Optional[list] = None, dt=0.1)¶
Move individual joints to position.
- Parameters:
point – (list) [z, shoulder, elbow, yaw, pitch] position of the joints.
dt – (float) time step
- Returns:
(dict) Dictionary containing the pose and velocity of the agent.
- joint_2_velocity(velocity: Optional[list] = None, dt=0.1)¶
Move individual joints to velocity.
- Parameters:
velocity – (list) [v, w1, w2] velocity of the joints.
dt – (float) time step
- Returns:
(dict) Dictionary containing the pose and velocity of the agent.
- observe_flowers(flowers)¶
Observe the flowers in the environment
- Parameters:
flowers – (list) List of flowers in the environment
- Returns:
(list) List of observations
- plot_arm(fig, ax, plot=False)¶
Plot the arm.
- Parameters:
fig – (matplotlib.figure.Figure) Figure to plot on.
ax – (matplotlib.axes._subplots.Axes3DSubplot) Axes to plot on.
plot – (bool) Whether to plot the arm. default: False
- pollinate_flowers(flowers)¶
Pollinate the flowers in the environment
- Parameters:
flowers – (list) List of flowers in the environment
- Returns:
(list) Flower that were pollinated
- step(action: Optional[dict] = None, flowers=None)¶
Perform action such as movement or attempt to pollinate
- Parameters:
action – (dict) Dictionary containing the action to take.
flowers – (list) List of flowers in the environment
- Returns:
(dict) Dictionary containing observation
- update(shoulder_pose: Optional[list] = None, joint_velocity: Optional[list] = None, constraints: Optional[dict] = None)¶
Update the arm’s pose, velocity, and bounding boxes based on movement of supporting body.
- Parameters:
shoulder_pose – (list) [x,y,z,h] position and angle (rad) of rotation in global frame
joint_velocity – ([v,w1,w2,cam_yaw,cam_pitch]) velocity of the joints.
constraints – (list) {“joints”: [z, shoulder, elbow], “bounds”: {}} position of the joints.