6D-Platform MagBot#
- class magbotsim.magbots.sixD_platform.SixDPlatformMagBotsAPM4330(num_magbots: int, indices_mover_a: ndarray, indices_mover_b: ndarray)[source]
Bases:
objectBase class for 6D-Platform MagBots. This class can handle multiple 6D-Platform MagBots, allowing calculations to be vectorized.
- Parameters:
num_magbots – number of 6D-Platform MagBots
indices_mover_a – a numpy array of shape (num_magbots,) containing all indices of movers controlling the alpha-rotation (around x-axis) of a platform
indices_mover_b – a numpy array of shape (num_magbots,) containing all indices of movers controlling the beta-rotation (around y-axis) of a platform
- control_platform_ab_rot(model: MjModel, data: MjData, mover_a_quats: ndarray, mover_b_quats: ndarray, indices_magbots: ndarray | None = None) None[source]
Couple the rotations around the z-axes of the movers with the platform’s a and b rotations. 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_a_quats – current rotations of the movers (represented as quaternions (w,x,y,z)) that control the platform’s alpha-rotation. Shape: (num_indices, 4)
mover_b_quats – current rotations of the movers (represented as quaternions (w,x,y,z)) that control the platform’s beta-rotation. Shape: (num_indices, 4)
indices_magbots – the indices of the MagBots to control, defaults to None. If None, all MagBots are controlled. Shape: (num_indices,)
- generate_magbot_xml_strings(initial_pos_xyz_mover_b: ndarray, custom_model_xml_strings: dict | None) dict[source]
Generate the MuJoCo XML strings for all 6D-Platform MagBots and add them to the
custom_model_xml_strings-dict.- Parameters:
initial_pos_xyz_mover_b – the initial x,y,z-positions for all movers that control the b rotation of the platforms. 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
- generate_platform_abRot_actuator_xml_strings() str[source]
Generate MuJoCo XML strings for the a,b-rot platform actuators of all 6D-Platform MagBots.
- Returns:
the MuJoCo XML actuator string (start <actuator> and end ‘</actuator>’ are not included)
- get_platform_acc(model: MjModel, data: MjData, idx_magbot: int) ndarray[source]
Get the current acceleration of a MagBot’s platform (measured at the center of the platform’s surface).
- Parameters:
model – mjModel of the MuJoCo environment
data – mjData of the MuJoCo environment
idx_magbot – the index of the MagBot for which to return the acceleration
- Returns:
the current acceleration of the platform. Shape: (6,) (first 3: linear accelerations, last 3: angular accelerations)
- get_platform_pose(model: MjModel, data: MjData, indices_magbots: ndarray) ndarray[source]
Get the current pose of a MagBot’s platform (measured at the center of the platform’s surface). 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 platforms (rotation represented as quaternion). Shape: (num_indices,7) (representation: (x_p,y_p,z_p,w_o,x_o,y_o,z_o))
- get_platform_vel(model: MjModel, data: MjData, idx_magbot: int) ndarray[source]
Get the current velocity of a MagBot’s platform (measured at the center of the platform’s surface).
- Parameters:
model – mjModel of the MuJoCo environment
data – mjData of the MuJoCo environment
idx_magbot – the index of the MagBot for which to return the velocity
- Returns:
the current velocity of the platform. Shape: (6,) (first 3: linear velocities, last 3: angular velocities)
- platformSetPose2MoverSetPose(platform_pose_d: ndarray, mover_z_d: ndarray | float, use_euler: bool = False) ndarray[source]
Calculate the desired mover pose from a desired platform pose. This method is vectorized and can therefore calculate desired mover poses for multiple MagBots.
- Parameters:
platform_pose_d – the desired platform poses (rotation specified as Euler angles (xyz) in rad). Shape: (num_samples,6)
mover_z_d – 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).
use_euler – whether to use quaternions (w,x,y,z) or euler angles (xyz) to represent the desired mover rotations, defaults to False
- Returns:
the desired mover poses. Shape: if
use_euler==True: (num_samples,2,6), else: (num_samples,2,7). [:,0,:]: poses for the mover that controls the platform’s alpha-rotation; [:,1,:]: poses for the mover that controls the platform’s beta-rotation
- platformZPos2MoverDist(platform_z_d: ndarray, mover_z_d: ndarray) ndarray[source]
Calculate the desired mover distance from a desired platform z-position. This method is vectorized and can therefore calculate desired mover distances for multiple MagBots. Additionally this method takes the minimum and maximum possible mover distances into account, i.e. distances that are less (greater) than the minimum (maximum) distance are set to the minimum (maximum) distance.
- Parameters:
platform_z_d – the desired platform z-positions. Shape: (num_samples,) or (num_samples,1)
mover_z_d – the desired mover z-pos (corresponds to the distance between the tile surface and the bottom of a mover). Shape: (num_samples,) or (num_samples,1)
- Returns:
the desired mover distances. Shape: (num_samples,) or (num_samples,1) depending on the input shapes
- 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