Gripper MagBot#

../_images/img_gripper_magbot.jpg
class magbotsim.magbots.gripper.GripperMagBotsAPM4330(num_magbots: int, indices_mover_c0: ndarray, indices_mover_c1: ndarray, indices_mover_c2: ndarray, magbot_params: GripperMagBotsAPM4330Params, cycle_time: float)[source]

Bases: object

Base class for Gripper MagBots. This class can handle multiple Gripper MagBots, allowing calculations to be vectorized.

Parameters:
  • num_magbots – number of Gripper MagBots

  • indices_mover_c0 – a numpy array of shape (num_magbots,) containing all indices of movers attached to connection 0

  • indices_mover_c1 – a numpy array of shape (num_magbots,) containing all indices of movers attached to connection 1

  • indices_mover_c2 – a numpy array of shape (num_magbots,) containing all indices of movers attached to connection 2

  • magbot_params – an instance of GripperMagBotsAPM4330Params

  • cycle_time – the cycle time used in the BasicMagBotEnv (usually 1ms)

control_gripper(model: MjModel, data: MjData, mover_poses_d: ndarray, current_mover_qpos: ndarray, current_mover_qvels: ndarray) → None[source]

Couple the rotations around the z-axes of the movers with the grippers’s a and b rotations, and the opening of the fingers. This method is vectorized and can therefore couple the rotations for multiple MagBots.

Parameters:
  • model – mjModel of the MuJoCo environment

  • data – mjData of the MuJoCo environment

  • mover_poses_d – the desired mover poses (rotation specified as Euler angles (xyz) in rad). Shape: (num_magbots*3,6)

  • current_mover_qpos – the current qpos of all movers (rotation specified as quaternion [w,x,y,z]). Shape: (num_magbots*3,7)

  • current_mover_qvels – the current qvel of all movers. Shape: (num_magbots*3,6)

finger_distance_to_angle(finger_distance: ndarray) → ndarray[source]

Convert a desired distance between the two finger pads to the corresponding finger (jaw) angle.

The desired distance is clipped to the reachable finger distance range (finger_distance_min, finger_distance_max).

Parameters:

finger_distance – the desired distance(s) between the finger pads in m. Shape: (num_samples,)

Returns:

the corresponding finger (jaw) angle(s) in rad. Shape: (num_samples,)

generate_actuator_xml_strings() → str[source]

Generate MuJoCo XML strings for the c-rot actuators of the movers, gripper’s a,b-rot actuators, and finger actuators of all Gripper MagBots.

Returns:

the MuJoCo XML actuator string (start ‘<actuator>’ and end ‘</actuator>’ are not included)

generate_magbot_xml_strings(initial_pos_xyz_mover_c0: ndarray, custom_model_xml_strings: dict | None) → dict[source]

Generate the MuJoCo XML strings for all Gripper MagBots and add them to the custom_model_xml_strings-dict.

Parameters:
  • initial_pos_xyz_mover_c0 – the initial x,y,z-positions for all movers attached to connection 0. Shape: (num_magbots,3)

  • custom_model_xml_strings – the current custom_model_xml_strings-dict which is modified by this method

Returns:

the modified custom_model_xml_strings-dict

get_gripper_pose(model: MjModel, data: MjData, indices_magbots: ndarray) → ndarray[source]

Get the current pose of a MagBot’s gripper (measured at the center between the two gripper fingers), including the current distance between the two fingers. This method is vectorized and can therefore calculate the current pose of multiple MagBots.

Parameters:
  • model – mjModel of the MuJoCo environment

  • data – mjData of the MuJoCo environment

  • indices_magbots – the indices of the MagBots for which to return the pose. Shape: (num_indices,)

Returns:

the current pose of the grippers (rotation represented as quaternion). Shape: (num_indices,8) (representation: (x_p,y_p,z_p,w_o,x_o,y_o,z_o,finger_distance)). The last entry is the current distance between the two finger pads in m.

gripperSetPose2MoverSetPose(gripper_pose_d: ndarray, z_m: ndarray | float, single_track: ndarray | bool = False) → tuple[ndarray, ndarray, ndarray, ndarray][source]

Calculate the desired mover pose from a desired gripper pose. This method is vectorized and can therefore calculate desired mover poses for multiple MagBots.

Parameters:
  • gripper_pose_d – the desired gripper poses (rotation specified as Euler angles (xyz) in rad). Shape: (num_samples,7) The 7th entry is the desired distance between the two finger pads in m (clipped to the reachable finger distance range).

  • z_m – the desired mover z-pos (corresponds to the distance between the tile surface and the bottom of a mover). Can be a numpy array of shape (num_samples,) or a single float value (similar position for all movers).

  • single_track – whether to calculate the mover set positions in single-track mode, defaults to False. Either a numpy array containing an individual bool value for each MagBot (shape: (num_magbots,)) or a single bool value.

Returns:

the desired mover poses. Shape: (num_samples,3,6) [:,0,:]: poses for the mover attached to connection 0; [:,1,:]: poses for the mover attached to connection 1; [:,2,:]: poses for the mover attached to connection 2

reset_yaw_extractor() → None[source]

Reset the continuous mover yaw extractor, i.e. set all integrated valued to zero.

update_cached_mujoco_data(model: MjModel) → None[source]

Update all cached information about MuJoCo objects, such as names and IDs.

Parameters:

model – mjModel of the MuJoCo environment

class magbotsim.magbots.gripper.GripperMagBotsAPM4330Params(n: float = 0.193, z_b01: float = 0.05811, z_t01: float = 0.0484, x_b01: float = 0.03, x_t01: float = 0.066, k_01: float = 0.182, z_b2: float = 0.06801, z_t2: float = 0.0385, x_b2: float = 0.032, x_t2: float = 0.064, k_2: float = 0.11386, s_m0: float = 0.9969, s_m1: float = 0.9969, s_m2: float = -182.4376, z_p_min: float = 0.16773, z_p_max: float = 0.22037, z_d_min: float = 0.026, f_d_max: float = 0.017)[source]