diff --git a/pyrobolearn/robots/acrobot.py b/pyrobolearn/robots/acrobot.py index 12ad466..317a368 100644 --- a/pyrobolearn/robots/acrobot.py +++ b/pyrobolearn/robots/acrobot.py @@ -31,8 +31,8 @@ class Acrobot(Robot): # TODO: create the acrobot dynamically instead of loading Args: simulator (Simulator): simulator instance. - position (np.array[3]): Cartesian world position. - orientation (np.array[4]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. + position (np.array[float[3]]): Cartesian world position. + orientation (np.array[float[4]]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. fixed_base (bool): if True, the robot base will be fixed in the world. scale (float): scaling factor that is used to scale the robot. urdf (str): path to the urdf. Do not change it unless you know what you are doing. diff --git a/pyrobolearn/robots/aibo.py b/pyrobolearn/robots/aibo.py index 523fdf0..a5b4dac 100644 --- a/pyrobolearn/robots/aibo.py +++ b/pyrobolearn/robots/aibo.py @@ -33,8 +33,8 @@ class Aibo(QuadrupedRobot): Args: simulator (Simulator): simulator instance. - position (np.array[3]): Cartesian world position. - orientation (np.array[4]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. + position (np.array[float[3]]): Cartesian world position. + orientation (np.array[float[4]]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. fixed_base (bool): if True, the robot base will be fixed in the world. scale (float): scaling factor that is used to scale the robot. urdf (str): path to the urdf. Do not change it unless you know what you are doing. diff --git a/pyrobolearn/robots/allegrohand.py b/pyrobolearn/robots/allegrohand.py index fd211f2..45b9abc 100644 --- a/pyrobolearn/robots/allegrohand.py +++ b/pyrobolearn/robots/allegrohand.py @@ -31,8 +31,8 @@ class AllegroHand(Hand): Args: simulator (Simulator): simulator instance. - position (np.array[3]): Cartesian world position. - orientation (np.array[4]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. + position (np.array[float[3]]): Cartesian world position. + orientation (np.array[float[4]]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. fixed_base (bool): if True, the hand base will be fixed in the world. scale (float): scaling factor that is used to scale the hand. """ diff --git a/pyrobolearn/robots/anymal.py b/pyrobolearn/robots/anymal.py index a41b790..1a8de64 100644 --- a/pyrobolearn/robots/anymal.py +++ b/pyrobolearn/robots/anymal.py @@ -40,8 +40,8 @@ class ANYmal(QuadrupedRobot): Args: simulator (Simulator): simulator instance. - position (np.array[3]): Cartesian world position. - orientation (np.array[4]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. + position (np.array[float[3]]): Cartesian world position. + orientation (np.array[float[4]]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. fixed_base (bool): if True, the robot base will be fixed in the world. scale (float): scaling factor that is used to scale the robot. urdf (str): path to the urdf. Do not change it unless you know what you are doing. diff --git a/pyrobolearn/robots/atlas.py b/pyrobolearn/robots/atlas.py index 4aecde5..e3e623f 100644 --- a/pyrobolearn/robots/atlas.py +++ b/pyrobolearn/robots/atlas.py @@ -33,8 +33,8 @@ class Atlas(BipedRobot, BiManipulator): Args: simulator (Simulator): simulator instance. - position (np.array[3]): Cartesian world position. - orientation (np.array[4]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. + position (np.array[float[3]]): Cartesian world position. + orientation (np.array[float[4]]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. fixed_base (bool): if True, the robot base will be fixed in the world. scale (float): scaling factor that is used to scale the robot. urdf (str): path to the urdf. Do not change it unless you know what you are doing. diff --git a/pyrobolearn/robots/ballbot.py b/pyrobolearn/robots/ballbot.py index 7362932..9b5e4b5 100644 --- a/pyrobolearn/robots/ballbot.py +++ b/pyrobolearn/robots/ballbot.py @@ -31,8 +31,8 @@ class Ballbot(Robot): Args: simulator (Simulator): simulator instance. - position (np.array[3]): Cartesian world position. - orientation (np.array[4]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. + position (np.array[float[3]]): Cartesian world position. + orientation (np.array[float[4]]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. fixed_base (bool): if True, the robot base will be fixed in the world. scale (float): scaling factor that is used to scale the robot. urdf (str): path to the urdf. Do not change it unless you know what you are doing. diff --git a/pyrobolearn/robots/base.py b/pyrobolearn/robots/base.py index 2408dad..d446ad3 100644 --- a/pyrobolearn/robots/base.py +++ b/pyrobolearn/robots/base.py @@ -347,10 +347,10 @@ class Body(object): - this does not work when using `sim.setRealTimeSimulation(1)`. Args: - force (np.array[3]): Cartesian forces to be applied on the body + force (np.array[float[3]]): Cartesian forces to be applied on the body link_id (int): link id to apply the force, if -1 it will apply the force on the base - position (np.array[3], None): position on the link where the force is applied (expressed in the given - cartesian frame, see next attribute :attr:`frame`). If None, it is the center of mass of the body + position (np.array[float[3]], None): position on the link where the force is applied (expressed in the + given cartesian frame, see next attribute :attr:`frame`). If None, it is the center of mass of the body (or the link if specified). frame (int): allows to specify the coordinate system of force/position. sim.LINK_FRAME (=1) for local link frame, and sim.WORLD_FRAME (=2) for world frame. By default, it is the world frame. @@ -382,10 +382,10 @@ class Body(object): Returns: float: mass in kg float: lateral friction coefficient - np.float[3]: local inertia diagonal. Note that links and base are centered around the center of mass and - aligned with the principal axes of inertia. - np.float[3]: position of inertial frame in local coordinates of the joint frame - np.float[4]: orientation of inertial frame in local coordinates of joint frame + np.array[float[3]]: local inertia diagonal. Note that links and base are centered around the center of + mass and aligned with the principal axes of inertia. + np.array[float[3]]: position of inertial frame in local coordinates of the joint frame + np.array[float[4]]: orientation of inertial frame in local coordinates of joint frame float: coefficient of restitution float: rolling friction coefficient orthogonal to contact normal float: spinning friction coefficient around contact normal @@ -417,7 +417,7 @@ class Body(object): section. friction_anchor (int): enable or disable a friction anchor: positional friction correction (disabled by default, unless set in the URDF contact section) - local_inertia_diagonal (np.float[3]): diagonal elements of the inertia tensor. Note that the base and + local_inertia_diagonal (np.array[float[3]]): diagonal elements of the inertia tensor. Note that the base and links are centered around the center of mass and aligned with the principal axes of inertia so there are no off-diagonal elements in the inertia tensor. joint_damping (float): joint damping coefficient applied at each joint. This coefficient is read from URDF @@ -445,14 +445,15 @@ class Body(object): int: object unique id. int: link id. int: geometry type; GEOM_BOX (=3), GEOM_SPHERE (=2), GEOM_CAPSULE (=7), GEOM_MESH (=5), GEOM_PLANE (=6) - np.float[3]: depends on geometry type: + np.array[float[3]]: depends on geometry type: for GEOM_BOX: extents, for GEOM_SPHERE: dimensions[0] = radius, for GEOM_CAPSULE and GEOM_CYLINDER: dimensions[0] = height (length), dimensions[1] = radius. For GEOM_MESH: dimensions is the scaling factor. str: Only for GEOM_MESH: file name (and path) of the collision mesh asset. - np.float[3]: Local position of the collision frame with respect to the center of mass/inertial frame - np.float[4]: Local orientation of the collision frame with respect to the inertial frame + np.array[float[3]]: Local position of the collision frame with respect to the center of mass/inertial + frame + np.array[float[4]]: Local orientation of the collision frame with respect to the inertial frame """ return self.sim.get_collision_shape_data(self.id, link_id=link_id) @@ -468,12 +469,12 @@ class Body(object): int: object unique id. int: link index or -1 for the base int: visual geometry type (TBD) - np.float[3]: dimensions (size, local scale) of the geometry + np.array[float[3]]: dimensions (size, local scale) of the geometry str: path to the triangle mesh, if any. Typically relative to the URDF, SDF or MJCF file location, but could be absolute - np.float[3]: position of local visual frame, relative to link/joint frame - np.float[4]: orientation of local visual frame relative to link/joint frame - list of 4 floats: URDF color (if any specified) in Red / Green / Blue / Alpha + np.array[float[3]]: position of local visual frame, relative to link/joint frame + np.array[float[4]]: orientation of local visual frame relative to link/joint frame + list[float[4]]: URDF color (if any specified) in Red / Green / Blue / Alpha int: texture unique id of the shape or -1 if None. This field only exists if using VISUAL_SHAPE_DATA_TEXTURE_UNIQUE_IDS (=1) flag. """ @@ -519,22 +520,22 @@ class Body(object): Warning: note that we do not convert the data here. Args: - link_ids (int, list of int): link id, or list of desired link ids. + link_ids (int, list[int]): link id, or list of desired link ids. compute_link_velocity (bool): if True, the Cartesian world velocity will be computed and returned. compute_forward_kinematics (bool): if True, the Cartesian world position/orientation will be recomputed using forward kinematics. Returns: if 1 link: - [0] np.array[3]: Cartesian position of center of mass - [1] np.array[4]: Cartesian orientation of center of mass - [2] np.array[3]: local position offset of inertial frame (CoM) expressed in the URDF link frame - [3] np.array[4]: local orientation (quat. [x,y,z,w]) offset of the inertial frame expressed in URDF - link frame - [4] np.array[3]: world position of the URDF link frame - [5] np.array[4]: world orientation of the URDF link frame - [6] np.array[3]: Cartesian world linear velocity - [7] np.array[3]: Cartesian world angular velocity + [0] np.array[float[3]]: Cartesian position of center of mass + [1] np.array[float[4]]: Cartesian orientation of center of mass + [2] np.array[float[3]]: local position offset of inertial frame (CoM) expressed in the URDF link frame + [3] np.array[float[4]]: local orientation (quat. [x,y,z,w]) offset of the inertial frame expressed in + URDF link frame + [4] np.array[float[3]]: world position of the URDF link frame + [5] np.array[float[4]]: world orientation of the URDF link frame + [6] np.array[float[3]]: Cartesian world linear velocity + [7] np.array[float[3]]: Cartesian world angular velocity if multiple links: list of above """ if isinstance(link_ids, int): # one link @@ -549,7 +550,7 @@ class Body(object): Get the state of the given joint(s). Args: - joint_ids (int, list of int): id of the joint, or list of joint ids. + joint_ids (int, list[int]): id of the joint, or list of joint ids. Returns: for 1 joint: @@ -571,7 +572,7 @@ class Body(object): only the desired information. Also, note that we do not convert the data here. Args: - joint_ids (int, list of int): joint id, or list of joint ids. + joint_ids (int, list[int]): joint id, or list of joint ids. Returns: if 1 joint: @@ -592,9 +593,9 @@ class Body(object): [11] float: maximum velocity specified in URDF. Note that this value is not used in actual motor control commands at the moment. [12] str: name of the link (as specified in the URDF/SDF/etc file) - [13] np.array[3]: joint axis in local frame (ignored for JOINT_FIXED) - [14] np.array[3]: joint position in parent frame - [15] np.array[4]: joint orientation in parent frame (x, y, z, w) + [13] np.array[float[3]]: joint axis in local frame (ignored for JOINT_FIXED) + [14] np.array[float[3]]: joint position in parent frame + [15] np.array[float[4]]: joint orientation in parent frame (x, y, z, w) [16] int: parent link index, -1 for base if multiple joints: list of joint information (i.e. list of above) diff --git a/pyrobolearn/robots/baxter.py b/pyrobolearn/robots/baxter.py index 89b3ee7..8751ba0 100644 --- a/pyrobolearn/robots/baxter.py +++ b/pyrobolearn/robots/baxter.py @@ -34,8 +34,8 @@ class Baxter(BiManipulator): Args: simulator (Simulator): simulator instance. - position (np.array[3]): Cartesian world position. - orientation (np.array[4]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. + position (np.array[float[3]]): Cartesian world position. + orientation (np.array[float[4]]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. fixed_base (bool): if True, the robot base will be fixed in the world. scale (float): scaling factor that is used to scale the robot. urdf (str): path to the urdf. Do not change it unless you know what you are doing. @@ -83,8 +83,8 @@ class BaxterGripper(ParallelGripper): Args: simulator (Simulator): simulator instance. - position (np.array[3]): Cartesian world position. - orientation (np.array[4]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. + position (np.array[float[3]]): Cartesian world position. + orientation (np.array[float[4]]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. fixed_base (bool): if True, the gripper will be fixed in the world. scale (float): scaling factor that is used to scale the gripper. urdf (str): path to the urdf. Do not change it unless you know what you are doing. diff --git a/pyrobolearn/robots/bb8.py b/pyrobolearn/robots/bb8.py index c70b6ab..74ab73c 100644 --- a/pyrobolearn/robots/bb8.py +++ b/pyrobolearn/robots/bb8.py @@ -30,8 +30,8 @@ class BB8(Robot): Args: simulator (Simulator): simulator instance. - position (np.array[3]): Cartesian world position. - orientation (np.array[4]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. + position (np.array[float[3]]): Cartesian world position. + orientation (np.array[float[4]]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. fixed_base (bool): if True, the robot base will be fixed in the world. scale (float): scaling factor that is used to scale the robot. urdf (str): path to the urdf. Do not change it unless you know what you are doing. diff --git a/pyrobolearn/robots/blackbird.py b/pyrobolearn/robots/blackbird.py index 4f773f8..1506879 100644 --- a/pyrobolearn/robots/blackbird.py +++ b/pyrobolearn/robots/blackbird.py @@ -34,8 +34,8 @@ class Blackbird(BipedRobot): Args: simulator (Simulator): simulator instance. - position (np.array[3]): Cartesian world position. - orientation (np.array[4]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. + position (np.array[float[3]]): Cartesian world position. + orientation (np.array[float[4]]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. fixed_base (bool): if True, the robot base will be fixed in the world. scale (float): scaling factor that is used to scale the robot. urdf (str): path to the urdf. Do not change it unless you know what you are doing. diff --git a/pyrobolearn/robots/cartpole.py b/pyrobolearn/robots/cartpole.py index cb0320d..ead3b9f 100644 --- a/pyrobolearn/robots/cartpole.py +++ b/pyrobolearn/robots/cartpole.py @@ -42,8 +42,8 @@ class CartPole(Robot): Args: simulator (Simulator): simulator instance. - position (np.array[3]): Cartesian world position. - orientation (np.array[4]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. + position (np.array[float[3]]): Cartesian world position. + orientation (np.array[float[4]]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. fixed_base (bool): if True, the robot base will be fixed in the world. scale (float): scaling factor that is used to scale the robot. num_links (int): number of links / poles connected to each other. diff --git a/pyrobolearn/robots/cassie.py b/pyrobolearn/robots/cassie.py index 978f9be..5e2de69 100644 --- a/pyrobolearn/robots/cassie.py +++ b/pyrobolearn/robots/cassie.py @@ -38,8 +38,8 @@ class Cassie(BipedRobot): Args: simulator (Simulator): simulator instance. - position (np.array[3]): Cartesian world position. - orientation (np.array[4]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. + position (np.array[float[3]]): Cartesian world position. + orientation (np.array[float[4]]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. fixed_base (bool): if True, the robot base will be fixed in the world. scale (float): scaling factor that is used to scale the robot. urdf (str): path to the urdf. Do not change it unless you know what you are doing. diff --git a/pyrobolearn/robots/centauro.py b/pyrobolearn/robots/centauro.py index 3d268bf..7a39cd5 100644 --- a/pyrobolearn/robots/centauro.py +++ b/pyrobolearn/robots/centauro.py @@ -35,8 +35,8 @@ class Centauro(WheeledRobot, QuadrupedRobot, BiManipulator): Args: simulator (Simulator): simulator instance. - position (np.array[3]): Cartesian world position. - orientation (np.array[4]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. + position (np.array[float[3]]): Cartesian world position. + orientation (np.array[float[4]]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. fixed_base (bool): if True, the robot base will be fixed in the world. scale (float): scaling factor that is used to scale the robot. urdf (str): path to the urdf. Do not change it unless you know what you are doing. diff --git a/pyrobolearn/robots/cogimon.py b/pyrobolearn/robots/cogimon.py index e67592a..ac87919 100644 --- a/pyrobolearn/robots/cogimon.py +++ b/pyrobolearn/robots/cogimon.py @@ -31,8 +31,8 @@ class Cogimon(BipedRobot, BiManipulator): Args: simulator (Simulator): simulator instance. - position (np.array[3]): Cartesian world position. - orientation (np.array[4]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. + position (np.array[float[3]]): Cartesian world position. + orientation (np.array[float[4]]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. fixed_base (bool): if True, the robot base will be fixed in the world. scale (float): scaling factor that is used to scale the robot. lower_body (bool): if we should only use the lower body of the robot. diff --git a/pyrobolearn/robots/coman.py b/pyrobolearn/robots/coman.py index 68045c5..ccf06b8 100644 --- a/pyrobolearn/robots/coman.py +++ b/pyrobolearn/robots/coman.py @@ -31,8 +31,8 @@ class Coman(BipedRobot, BiManipulator): Args: simulator (Simulator): simulator instance. - position (np.array[3]): Cartesian world position. - orientation (np.array[4]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. + position (np.array[float[3]]): Cartesian world position. + orientation (np.array[float[4]]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. fixed_base (bool): if True, the robot base will be fixed in the world. scale (float): scaling factor that is used to scale the robot. urdf (str): path to the urdf. Do not change it unless you know what you are doing. diff --git a/pyrobolearn/robots/crab.py b/pyrobolearn/robots/crab.py index 5c23d15..5559d32 100644 --- a/pyrobolearn/robots/crab.py +++ b/pyrobolearn/robots/crab.py @@ -30,8 +30,8 @@ class Crab(HexapodRobot): Args: simulator (Simulator): simulator instance. - position (np.array[3]): Cartesian world position. - orientation (np.array[4]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. + position (np.array[float[3]]): Cartesian world position. + orientation (np.array[float[4]]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. fixed_base (bool): if True, the robot base will be fixed in the world. scale (float): scaling factor that is used to scale the robot. urdf (str): path to the urdf. Do not change it unless you know what you are doing. diff --git a/pyrobolearn/robots/cubli.py b/pyrobolearn/robots/cubli.py index a55fe9f..7977ede 100644 --- a/pyrobolearn/robots/cubli.py +++ b/pyrobolearn/robots/cubli.py @@ -40,8 +40,8 @@ class Cubli(Robot): Args: simulator (Simulator): simulator instance. - position (np.array[3]): Cartesian world position. - orientation (np.array[4]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. + position (np.array[float[3]]): Cartesian world position. + orientation (np.array[float[4]]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. fixed_base (bool): if True, the robot base will be fixed in the world. scale (float): scaling factor that is used to scale the robot. urdf (str): path to the urdf. Do not change it unless you know what you are doing. diff --git a/pyrobolearn/robots/darwin.py b/pyrobolearn/robots/darwin.py index 86e42d6..76fe90f 100644 --- a/pyrobolearn/robots/darwin.py +++ b/pyrobolearn/robots/darwin.py @@ -31,8 +31,8 @@ class Darwin(BipedRobot, BiManipulator): Args: simulator (Simulator): simulator instance. - position (np.array[3]): Cartesian world position. - orientation (np.array[4]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. + position (np.array[float[3]]): Cartesian world position. + orientation (np.array[float[4]]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. fixed_base (bool): if True, the robot base will be fixed in the world. scale (float): scaling factor that is used to scale the robot. urdf (str): path to the urdf. Do not change it unless you know what you are doing. diff --git a/pyrobolearn/robots/ecaa9.py b/pyrobolearn/robots/ecaa9.py index 9997360..dcae9a7 100755 --- a/pyrobolearn/robots/ecaa9.py +++ b/pyrobolearn/robots/ecaa9.py @@ -79,8 +79,8 @@ class ECAA9(UUVRobot): Args: simulator (Simulator): simulator instance. - position (np.array[3]): Cartesian world position. - orientation (np.array[4]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. + position (np.array[float[3]]): Cartesian world position. + orientation (np.array[float[4]]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. fixed_base (bool): if True, the vehicle base will be fixed in the world. scale (float): scaling factor that is used to scale the vehicle. urdf (str): path to the urdf. Do not change it unless you know what you are doing. @@ -111,7 +111,7 @@ class ECAA9(UUVRobot): g (gravity): gravity value in the z direction. Returns: - np.array[3]: buoyancy force + np.array[float[3]]: buoyancy force """ # currently, we assume that the whole body is submerged in the if fluid_density is None: @@ -126,7 +126,7 @@ class ECAA9(UUVRobot): Args: mass (float): mass that will be added to the base link. - local_inertia_diagonal (np.array[3]): local inertia diagonal around the CoM of the base link. + local_inertia_diagonal (np.array[float[3]]): local inertia diagonal around the CoM of the base link. """ info = self.sim.get_dynamics_info(body_id=self.id, link_id=-1) mass += info[0] diff --git a/pyrobolearn/robots/edo.py b/pyrobolearn/robots/edo.py index 490022b..b06e2b4 100644 --- a/pyrobolearn/robots/edo.py +++ b/pyrobolearn/robots/edo.py @@ -33,8 +33,8 @@ class Edo(Manipulator): Args: simulator (Simulator): simulator instance. - position (np.array[3]): Cartesian world position. - orientation (np.array[4]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. + position (np.array[float[3]]): Cartesian world position. + orientation (np.array[float[4]]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. fixed_base (bool): if True, the robot base will be fixed in the world. scale (float): scaling factor that is used to scale the robot. urdf (str): path to the urdf. Do not change it unless you know what you are doing. diff --git a/pyrobolearn/robots/epuck.py b/pyrobolearn/robots/epuck.py index 506dd66..5ef3814 100644 --- a/pyrobolearn/robots/epuck.py +++ b/pyrobolearn/robots/epuck.py @@ -32,8 +32,8 @@ class Epuck(DifferentialWheeledRobot): Args: simulator (Simulator): simulator instance. - position (np.array[3]): Cartesian world position. - orientation (np.array[4]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. + position (np.array[float[3]]): Cartesian world position. + orientation (np.array[float[4]]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. fixed_base (bool): if True, the robot base will be fixed in the world. scale (float): scaling factor that is used to scale the robot. urdf (str): path to the urdf. Do not change it unless you know what you are doing. diff --git a/pyrobolearn/robots/f10_racecar.py b/pyrobolearn/robots/f10_racecar.py index 50b3956..9f62f6a 100644 --- a/pyrobolearn/robots/f10_racecar.py +++ b/pyrobolearn/robots/f10_racecar.py @@ -30,8 +30,8 @@ class F10Racecar(AckermannWheeledRobot): Args: simulator (Simulator): simulator instance. - position (np.array[3]): Cartesian world position. - orientation (np.array[4]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. + position (np.array[float[3]]): Cartesian world position. + orientation (np.array[float[4]]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. fixed_base (bool): if True, the car base will be fixed in the world. scale (float): scaling factor that is used to scale the car. urdf (str): path to the urdf. Do not change it unless you know what you are doing. diff --git a/pyrobolearn/robots/fetch.py b/pyrobolearn/robots/fetch.py index 2d7c7cd..3c677bf 100644 --- a/pyrobolearn/robots/fetch.py +++ b/pyrobolearn/robots/fetch.py @@ -33,8 +33,8 @@ class Fetch(WheeledRobot, Manipulator): Args: simulator (Simulator): simulator instance. - position (np.array[3]): Cartesian world position. - orientation (np.array[4]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. + position (np.array[float[3]]): Cartesian world position. + orientation (np.array[float[4]]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. fixed_base (bool): if True, the robot base will be fixed in the world. scale (float): scaling factor that is used to scale the robot. urdf (str): path to the urdf. Do not change it unless you know what you are doing. @@ -68,8 +68,8 @@ class FetchGripper(ParallelGripper): Args: simulator (Simulator): simulator instance. - position (np.array[3]): Cartesian world position. - orientation (np.array[4]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. + position (np.array[float[3]]): Cartesian world position. + orientation (np.array[float[4]]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. fixed_base (bool): if True, the gripper will be fixed in the world. scale (float): scaling factor that is used to scale the gripper. urdf (str): path to the urdf. Do not change it unless you know what you are doing. diff --git a/pyrobolearn/robots/flappy.py b/pyrobolearn/robots/flappy.py index 73f5cae..3f69e0d 100644 --- a/pyrobolearn/robots/flappy.py +++ b/pyrobolearn/robots/flappy.py @@ -322,8 +322,8 @@ class Flappy(FlappingWingUAV): Args: simulator (Simulator): simulator instance. - position (np.array[3]): Cartesian world position. - orientation (np.array[4]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. + position (np.array[float[3]]): Cartesian world position. + orientation (np.array[float[4]]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. fixed_base (bool): if True, the robot base will be fixed in the world. scale (float): scaling factor that is used to scale the robot. urdf (str): path to the urdf. Do not change it unless you know what you are doing. diff --git a/pyrobolearn/robots/franka.py b/pyrobolearn/robots/franka.py index 9f9979d..21b085f 100644 --- a/pyrobolearn/robots/franka.py +++ b/pyrobolearn/robots/franka.py @@ -37,8 +37,8 @@ class Franka(Manipulator): Args: simulator (Simulator): simulator instance. - position (np.array[3]): Cartesian world position. - orientation (np.array[4]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. + position (np.array[float[3]]): Cartesian world position. + orientation (np.array[float[4]]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. fixed_base (bool): if True, the robot base will be fixed in the world. scale (float): scaling factor that is used to scale the robot. urdf (str): path to the urdf. Do not change it unless you know what you are doing. @@ -79,8 +79,8 @@ class FrankaGripper(ParallelGripper): Args: simulator (Simulator): simulator instance. - position (np.array[3]): Cartesian world position. - orientation (np.array[4]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. + position (np.array[float[3]]): Cartesian world position. + orientation (np.array[float[4]]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. fixed_base (bool): if True, the gripper will be fixed in the world. scale (float): scaling factor that is used to scale the gripper. urdf (str): path to the urdf. Do not change it unless you know what you are doing. diff --git a/pyrobolearn/robots/gripper.py b/pyrobolearn/robots/gripper.py index d11f172..29f6816 100644 --- a/pyrobolearn/robots/gripper.py +++ b/pyrobolearn/robots/gripper.py @@ -27,8 +27,8 @@ class Gripper(Robot): Args: simulator (Simulator): simulator instance. urdf (str): path to the URDF file. - position (np.array[3]): Cartesian world position. - orientation (np.array[4]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. + position (np.array[float[3]]): Cartesian world position. + orientation (np.array[float[4]]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. fixed_base (bool): if True, the gripper will be fixed in the world. scale (float): scaling factor that is used to scale the gripper. """ @@ -75,7 +75,7 @@ class Gripper(Robot): strength (float): scalar describing how much to increases the stiffness (the torques that are applied on the joint fingers). If positive, it closes the gripper fingers. If negative, it opens the gripper fingers. - point (np.array[3], list of np.array[3], None): attractor point(s) described in the specified frame. + point (np.array[float[3]], list of np.array[float[3]], None): attractor point(s) described in the specified frame. If multiple points are specified, they have to match the number of fingers and will be used in the same order. If None, it will grasp in a "natural" way (which is let to the user that has implemented this method). @@ -99,8 +99,8 @@ class ParallelGripper(Gripper): Args: simulator (Simulator): simulator instance. urdf (str): path to the URDF file. - position (np.array[3]): Cartesian world position. - orientation (np.array[4]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. + position (np.array[float[3]]): Cartesian world position. + orientation (np.array[float[4]]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. fixed_base (bool): if True, the gripper will be fixed in the world. scale (float): scaling factor that is used to scale the gripper. """ @@ -121,8 +121,8 @@ class AngularGripper(Gripper): Args: simulator (Simulator): simulator instance. urdf (str): path to the URDF file. - position (np.array[3]): Cartesian world position. - orientation (np.array[4]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. + position (np.array[float[3]]): Cartesian world position. + orientation (np.array[float[4]]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. fixed_base (bool): if True, the gripper will be fixed in the world. scale (float): scaling factor that is used to scale the gripper. """ @@ -143,8 +143,8 @@ class VacuumGripper(Gripper): Args: simulator (Simulator): simulator instance. urdf (str): path to the URDF file. - position (np.array[3]): Cartesian world position. - orientation (np.array[4]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. + position (np.array[float[3]]): Cartesian world position. + orientation (np.array[float[4]]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. fixed_base (bool): if True, the gripper will be fixed in the world. scale (float): scaling factor that is used to scale the gripper. """ diff --git a/pyrobolearn/robots/hand.py b/pyrobolearn/robots/hand.py index 9f068a4..6605f0c 100644 --- a/pyrobolearn/robots/hand.py +++ b/pyrobolearn/robots/hand.py @@ -26,8 +26,8 @@ class Hand(AngularGripper): Args: simulator (Simulator): simulator instance. urdf (str): path to the urdf. Do not change it unless you know what you are doing. - position (np.array[3]): Cartesian world position. - orientation (np.array[4]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. + position (np.array[float[3]]): Cartesian world position. + orientation (np.array[float[4]]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. fixed_base (bool): if True, the robot base will be fixed in the world. scale (float): scaling factor that is used to scale the robot. """ @@ -158,8 +158,8 @@ class TwoHand(Hand): Args: simulator (Simulator): simulator instance. urdf (str): path to the urdf. Do not change it unless you know what you are doing. - position (np.array[3]): Cartesian world position. - orientation (np.array[4]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. + position (np.array[float[3]]): Cartesian world position. + orientation (np.array[float[4]]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. fixed_base (bool): if True, the robot base will be fixed in the world. scale (float): scaling factor that is used to scale the robot. """ diff --git a/pyrobolearn/robots/hubo.py b/pyrobolearn/robots/hubo.py index 8a458a8..5b44b29 100644 --- a/pyrobolearn/robots/hubo.py +++ b/pyrobolearn/robots/hubo.py @@ -40,8 +40,8 @@ class Hubo(BipedRobot, BiManipulator, TwoHand): Args: simulator (Simulator): simulator instance. - position (np.array[3]): Cartesian world position. - orientation (np.array[4]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. + position (np.array[float[3]]): Cartesian world position. + orientation (np.array[float[4]]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. fixed_base (bool): if True, the robot base will be fixed in the world. scale (float): scaling factor that is used to scale the robot. urdf (str): path to the urdf. Do not change it unless you know what you are doing. diff --git a/pyrobolearn/robots/husky.py b/pyrobolearn/robots/husky.py index e96bca6..1724496 100644 --- a/pyrobolearn/robots/husky.py +++ b/pyrobolearn/robots/husky.py @@ -34,8 +34,8 @@ class Husky(DifferentialWheeledRobot): Args: simulator (Simulator): simulator instance. - position (np.array[3]): Cartesian world position. - orientation (np.array[4]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. + position (np.array[float[3]]): Cartesian world position. + orientation (np.array[float[4]]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. fixed_base (bool): if True, the robot base will be fixed in the world. scale (float): scaling factor that is used to scale the robot. urdf (str): path to the urdf. Do not change it unless you know what you are doing. diff --git a/pyrobolearn/robots/hyq.py b/pyrobolearn/robots/hyq.py index 1a7e6e7..12ff062 100644 --- a/pyrobolearn/robots/hyq.py +++ b/pyrobolearn/robots/hyq.py @@ -32,8 +32,8 @@ class HyQ(QuadrupedRobot): Args: simulator (Simulator): simulator instance. - position (np.array[3]): Cartesian world position. - orientation (np.array[4]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. + position (np.array[float[3]]): Cartesian world position. + orientation (np.array[float[4]]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. fixed_base (bool): if True, the robot base will be fixed in the world. scale (float): scaling factor that is used to scale the robot. urdf (str): path to the urdf. Do not change it unless you know what you are doing. diff --git a/pyrobolearn/robots/hyq2max.py b/pyrobolearn/robots/hyq2max.py index eef7c02..8493122 100644 --- a/pyrobolearn/robots/hyq2max.py +++ b/pyrobolearn/robots/hyq2max.py @@ -36,8 +36,8 @@ class HyQ2Max(QuadrupedRobot): Args: simulator (Simulator): simulator instance. - position (np.array[3]): Cartesian world position. - orientation (np.array[4]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. + position (np.array[float[3]]): Cartesian world position. + orientation (np.array[float[4]]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. fixed_base (bool): if True, the robot base will be fixed in the world. scale (float): scaling factor that is used to scale the robot. urdf (str): path to the urdf. Do not change it unless you know what you are doing. @@ -112,4 +112,4 @@ if __name__ == "__main__": print("Draw support polygon") robot.draw_support_polygon(floor_id=world.floor_id, lifetime=0) - world.step(sleep_dt=1./240) + # world.step(sleep_dt=1./240) diff --git a/pyrobolearn/robots/icub.py b/pyrobolearn/robots/icub.py index 0321a70..dd6170f 100644 --- a/pyrobolearn/robots/icub.py +++ b/pyrobolearn/robots/icub.py @@ -34,8 +34,8 @@ class ICub(BipedRobot, BiManipulator): Args: simulator (Simulator): simulator instance. - position (np.array[3]): Cartesian world position. - orientation (np.array[4]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. + position (np.array[float[3]]): Cartesian world position. + orientation (np.array[float[4]]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. fixed_base (bool): if True, the robot base will be fixed in the world. scale (float): scaling factor that is used to scale the robot. urdf (str): path to the urdf. Do not change it unless you know what you are doing. diff --git a/pyrobolearn/robots/jaco.py b/pyrobolearn/robots/jaco.py index d927633..871f621 100644 --- a/pyrobolearn/robots/jaco.py +++ b/pyrobolearn/robots/jaco.py @@ -33,8 +33,8 @@ class Jaco(Manipulator): Args: simulator (Simulator): simulator instance. - position (np.array[3]): Cartesian world position. - orientation (np.array[4]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. + position (np.array[float[3]]): Cartesian world position. + orientation (np.array[float[4]]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. fixed_base (bool): if True, the robot base will be fixed in the world. scale (float): scaling factor that is used to scale the robot. urdf (str): path to the urdf. Do not change it unless you know what you are doing. @@ -69,8 +69,8 @@ class JacoGripper(AngularGripper): Args: simulator (Simulator): simulator instance. - position (np.array[3]): Cartesian world position. - orientation (np.array[4]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. + position (np.array[float[3]]): Cartesian world position. + orientation (np.array[float[4]]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. fixed_base (bool): if True, the gripper will be fixed in the world. scale (float): scaling factor that is used to scale the gripper. urdf (str): path to the urdf. Do not change it unless you know what you are doing. diff --git a/pyrobolearn/robots/kilobot.py b/pyrobolearn/robots/kilobot.py index 0c423d5..b893ba9 100644 --- a/pyrobolearn/robots/kilobot.py +++ b/pyrobolearn/robots/kilobot.py @@ -47,8 +47,8 @@ class Kilobot(Robot): Args: simulator (Simulator): simulator instance. - position (np.array[3]): Cartesian world position. - orientation (np.array[4]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. + position (np.array[float[3]]): Cartesian world position. + orientation (np.array[float[4]]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. fixed_base (bool): if True, the robot base will be fixed in the world. scale (float): scaling factor that is used to scale the robot. urdf (str): path to the urdf. Do not change it unless you know what you are doing. diff --git a/pyrobolearn/robots/kr5.py b/pyrobolearn/robots/kr5.py index 1cdce43..464be91 100644 --- a/pyrobolearn/robots/kr5.py +++ b/pyrobolearn/robots/kr5.py @@ -33,8 +33,8 @@ class KR5(Manipulator): Args: simulator (Simulator): simulator instance. - position (np.array[3]): Cartesian world position. - orientation (np.array[4]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. + position (np.array[float[3]]): Cartesian world position. + orientation (np.array[float[4]]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. fixed_base (bool): if True, the robot base will be fixed in the world. scale (float): scaling factor that is used to scale the robot. urdf (str): path to the urdf. Do not change it unless you know what you are doing. diff --git a/pyrobolearn/robots/kuka_iiwa.py b/pyrobolearn/robots/kuka_iiwa.py index a08a66e..b80ad71 100644 --- a/pyrobolearn/robots/kuka_iiwa.py +++ b/pyrobolearn/robots/kuka_iiwa.py @@ -34,8 +34,8 @@ class KukaIIWA(Manipulator): Args: simulator (Simulator): simulator instance. - position (np.array[3]): Cartesian world position. - orientation (np.array[4]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. + position (np.array[float[3]]): Cartesian world position. + orientation (np.array[float[4]]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. fixed_base (bool): if True, the robot base will be fixed in the world. scale (float): scaling factor that is used to scale the robot. urdf (str): path to the urdf. Do not change it unless you know what you are doing. diff --git a/pyrobolearn/robots/kuka_lwr.py b/pyrobolearn/robots/kuka_lwr.py index e65ff05..9159a1c 100644 --- a/pyrobolearn/robots/kuka_lwr.py +++ b/pyrobolearn/robots/kuka_lwr.py @@ -34,8 +34,8 @@ class KukaLWR(Manipulator): Args: simulator (Simulator): simulator instance. - position (np.array[3]): Cartesian world position. - orientation (np.array[4]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. + position (np.array[float[3]]): Cartesian world position. + orientation (np.array[float[4]]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. fixed_base (bool): if True, the robot base will be fixed in the world. scale (float): scaling factor that is used to scale the robot. urdf (str): path to the urdf. Do not change it unless you know what you are doing. diff --git a/pyrobolearn/robots/laikago.py b/pyrobolearn/robots/laikago.py index 35db37f..952a297 100644 --- a/pyrobolearn/robots/laikago.py +++ b/pyrobolearn/robots/laikago.py @@ -31,8 +31,8 @@ class Laikago(QuadrupedRobot): Args: simulator (Simulator): simulator instance. - position (np.array[3]): Cartesian world position. - orientation (np.array[4]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. + position (np.array[float[3]]): Cartesian world position. + orientation (np.array[float[4]]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. fixed_base (bool): if True, the robot base will be fixed in the world. scale (float): scaling factor that is used to scale the robot. urdf (str): path to the urdf. Do not change it unless you know what you are doing. diff --git a/pyrobolearn/robots/legged_robot.py b/pyrobolearn/robots/legged_robot.py index 24ae889..14c7a4a 100644 --- a/pyrobolearn/robots/legged_robot.py +++ b/pyrobolearn/robots/legged_robot.py @@ -36,8 +36,8 @@ class LeggedRobot(Robot): Args: simulator (Simulator): simulator instance. urdf (str): path to the urdf. Do not change it unless you know what you are doing. - position (np.array[3]): Cartesian world position. - orientation (np.array[4]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. + position (np.array[float[3]]): Cartesian world position. + orientation (np.array[float[4]]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. fixed_base (bool): if True, the robot base will be fixed in the world. scale (float): scaling factor that is used to scale the robot. foot_frictions (float, list of float): foot friction value(s). @@ -181,7 +181,7 @@ class LeggedRobot(Robot): floor_id (int, None): id of the floor in the simulator. If None, it will use the force/pressure sensors. Returns: - np.array[3], None: center of pressure. None if the robot is not in contact with the ground. + np.array[float[3]], None: center of pressure. None if the robot is not in contact with the ground. References: - [1] "Postural Stability of Biped Robots and Foot-Rotation Index (FRI) Point", Goswami, 1999 @@ -273,7 +273,7 @@ class LeggedRobot(Robot): floor_id (int, None): id of the floor in the simulator. If None, it will use the force/pressure sensors. Returns: - np.array[3], None: zero-moment point. None if the ground reaction force in z is 0. + np.array[float[3]], None: zero-moment point. None if the ground reaction force in z is 0. References: - [1] "Ground Reference Points in Legged Locomotion: Definitions, Biological Trajectories and Control @@ -391,7 +391,7 @@ class LeggedRobot(Robot): floor_id (int, None): id of the floor in the simulator. If None, it will use the force/pressure sensors. Returns: - np.array[3], None: centroidal moment pivot point. None if the ground reaction force in z is 0. + np.array[float[3]], None: centroidal moment pivot point. None if the ground reaction force in z is 0. References: - [1] "Ground Reference Points in Legged Locomotion: Definitions, Biological Trajectories and Control @@ -646,7 +646,7 @@ class LeggedRobot(Robot): Draw the CoP in the simulator. Args: - cop (np.array[3], None, int): center of pressure. If None or int, it will compute the CoP. If None, it + cop (np.array[float[3]], None, int): center of pressure. If None or int, it will compute the CoP. If None, it will compute it using the force sensors. If int, it will be assumed to be the floor's id, and will use the simulator to compute the CoP. radius (float): radius of the sphere representing the CoP of the robot @@ -668,7 +668,7 @@ class LeggedRobot(Robot): Draw the ZMP in the simulator. Args: - zmp (np.array[3], None, int): zero-moment point. If None or int, it will compute the ZMP. If None, it + zmp (np.array[float[3]], None, int): zero-moment point. If None or int, it will compute the ZMP. If None, it will compute it using the force sensors. If int, it will be assumed to be the floor's id, and will use the simulator to compute the ZMP. radius (float): radius of the sphere representing the ZMP of the robot @@ -691,7 +691,7 @@ class LeggedRobot(Robot): Draw the CMP in the simulator. Args: - cmp (np.array[3], None, int): central moment pivot. If None or int, it will compute the CMP. If None, it + cmp (np.array[float[3]], None, int): central moment pivot. If None or int, it will compute the CMP. If None, it will compute it using the force sensors. If int, it will be assumed to be the floor's id, and will use the simulator to compute the CMP. radius (float): radius of the sphere representing the CMP of the robot @@ -714,7 +714,7 @@ class LeggedRobot(Robot): Draw the FRI in the simulator. Args: - fri (np.array[3], None, int): central moment pivot. If None or int, it will compute the FRI. If None, it + fri (np.array[float[3]], None, int): central moment pivot. If None or int, it will compute the FRI. If None, it will compute it using the force sensors. If int, it will be assumed to be the floor's id, and will use the simulator to compute the FRI. radius (float): radius of the sphere representing the FRI of the robot @@ -805,8 +805,8 @@ class BipedRobot(LeggedRobot): Args: simulator (Simulator): simulator instance. urdf (str): path to the urdf. Do not change it unless you know what you are doing. - position (np.array[3]): Cartesian world position. - orientation (np.array[4]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. + position (np.array[float[3]]): Cartesian world position. + orientation (np.array[float[4]]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. fixed_base (bool): if True, the robot base will be fixed in the world. scale (float): scaling factor that is used to scale the robot. """ @@ -853,8 +853,8 @@ class QuadrupedRobot(LeggedRobot): Args: simulator (Simulator): simulator instance. urdf (str): path to the urdf. Do not change it unless you know what you are doing. - position (np.array[3]): Cartesian world position. - orientation (np.array[4]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. + position (np.array[float[3]]): Cartesian world position. + orientation (np.array[float[4]]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. fixed_base (bool): if True, the robot base will be fixed in the world. scale (float): scaling factor that is used to scale the robot. """ @@ -923,8 +923,8 @@ class HexapodRobot(LeggedRobot): Args: simulator (Simulator): simulator instance. urdf (str): path to the urdf. Do not change it unless you know what you are doing. - position (np.array[3]): Cartesian world position. - orientation (np.array[4]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. + position (np.array[float[3]]): Cartesian world position. + orientation (np.array[float[4]]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. fixed_base (bool): if True, the robot base will be fixed in the world. scale (float): scaling factor that is used to scale the robot. """ diff --git a/pyrobolearn/robots/littledog.py b/pyrobolearn/robots/littledog.py index 3533eb0..35c6796 100644 --- a/pyrobolearn/robots/littledog.py +++ b/pyrobolearn/robots/littledog.py @@ -32,8 +32,8 @@ class LittleDog(QuadrupedRobot): Args: simulator (Simulator): simulator instance. - position (np.array[3]): Cartesian world position. - orientation (np.array[4]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. + position (np.array[float[3]]): Cartesian world position. + orientation (np.array[float[4]]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. fixed_base (bool): if True, the robot base will be fixed in the world. scale (float): scaling factor that is used to scale the robot. urdf (str): path to the urdf. Do not change it unless you know what you are doing. diff --git a/pyrobolearn/robots/manipulator.py b/pyrobolearn/robots/manipulator.py index 8db2814..baf3be3 100644 --- a/pyrobolearn/robots/manipulator.py +++ b/pyrobolearn/robots/manipulator.py @@ -27,8 +27,8 @@ class Manipulator(Robot): Args: simulator (Simulator): simulator instance. urdf (str): path to the urdf. Do not change it unless you know what you are doing. - position (np.array[3]): Cartesian world position. - orientation (np.array[4]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. + position (np.array[float[3]]): Cartesian world position. + orientation (np.array[float[4]]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. fixed_base (bool): if True, the robot base will be fixed in the world. scale (float): scaling factor that is used to scale the robot. """ @@ -135,8 +135,8 @@ class BiManipulator(Manipulator): Args: simulator (Simulator): simulator instance. urdf (str): path to the urdf. Do not change it unless you know what you are doing. - position (np.array[3]): Cartesian world position. - orientation (np.array[4]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. + position (np.array[float[3]]): Cartesian world position. + orientation (np.array[float[4]]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. fixed_base (bool): if True, the robot base will be fixed in the world. scale (float): scaling factor that is used to scale the robot. """ diff --git a/pyrobolearn/robots/manipulator2d.py b/pyrobolearn/robots/manipulator2d.py index 7443cc3..1417c50 100644 --- a/pyrobolearn/robots/manipulator2d.py +++ b/pyrobolearn/robots/manipulator2d.py @@ -30,8 +30,8 @@ class Manipulator2D(Manipulator): Args: simulator (Simulator): simulator instance. - position (np.array[3]): Cartesian world position. - orientation (np.array[4]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. + position (np.array[float[3]]): Cartesian world position. + orientation (np.array[float[4]]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. fixed_base (bool): if True, the robot base will be fixed in the world. scale (float): scaling factor that is used to scale the robot. urdf (str): path to the urdf. Do not change it unless you know what you are doing. diff --git a/pyrobolearn/robots/minitaur.py b/pyrobolearn/robots/minitaur.py index 646415d..979d3e7 100644 --- a/pyrobolearn/robots/minitaur.py +++ b/pyrobolearn/robots/minitaur.py @@ -35,8 +35,8 @@ class Minitaur(QuadrupedRobot): Args: simulator (Simulator): simulator instance. - position (np.array[3]): Cartesian world position. - orientation (np.array[4]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. + position (np.array[float[3]]): Cartesian world position. + orientation (np.array[float[4]]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. fixed_base (bool): if True, the robot base will be fixed in the world. scale (float): scaling factor that is used to scale the robot. couple_legs (bool): if True, it will couple the legs by setting a constraint between two legs. diff --git a/pyrobolearn/robots/mkz.py b/pyrobolearn/robots/mkz.py index 8fb37b3..13300d9 100644 --- a/pyrobolearn/robots/mkz.py +++ b/pyrobolearn/robots/mkz.py @@ -34,8 +34,8 @@ class MKZ(AckermannWheeledRobot): Args: simulator (Simulator): simulator instance. - position (np.array[3]): Cartesian world position. - orientation (np.array[4]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. + position (np.array[float[3]]): Cartesian world position. + orientation (np.array[float[4]]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. fixed_base (bool): if True, the robot base will be fixed in the world. scale (float): scaling factor that is used to scale the robot. urdf (str): path to the urdf. Do not change it unless you know what you are doing. diff --git a/pyrobolearn/robots/morphex.py b/pyrobolearn/robots/morphex.py index 1468e77..0b046e5 100644 --- a/pyrobolearn/robots/morphex.py +++ b/pyrobolearn/robots/morphex.py @@ -30,8 +30,8 @@ class Morphex(HexapodRobot): Args: simulator (Simulator): simulator instance. - position (np.array[3]): Cartesian world position. - orientation (np.array[4]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. + position (np.array[float[3]]): Cartesian world position. + orientation (np.array[float[4]]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. fixed_base (bool): if True, the robot base will be fixed in the world. scale (float): scaling factor that is used to scale the robot. urdf (str): path to the urdf. Do not change it unless you know what you are doing. diff --git a/pyrobolearn/robots/nao.py b/pyrobolearn/robots/nao.py index ac3181c..47068d5 100644 --- a/pyrobolearn/robots/nao.py +++ b/pyrobolearn/robots/nao.py @@ -32,8 +32,8 @@ class Nao(BipedRobot, BiManipulator, TwoHand): Args: simulator (Simulator): simulator instance. - position (np.array[3]): Cartesian world position. - orientation (np.array[4]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. + position (np.array[float[3]]): Cartesian world position. + orientation (np.array[float[4]]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. fixed_base (bool): if True, the robot base will be fixed in the world. scale (float): scaling factor that is used to scale the robot. urdf (str): path to the urdf. Do not change it unless you know what you are doing. diff --git a/pyrobolearn/robots/opendog.py b/pyrobolearn/robots/opendog.py index b855cf2..3dacd8a 100644 --- a/pyrobolearn/robots/opendog.py +++ b/pyrobolearn/robots/opendog.py @@ -30,8 +30,8 @@ class OpenDog(QuadrupedRobot): Args: simulator (Simulator): simulator instance. - position (np.array[3]): Cartesian world position. - orientation (np.array[4]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. + position (np.array[float[3]]): Cartesian world position. + orientation (np.array[float[4]]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. fixed_base (bool): if True, the robot base will be fixed in the world. scale (float): scaling factor that is used to scale the robot. urdf (str): path to the urdf. Do not change it unless you know what you are doing. diff --git a/pyrobolearn/robots/pendulum.py b/pyrobolearn/robots/pendulum.py index ab7e4b4..9f390f7 100644 --- a/pyrobolearn/robots/pendulum.py +++ b/pyrobolearn/robots/pendulum.py @@ -31,8 +31,8 @@ class Pendulum(Robot): # TODO: create the pendulum dynamically instead of loadi Args: simulator (Simulator): simulator instance. - position (np.array[3]): Cartesian world position. - orientation (np.array[4]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. + position (np.array[float[3]]): Cartesian world position. + orientation (np.array[float[4]]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. fixed_base (bool): if True, the robot base will be fixed in the world. scale (float): scaling factor that is used to scale the robot. urdf (str): path to the urdf. Do not change it unless you know what you are doing. diff --git a/pyrobolearn/robots/pepper.py b/pyrobolearn/robots/pepper.py index 37c12d2..97ed180 100644 --- a/pyrobolearn/robots/pepper.py +++ b/pyrobolearn/robots/pepper.py @@ -39,8 +39,8 @@ class Pepper(WheeledRobot, BiManipulator): Args: simulator (Simulator): simulator instance. - position (np.array[3]): Cartesian world position. - orientation (np.array[4]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. + position (np.array[float[3]]): Cartesian world position. + orientation (np.array[float[4]]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. fixed_base (bool): if True, the robot base will be fixed in the world. scale (float): scaling factor that is used to scale the robot. urdf (str): path to the urdf. Do not change it unless you know what you are doing. diff --git a/pyrobolearn/robots/phantomx.py b/pyrobolearn/robots/phantomx.py index ad8d3c8..9f8d4aa 100644 --- a/pyrobolearn/robots/phantomx.py +++ b/pyrobolearn/robots/phantomx.py @@ -30,8 +30,8 @@ class PhantomX(HexapodRobot): Args: simulator (Simulator): simulator instance. - position (np.array[3]): Cartesian world position. - orientation (np.array[4]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. + position (np.array[float[3]]): Cartesian world position. + orientation (np.array[float[4]]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. fixed_base (bool): if True, the robot base will be fixed in the world. scale (float): scaling factor that is used to scale the robot. urdf (str): path to the urdf. Do not change it unless you know what you are doing. diff --git a/pyrobolearn/robots/pleurobot.py b/pyrobolearn/robots/pleurobot.py index 68e4730..0dd5822 100644 --- a/pyrobolearn/robots/pleurobot.py +++ b/pyrobolearn/robots/pleurobot.py @@ -32,8 +32,8 @@ class Pleurobot(QuadrupedRobot, UUVRobot, USVRobot): Args: simulator (Simulator): simulator instance. - position (np.array[3]): Cartesian world position. - orientation (np.array[4]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. + position (np.array[float[3]]): Cartesian world position. + orientation (np.array[float[4]]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. fixed_base (bool): if True, the robot base will be fixed in the world. scale (float): scaling factor that is used to scale the robot. urdf (str): path to the urdf. Do not change it unless you know what you are doing. diff --git a/pyrobolearn/robots/pr2.py b/pyrobolearn/robots/pr2.py index c60f083..2cd21d1 100644 --- a/pyrobolearn/robots/pr2.py +++ b/pyrobolearn/robots/pr2.py @@ -33,8 +33,8 @@ class PR2(WheeledRobot, BiManipulator): Args: simulator (Simulator): simulator instance. - position (np.array[3]): Cartesian world position. - orientation (np.array[4]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. + position (np.array[float[3]]): Cartesian world position. + orientation (np.array[float[4]]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. fixed_base (bool): if True, the robot base will be fixed in the world. scale (float): scaling factor that is used to scale the robot. urdf (str): path to the urdf. Do not change it unless you know what you are doing. @@ -68,8 +68,8 @@ class PR2Gripper(AngularGripper): Args: simulator (Simulator): simulator instance. - position (np.array[3]): Cartesian world position. - orientation (np.array[4]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. + position (np.array[float[3]]): Cartesian world position. + orientation (np.array[float[4]]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. fixed_base (bool): if True, the gripper will be fixed in the world. scale (float): scaling factor that is used to scale the gripper. urdf (str): path to the urdf. Do not change it unless you know what you are doing. diff --git a/pyrobolearn/robots/quadcopter.py b/pyrobolearn/robots/quadcopter.py index c90bd82..314769d 100644 --- a/pyrobolearn/robots/quadcopter.py +++ b/pyrobolearn/robots/quadcopter.py @@ -75,8 +75,8 @@ class Quadcopter(RotaryWingUAV): Args: simulator (Simulator): simulator instance. - position (np.array[3]): Cartesian world position. - orientation (np.array[4]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. + position (np.array[float[3]]): Cartesian world position. + orientation (np.array[float[4]]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. fixed_base (bool): if True, the robot base will be fixed in the world. scale (float): scaling factor that is used to scale the robot. urdf (str): path to the urdf. Do not change it unless you know what you are doing. @@ -156,7 +156,7 @@ class Quadcopter(RotaryWingUAV): joint id(s). Args: - velocities (np.array[4]): velocity of each propeller + velocities (np.array[float[4]]): velocity of each propeller forces (float, np.float[N], None, bool): maximum motor torques / forces. If True, it will apply the default maximum force values. max_velocity (float, bool, None): if True, it will make sure that the given velocity(ies) are below their @@ -242,7 +242,7 @@ class Quadcopter(RotaryWingUAV): """Move the robot at the specified 3D velocity vector. Args: - velocity (np.array[3]): 3D velocity vector defined in the xy plane. The magnitude represents the speed. + velocity (np.array[float[3]]): 3D velocity vector defined in the xy plane. The magnitude represents the speed. """ speed = np.linalg.norm(velocity[:2]) angle = np.arctan2(velocity[1], velocity[0]) diff --git a/pyrobolearn/robots/rhex.py b/pyrobolearn/robots/rhex.py index de3a5db..1749dc8 100644 --- a/pyrobolearn/robots/rhex.py +++ b/pyrobolearn/robots/rhex.py @@ -36,8 +36,8 @@ class Rhex(HexapodRobot): Args: simulator (Simulator): simulator instance. - position (np.array[3]): Cartesian world position. - orientation (np.array[4]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. + position (np.array[float[3]]): Cartesian world position. + orientation (np.array[float[4]]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. fixed_base (bool): if True, the robot base will be fixed in the world. scale (float): scaling factor that is used to scale the robot. urdf (str): path to the urdf. Do not change it unless you know what you are doing. diff --git a/pyrobolearn/robots/robot.py b/pyrobolearn/robots/robot.py index d78e84c..06bc325 100644 --- a/pyrobolearn/robots/robot.py +++ b/pyrobolearn/robots/robot.py @@ -66,8 +66,8 @@ class Robot(ControllableBody): Args: simulator: reference to the simulator such that the robot can access it. urdf (str): path to the URDF/MJCF file. - position (np.array[3]): initial position. - orientation (np.array[4]): initial orientation represented as a quaternion (x,y,z,w). + position (np.array[float[3]]): initial position. + orientation (np.array[float[4]]): initial orientation represented as a quaternion (x,y,z,w). fixed_base (bool, None): if True, the base of the robot will be fixed. scale (float): scaling factor. visual_ticks (int): the number of ticks to sleep before updating the visuals. @@ -341,10 +341,10 @@ class Robot(ControllableBody): Returns: if concatenate: - np.array[7]: concatenated position and orientation + np.array[float[7]]: concatenated position and orientation else: - np.array[3]: position - np.array[4]: orientation (x, y, z, w) + np.array[float[3]]: position + np.array[float[4]]: orientation (x, y, z, w) """ pose = self.sim.get_base_pose(self.id) if concatenate: @@ -356,7 +356,7 @@ class Robot(ControllableBody): Return the base position. Returns: - np.array[3]: base position. + np.array[float[3]]: base position. """ return self.sim.get_base_position(self.id) @@ -365,7 +365,7 @@ class Robot(ControllableBody): Get the base orientation in the form of a quaternion (x, y, z, w). Returns: - quaternion (np.array[4]): base orientation in the form of a quaternion (x, y, z, w). + quaternion (np.array[float[4]]): base orientation in the form of a quaternion (x, y, z, w). """ return self.sim.get_base_orientation(self.id) @@ -378,10 +378,10 @@ class Robot(ControllableBody): Returns: if concatenate: - np.array[6]: linear and angular velocities of the base + np.array[float[6]]: linear and angular velocities of the base else: - np.array[3]: linear velocity of the base - np.array[3]: angular velocity of the base + np.array[float[3]]: linear velocity of the base + np.array[float[3]]: angular velocity of the base """ # check if cached if 'vel' in self._state: @@ -399,7 +399,7 @@ class Robot(ControllableBody): Return the linear velocity of the base. Returns: - np.array[3]: linear velocity of the base + np.array[float[3]]: linear velocity of the base """ return self.sim.get_base_linear_velocity(self.id) @@ -408,7 +408,7 @@ class Robot(ControllableBody): Return the angular velocity of the base. Returns: - np.array[3]: angular velocity of the base + np.array[float[3]]: angular velocity of the base """ return self.sim.get_base_angular_velocity(self.id) @@ -417,7 +417,7 @@ class Robot(ControllableBody): Return the base spatial velocity (which is the concatenation of the angular and linear velocity). Returns: - np.array[6]: spatial velocity + np.array[float[6]]: spatial velocity """ lin_vel, ang_vel = self.get_base_velocity(concatenate=False) return np.concatenate((ang_vel, lin_vel)) @@ -430,10 +430,10 @@ class Robot(ControllableBody): Returns: if concatenate: - np.array[6]: concatenation of the linear and angular acceleration + np.array[float[6]]: concatenation of the linear and angular acceleration else: - np.array[3]: linear acceleration - np.array[3]: angular acceleration + np.array[float[3]]: linear acceleration + np.array[float[3]]: angular acceleration """ # check if cached if 'acc' in self._state: @@ -484,7 +484,7 @@ class Robot(ControllableBody): zero vector for the linear acceleration). Returns: - np.array[3]: linear acceleration + np.array[float[3]]: linear acceleration """ return self.get_base_acceleration(concatenate=False)[0] @@ -495,7 +495,7 @@ class Robot(ControllableBody): zero vector for the angular acceleration). Returns: - np.array[3]: angular acceleration + np.array[float[3]]: angular acceleration """ return self.get_base_acceleration(concatenate=False)[1] @@ -504,7 +504,7 @@ class Robot(ControllableBody): Return the base spatial acceleration (which is the concatenation of the angular and linear acceleration). Returns: - np.array[6]: spatial acceleration + np.array[float[6]]: spatial acceleration """ lin_acc, ang_acc = self.get_base_acceleration(concatenate=False) return np.concatenate((ang_acc, lin_acc)) @@ -561,7 +561,7 @@ class Robot(ControllableBody): Return the center of mass position. Returns: - np.array[3]: center of mass position [m] + np.array[float[3]]: center of mass position [m] """ if 'com' in self._state: return self._state['com'] @@ -577,7 +577,7 @@ class Robot(ControllableBody): Return the center of mass velocity. Returns: - np.array[3]: center of mass velocity [m/s] + np.array[float[3]]: center of mass velocity [m/s] """ if 'com_vel' in self._state: return self._state['com_vel'][0] @@ -593,7 +593,7 @@ class Robot(ControllableBody): Return the center of mass acceleration. Returns: - np.array[3]: center of mass acceleration [m/s] + np.array[float[3]]: center of mass acceleration [m/s] """ # if already cached, return it if 'com_acc' in self._state: @@ -635,7 +635,7 @@ class Robot(ControllableBody): # where :math:`p` is the linear momentum, :math:`m` is the total mass, and :math:`v` is the velocity. # # Returns: - # np.array[3]: linear momentum + # np.array[float[3]]: linear momentum # """ # return self.mass * self.get_base_linear_velocity() # @@ -649,7 +649,7 @@ class Robot(ControllableBody): # and :math:`\omega` is the angular velocity. # # Returns: - # np.array[3]: angular momentum + # np.array[float[3]]: angular momentum # """ # pass @@ -665,7 +665,7 @@ class Robot(ControllableBody): while the q index goes from 0 to the number of actuated joints. Args: - joint (str, int, list of str/int, None): if str, it will get the joint id associated to the given name. + joint (str, int, list[int,str], None): if str, it will get the joint id associated to the given name. If int, it will get the joint id associated to the given q index. If it is a list of str and/or int, it will get the corresponding joint ids. If None, it will return all the (actuated) joint ids. @@ -673,7 +673,7 @@ class Robot(ControllableBody): if 1 joint: int: joint id if multiple joint: - int[N]: joint ids + list[int[N]]: joint ids """ if joint is None: return self.joints @@ -701,14 +701,14 @@ class Robot(ControllableBody): only the desired information. Also, note that we do not convert the data here. Args: - joint_ids (int, int[N], None): joint id, or list of joint ids. If None, return the information for all - (actuated) joints. + joint_ids (int, list[int], None): joint id, or list of joint ids. If None, return the information for + all (actuated) joints. Returns: if 1 joint: [0] int: the same joint id as the input parameter [1] str: name of the joint (as specified in the URDF/SDF/etc file) - [2] int: type of the joint which implie the number of position and velocity variables. + [2] int: type of the joint which implies the number of position and velocity variables. The types include JOINT_REVOLUTE (=0), JOINT_PRISMATIC (=1), JOINT_SPHERICAL (=2), JOINT_PLANAR (=3), and JOINT_FIXED (=4). [3] int: q index - the first position index in the positional state variables for this body @@ -723,9 +723,9 @@ class Robot(ControllableBody): [11] float: maximum velocity specified in URDF. Note that this value is not used in actual motor control commands at the moment. [12] str: name of the link (as specified in the URDF/SDF/etc file) - [13] np.array[3]: joint axis in local frame (ignored for JOINT_FIXED) - [14] np.array[3]: joint position in parent frame - [15] np.array[4]: joint orientation in parent frame (x, y, z, w) + [13] np.array[float[3]]: joint axis in local frame (ignored for JOINT_FIXED) + [14] np.array[float[3]]: joint position in parent frame + [15] np.array[float[4]]: joint orientation in parent frame (x, y, z, w) [16] int: parent link index, -1 for base if multiple joints: list of joint information (i.e. list of above) @@ -744,14 +744,14 @@ class Robot(ControllableBody): only the desired information. Also, note that we do not convert the data here. Args: - joint_ids (int, int[N], None): joint id, or list of joint ids. If None, return the axis for all + joint_ids (int, list[int], None): joint id, or list of joint ids. If None, return the axis for all (actuated) joints. Returns: if 1 joint: - np.array[3]: joint axis + np.array[float[3]]: joint axis if multiple joint: - [np.array[3]]: list of joint axis + list[np.array[float[3]]]: list of joint axis """ if joint_ids is None: joint_ids = self.joints @@ -762,14 +762,14 @@ class Robot(ControllableBody): Get the corresponding q index of the given joint(s). Args: - joint_ids (int, int[N], None): joint id, or list of joint ids. If None, return the q indices for all + joint_ids (int, list[int], None): joint id, or list of joint ids. If None, return the q indices for all (actuated) joints. Returns: if 1 joint: int: q index if multiple joints: - int[N]: q indices + list[int]: q indices """ if joint_ids is None: joint_ids = self.joints @@ -780,7 +780,7 @@ class Robot(ControllableBody): Get the joint type as a string or integer. Args: - joint_ids (int, int[N], None): joint id, or list of joint ids. If None, return the information for all + joint_ids (int, list[int], None): joint id, or list of joint ids. If None, return the information for all (actuated) joints. to_string (bool): if True, it will return the joint type in a readable string format @@ -805,9 +805,9 @@ class Robot(ControllableBody): Returns: if 1 joint: - np.array[2]: lower and upper limit + np.array[float[2]]: lower and upper limit if multiple joints: - np.array[N,2]: lower and upper limit for each specified joint + np.array[float[N,2]]: lower and upper limit for each specified joint """ if joint_ids is None: joint_ids = self.joints @@ -818,14 +818,14 @@ class Robot(ControllableBody): Get the damping coefficient of the given joint(s). Args: - joint_ids (int, int[N], None): joint id, or list of joint ids. If None, return the information for all - (actuated) joints. + joint_ids (int, list[int[M]], None): joint id, or list of joint ids. If None, return the information for + all (actuated) joints. Returns: if 1 joint: float: damping coefficient of the given joint if multiple joints: - np.array[N]: damping coefficient for each specified joint + np.array[float[M]]: damping coefficient for each specified joint """ if joint_ids is None: joint_ids = self.joints @@ -836,14 +836,14 @@ class Robot(ControllableBody): Get the friction coefficient of the given joint(s). Args: - joint_ids (int, int[N], None): joint id, or list of joint ids. If None, return the information for all - (actuated) joints. + joint_ids (int, list[int[M]], None): joint id, or list of joint ids. If None, return the information for + all (actuated) joints. Returns: if 1 joint: float: friction coefficient of the given joint if multiple joints: - np.array[N]: friction coefficient for each specified joint + np.array[float[M]]: friction coefficient for each specified joint """ if joint_ids is None: joint_ids = self.joints @@ -856,14 +856,14 @@ class Robot(ControllableBody): Warning: Note that this is not automatically used in position, velocity, or torque control. Args: - joint_ids (int, int[N], None): joint id, or list of joint ids. If None, return the information for all - (actuated) joints. + joint_ids (int, list[int[M]], None): joint id, or list of joint ids. If None, return the information for + all (actuated) joints. Returns: if 1 joint: float: maximum force [N] if multiple joints: - np.array[N]: maximum force for each specified joint [N] + np.array[float[M]]: maximum force for each specified joint [N] """ if joint_ids is None: joint_ids = self.joints @@ -876,14 +876,14 @@ class Robot(ControllableBody): Warning: Note that this is not automatically used in position, velocity, or torque control. Args: - joint_ids (int, int[N], None): joint id, or list of joint ids. If None, return the information for all - (actuated) joints. + joint_ids (int, list[int[M]], None): joint id, or list of joint ids. If None, return the information for + all (actuated) joints. Returns: if 1 joint: float: maximum velocity [rad/s] if multiple joints: - np.array[N]: maximum velocities for each specified joint [rad/s] + np.array[float[M]]: maximum velocities for each specified joint [rad/s] """ if joint_ids is None: joint_ids = self.joints @@ -894,13 +894,14 @@ class Robot(ControllableBody): Return the name of the given joint(s). Args: - joint_ids (int, int[N]): joint id, or list of joint ids. If None, get the name of all (actuated) joints. + joint_ids (int, list[int[M]]): joint id, or list of joint ids. If None, get the name of all (actuated) + joints. Returns: if 1 joint: str: name of the joint if multiple joints: - str[N]: name of each joint + list[str[M]]: name of each joint """ if joint_ids is None: joint_ids = self.joints @@ -911,14 +912,14 @@ class Robot(ControllableBody): Get the state of the given joint(s). Args: - joint_ids (int, int[N], None): id of the joint, or list of joint ids. If None, get the state of all + joint_ids (int, list[int], None): id of the joint, or list of joint ids. If None, get the state of all (actuated) joints. Returns: for 1 joint: float: joint position [rad] float: joint velocity [rad/s] - np.array[6]: joint reaction forces [fx,fy,fz,mx,my,mz] + np.array[float[6]]: joint reaction forces [fx,fy,fz,mx,my,mz] float: applied joint motor torque (during the last step) for multiple joints: list of each joint state """ @@ -935,14 +936,14 @@ class Robot(ControllableBody): See Also: :func:`~Robot.get_augmented_joint_positions`. Args: - joint_ids (int, int[N], None): joint id, or list of joint ids. If None, get the position of all (actuated) - joints. + joint_ids (int, list[int[M]], None): joint id, or list of joint ids. If None, get the position of all + (actuated) joints. Returns: if 1 joint: float: joint position [rad] if multiple joints: - np.array[N]: joint positions [rad] + np.array[float[M]]: joint positions [rad] """ # check if cached if 'q' in self._state: @@ -965,14 +966,14 @@ class Robot(ControllableBody): If the robot has a fixed base, this is the same as calling :func:`~Robot.get_joint_positions`. Args: - joint_ids (int, int[N], None): joint id, or list of joint ids. If None, get the position of all (actuated) - joints. + joint_ids (int, list[int[M]], None): joint id, or list of joint ids. If None, get the position of all + (actuated) joints. Returns: if 1 joint: - float, np.array[6+1]: joint position(s) [rad] + float, np.array[float[6+1]]: joint position(s) [rad] if multiple joints: - np.array[N], np.array[6+N]: joint positions [rad] + np.array[float[M]], np.array[float[6+M]]: joint positions [rad] """ q = self.get_joint_positions(joint_ids=joint_ids) if self.has_fixed_base(): @@ -988,14 +989,14 @@ class Robot(ControllableBody): See Also: :func:`~Robot.get_augmented_joint_velocities`. Args: - joint_ids (int, int[N], None): joint id, or list of joint ids. If None, get the velocity of all (actuated) - joints. + joint_ids (int, list[int[N]], None): joint id, or list of joint ids. If None, get the velocity of all + (actuated) joints. Returns: if 1 joint: float: joint velocity [rad/s] if multiple joints: - np.array[N]: joint velocities [rad/s] + np.array[float[N]]: joint velocities [rad/s] """ # check if cached if 'dq' in self._state: @@ -1023,9 +1024,9 @@ class Robot(ControllableBody): Returns: if 1 joint: - float, np.array[6+1]: joint velocity [rad/s] + float, np.array[float[6+1]]: joint velocity [rad/s] if multiple joints: - np.array[N], np.array[6+N]: joint velocities [rad/s] + np.array[float[N]], np.array[float[6+N]]: joint velocities [rad/s] """ dq = self.get_joint_velocities(joint_ids=joint_ids) if self.has_fixed_base(): @@ -1048,7 +1049,7 @@ class Robot(ControllableBody): # if 1 joint: # float: joint acceleration [rad/s^2] # if multiple joints: - # np.array[N]: joint accelerations [rad/s^2] + # np.array[float[N]]: joint accelerations [rad/s^2] # """ # # check joint id # if joint_ids is None: @@ -1084,7 +1085,7 @@ class Robot(ControllableBody): if 1 joint: float: joint acceleration [rad/s^2] if multiple joints: - np.array[N]: joint accelerations [rad/s^2] + np.array[float[N]]: joint accelerations [rad/s^2] """ # check if cached if 'ddq' in self._state: @@ -1150,9 +1151,9 @@ class Robot(ControllableBody): Returns: if 1 joint: - float, np.array[6+1]: joint acceleration [rad/s^2] + float, np.array[float[6+1]]: joint acceleration [rad/s^2] if multiple joints: - np.array[N], np.array[6+N]: joint accelerations [rad/s^2] + np.array[float[N]], np.array[float[6+N]]: joint accelerations [rad/s^2] """ ddq = self.get_joint_accelerations(joint_ids=joint_ids) if self.has_fixed_base(): @@ -1166,14 +1167,14 @@ class Robot(ControllableBody): it will always return [0,0,0,0,0,0]. Args: - joint_ids (int, int[N], None): unique id of the joint, or list of joint ids. If None, get the joint + joint_ids (int, list[int[N]], None): unique id of the joint, or list of joint ids. If None, get the joint reaction forces of all (actuated) joints. Returns: if 1 joint: - np.array[6]: joint reaction force (fx,fy,fz,mx,my,mz) [N,Nm] + np.array[float[6]]: joint reaction force (fx,fy,fz,mx,my,mz) [N,Nm] if multiple joints: - np.array[N,6]: joint reaction forces [N, Nm] + np.array[float[N,6]]: joint reaction forces [N, Nm] """ if joint_ids is None: joint_ids = self.joints @@ -1184,14 +1185,14 @@ class Robot(ControllableBody): Get the applied torque on the given joint(s). Args: - joint_ids (int, int[N], None): id of the joint, or list of joint ids. If None, get the joint torques of - all (actuated) joints. + joint_ids (int, list[int[N]], None): id of the joint, or list of joint ids. If None, get the joint torques + of all (actuated) joints. Returns: if 1 joint: float: torque [Nm] if multiple joints: - np.array[N]: torques associated to the given joints [Nm] + np.array[float[N]]: torques associated to the given joints [Nm] """ if joint_ids is None: joint_ids = self.joints @@ -1209,7 +1210,7 @@ class Robot(ControllableBody): if 1 joint: float: joint power [W] if multiple joints: - np.array[N]: power at each joint [W] + np.array[float[N]]: power at each joint [W] """ if joint_ids is None: joint_ids = self.joints @@ -1222,11 +1223,11 @@ class Robot(ControllableBody): Args: joint_ids (int, int[N], None): joint id, or list of joint ids. If None, get all the actuated joints. - positions (float, np.array[N]): desired position, or list of desired positions [rad] - velocities (float, np.array[N], None): desired velocity, or list of desired velocities [rad/s] - kp (float, np.array[N], None): position gain(s) - kd (float, np.array[N], None): velocity gain(s) - forces (float, np.array[N], None, bool): maximum motor torques / forces. If True, it will apply the + positions (float, np.array[float[N]]): desired position, or list of desired positions [rad] + velocities (float, np.array[float[N]], None): desired velocity, or list of desired velocities [rad/s] + kp (float, np.array[float[N]], None): position gain(s) + kd (float, np.array[float[N]], None): velocity gain(s) + forces (float, np.array[float[N]], None, bool): maximum motor torques / forces. If True, it will apply the default maximum force values. """ if joint_ids is None: @@ -1240,9 +1241,9 @@ class Robot(ControllableBody): Set the velocity of the given joint(s) (using velocity control). Args: - velocities (float, np.array[N]): desired velocity, or list of desired velocities [rad/s] + velocities (float, np.array[float[N]]): desired velocity, or list of desired velocities [rad/s] joint_ids (int, int[N], None): joint id, or list of joint ids. If None, get all the actuated joints. - forces (float, np.array[N], None, bool): maximum motor torques / forces. If True, it will apply the + forces (float, np.array[float[N]], None, bool): maximum motor torques / forces. If True, it will apply the default maximum force values. max_velocity (float, bool, None): if True, it will make sure that the given velocity(ies) are below their authorized maximum value(s) (inferred from the URDF, or set previously by the user). If you already @@ -1259,8 +1260,8 @@ class Robot(ControllableBody): dynamic which given the joint accelerations compute the joint torques to be applied. Args: - accelerations (float, np.array[N]): desired joint acceleration, or list of desired joint accelerations - [rad/s^2] + accelerations (float, np.array[float[N]]): desired joint acceleration, or list of desired joint + accelerations [rad/s^2] joint_ids (int, int[N], None): joint id, or list of joint ids. If None, get all the actuated joints. max_acceleration (bool, float, None): if True, it will make sure that the given acceleration(s) are below their authorized maximum value(s). If you already did the check outside the method or if you don't want @@ -1302,8 +1303,8 @@ class Robot(ControllableBody): Set the torque to the given joint(s) (using force/torque control). Args: - torques (float, np.array[N], None): desired torque(s) to apply to the joint(s) [N]. If None, it will apply - a torque of 0 to the given joint(s). + torques (float, np.array[float[N]], None): desired torque(s) to apply to the joint(s) [N]. If None, it will + apply a torque of 0 to the given joint(s). joint_ids (int, int[N], None): joint id, or list of joint ids. If None, it will set the joint torques to all (actuated) joints. """ @@ -1339,14 +1340,16 @@ class Robot(ControllableBody): joint_ids (int, int[N]): joint id, or list of joint ids control_mode (int): sim.VELOCITY_CONTROL (=0), sim.TORQUE_CONTROL (=1), sim.POSITION_CONTROL (=2) kwargs: - positions (float, np.array[N]) (optional): target position of the joint (in position control) [rad] - velocities (float, np.array[N]) (optional): target velocity of the joint (in position/velocity + positions (float, np.array[float[N]]) (optional): target position of the joint (in position control) + [rad] + velocities (float, np.array[float[N]]) (optional): target velocity of the joint (in position/velocity control) [rad/s] - forces (float, np.array[N]) (optional): in position/velocity control, this is the maximum force used - to reach the target value. In torque control, this is the force/torque to be applied. - kp (float, np.array[N]) (optional): position gain :math:`Kp` - kd (float, np.array[N]) (optional): velocity gain :math:`Kd` - maxVelocity (float, np.array[N]) (optional): in position control, this limits the velocity to a maximum. + forces (float, np.array[float[N]]) (optional): in position/velocity control, this is the maximum force + used to reach the target value. In torque control, this is the force/torque to be applied. + kp (float, np.array[float[N]]) (optional): position gain :math:`Kp` + kd (float, np.array[float[N]]) (optional): velocity gain :math:`Kd` + maxVelocity (float, np.array[float[N]]) (optional): in position control, this limits the velocity to a + maximum. """ self.sim.set_joint_motor_control(self.id, joint_ids, control_mode, **kwargs) @@ -1367,8 +1370,8 @@ class Robot(ControllableBody): Reset the state of the robot. Args: - q (int, float, np.array[N], None): joint position(s). - dq (int, float, np.array[N], None): joint velocity(ies). + q (int, float, np.array[float[N]], None): joint position(s). + dq (int, float, np.array[float[N]], None): joint velocity(ies). joint_ids (int, int[N], None): joint id, or list of joint ids. If None, it will disable the motors of all actuated joints. @@ -1465,8 +1468,8 @@ class Robot(ControllableBody): list: str: name of each joint configuration. else: - np.array[M]: joint ids to move. - np.array[M]: joint positions. + np.array[float[M]]: joint ids to move. + np.array[float[M]]: joint positions. """ pass @@ -1482,7 +1485,7 @@ class Robot(ControllableBody): while the q index goes from 0 to the number of links associated with actuated joints. Args: - link (str, int, list of str/int, None): if str, it will get the link id associated to the given name. + link (str, int, list[str,int], None): if str, it will get the link id associated to the given name. If int, it will get the link id associated to the given q index. If it is a list of str and/or int, it will get the corresponding link ids. If None, it will return all the link ids (associated to actuated joints). @@ -1491,7 +1494,7 @@ class Robot(ControllableBody): if 1 link: int: link id if multiple links: - int[N]: link ids + list[int]: link ids """ if link is None: return self.joints @@ -1516,14 +1519,14 @@ class Robot(ControllableBody): Return the parent link of the given link(s) Args: - link_ids (int, int[N], None): link id, or list of desired link ids. If None, get the state of all links + link_ids (int, list[int], None): link id, or list of desired link ids. If None, get the state of all links associated to actuated joints. Returns: if 1 link: int: link id if multiple links: - int[N]: link ids + list[int]: link ids """ if isinstance(link_ids, int): return self.sim.get_joint_info(self.id, link_ids)[-1] @@ -1536,12 +1539,13 @@ class Robot(ControllableBody): Return the link ids that constitute the chain(s) that go(es) from `fromLinkId` to `toLinkId`. Args: - to_link_id (int, int[M]): link id(s) that end(s) the chain(s). - from_link_id (int, int[M], None): link id(s) that start(s) the chain(s). `fromLinkId` has to be a parent or - ancestor of the `toLinkId`. If None, it will return the chain going from the base to the `toLinkId`. + to_link_id (int, list[int[M]]): link id(s) that end(s) the chain(s). + from_link_id (int, list[int[M]], None): link id(s) that start(s) the chain(s). `from_link_id` has to be a + parent or ancestor of the `to_link_id`. If None, it will return the chain going from the base to the + `to_link_id`. Returns: - int[N], [int[N]]: chain(s) containing the link ids. + list[int], list[list[int]]: chain(s) containing the link ids. """ if from_link_id is None: if isinstance(to_link_id, collections.Iterable): @@ -1578,15 +1582,15 @@ class Robot(ControllableBody): Returns: if 1 link: - [0] np.array[3]: Cartesian position of center of mass - [1] np.array[4]: Cartesian orientation of center of mass - [2] np.array[3]: local position offset of inertial frame (CoM) expressed in the URDF link frame - [3] np.array[4]: local orientation (quat. [x,y,z,w]) offset of the inertial frame expressed in URDF - link frame - [4] np.array[3]: world position of the URDF link frame - [5] np.array[4]: world orientation of the URDF link frame - [6] np.array[3]: Cartesian world linear velocity - [7] np.array[3]: Cartesian world angular velocity + [0] np.array[float[3]]: Cartesian position of center of mass + [1] np.array[float[4]]: Cartesian orientation of center of mass + [2] np.array[float[3]]: local position offset of inertial frame (CoM) expressed in the URDF link frame + [3] np.array[float[4]]: local orientation (quat. [x,y,z,w]) offset of the inertial frame expressed in + URDF link frame + [4] np.array[float[3]]: world position of the URDF link frame + [5] np.array[float[4]]: world orientation of the URDF link frame + [6] np.array[float[3]]: Cartesian world linear velocity + [7] np.array[float[3]]: Cartesian world angular velocity if multiple links: list of above """ if isinstance(link_ids, int): # one link @@ -1608,7 +1612,7 @@ class Robot(ControllableBody): Returns: if 1 link: - np.array[3]: local position offset of inertial frame (CoM) expressed in the URDF link frame + np.array[float[3]]: local position offset of inertial frame (CoM) expressed in the URDF link frame if multiple links: list of above """ if isinstance(link_ids, int): @@ -1626,8 +1630,8 @@ class Robot(ControllableBody): Returns: if 1 link: - np.array[4]: local orientation (quaternion [x,y,z,w]) offset of inertial frame (CoM) expressed in the - URDF link frame + np.array[float[4]]: local orientation (quaternion [x,y,z,w]) offset of inertial frame (CoM) expressed + in the URDF link frame if multiple links: list of above """ if isinstance(link_ids, int): @@ -1639,14 +1643,14 @@ class Robot(ControllableBody): Return the name of the given link(s). Args: - link_ids (int, int[N], None): link id, or list of desired link ids. If None, get the name of all links - associated to actuated joints. + link_ids (int, list[int[N]], None): link id, or list of desired link ids. If None, get the name of all + links associated to actuated joints. Returns: if 1 link: str: link name if multiple links: - str[N]: link names + list[str[N]]: link names """ if link_ids is None: link_ids = self.joints @@ -1664,7 +1668,7 @@ class Robot(ControllableBody): if 1 link: float: mass of the given link else: - np.array[N]: mass of each link + np.array[float[N]]: mass of each link """ if isinstance(link_ids, int): return self.sim.get_dynamics_info(self.id, link_ids)[0] @@ -1683,11 +1687,11 @@ class Robot(ControllableBody): Returns: if 1 link: - np.array[3]: the link frame position in the world space - np.array[4]: Cartesian orientation of the link frame [x,y,z,w] + np.array[float[3]]: the link frame position in the world space + np.array[float[4]]: Cartesian orientation of the link frame [x,y,z,w] if multiple links: - np.array[N*3], np.array[N,3]: link frame position of each link in world space - np.array[N*4], np.array[N,4]: orientation of each link frame [x,y,z,w] + np.array[float[N*3]], np.array[float[N,3]]: link frame position of each link in world space + np.array[float[N*4]], np.array[float[N,4]]: orientation of each link frame [x,y,z,w] """ positions, orientations = self.sim.get_link_frames(body_id=self.id, link_ids=link_ids) @@ -1706,9 +1710,9 @@ class Robot(ControllableBody): Returns: if 1 link: - np.array[3]: the link frame position in the world space + np.array[float[3]]: the link frame position in the world space if multiple links: - np.array[N*3], np.array[N,3]: link frame position of each link in world space + np.array[float[N*3]], np.array[float[N,3]]: link frame position of each link in world space """ return self.get_link_frames(link_ids=link_ids, flatten=flatten)[0] @@ -1723,9 +1727,9 @@ class Robot(ControllableBody): Returns: if 1 link: - np.array[4]: Cartesian orientation of the link frame [x,y,z,w] + np.array[float[4]]: Cartesian orientation of the link frame [x,y,z,w] if multiple links: - np.array[N*4], np.array[N,4]: orientation of each link frame [x,y,z,w] + np.array[float[N*4]], np.array[float[N,4]]: orientation of each link frame [x,y,z,w] """ return self.get_link_frames(link_ids=link_ids, flatten=flatten)[1] @@ -1740,9 +1744,9 @@ class Robot(ControllableBody): Returns: if 1 link: - np.array[3]: the link CoM position in the world space + np.array[float[3]]: the link CoM position in the world space if multiple links: - np.array[N*3], np.array[N,3]: CoM position of each link in world space + np.array[float[N*3]], np.array[float[N,3]]: CoM position of each link in world space """ # check if cached if 'link_pos' in self._state: @@ -1780,9 +1784,9 @@ class Robot(ControllableBody): Returns: if 1 link: - np.array[3]: the link CoM position + np.array[float[3]]: the link CoM position if multiple links: - np.array[N*3], np.array[N,3]: CoM position of each link + np.array[float[N*3]], np.array[float[N,3]]: CoM position of each link """ p1 = self.get_link_world_positions(link_ids, flatten=False) p0 = self.get_base_position() if wrt_link_id is None or wrt_link_id == -1 \ @@ -1807,9 +1811,9 @@ class Robot(ControllableBody): Returns: if 1 link: - np.array[4]: Cartesian orientation of the link CoM [x,y,z,w] + np.array[float[4]]: Cartesian orientation of the link CoM [x,y,z,w] if multiple links: - np.array[N*4], np.array[N,4]: CoM orientation of each link [x,y,z,w] + np.array[float[N*4]], np.array[float[N,4]]: CoM orientation of each link [x,y,z,w] """ if isinstance(link_ids, int): return self.sim.get_link_state(self.id, link_ids)[1] @@ -1832,9 +1836,9 @@ class Robot(ControllableBody): Returns: if 1 link: - np.array[4]: Cartesian orientation of the link CoM [x,y,z,w] + np.array[float[4]]: Cartesian orientation of the link CoM [x,y,z,w] if multiple links: - np.array[N*4], np.array[N,4]: CoM orientation of each link [x,y,z,w] + np.array[float[N*4]], np.array[float[N,4]]: CoM orientation of each link [x,y,z,w] """ q1 = self.get_link_world_orientations(link_ids) if wrt_link_id is None or wrt_link_id == -1: @@ -1865,9 +1869,9 @@ class Robot(ControllableBody): Returns: if 1 link: - np.array[7]: Cartesian pose of the link CoM + np.array[float[7]]: Cartesian pose of the link CoM if multiple links: - np.array[N*7], np.array[N,7]: CoM pose of each link + np.array[float[N*7]], np.array[float[N,7]]: CoM pose of each link """ # get positions and orientations positions = self.get_link_world_positions(link_ids=link_ids, flatten=False) # (N,3) @@ -1892,9 +1896,9 @@ class Robot(ControllableBody): Returns: if 1 link: - np.array[3]: linear velocity of the link in the Cartesian world space + np.array[float[3]]: linear velocity of the link in the Cartesian world space if multiple links: - np.array[N*3], np.array[N,3]: linear velocity of each link + np.array[float[N*3]], np.array[float[N,3]]: linear velocity of each link """ if isinstance(link_ids, int): return np.asarray(self.sim.get_link_state(self.id, link_ids, compute_velocity=True)[6]) @@ -1916,9 +1920,9 @@ class Robot(ControllableBody): Returns: if 1 link: - np.array[3]: angular velocity of the link in the Cartesian world space + np.array[float[3]]: angular velocity of the link in the Cartesian world space if multiple links: - np.array[N*3], np.array[N,3]: angular velocity of each link + np.array[float[N*3]], np.array[float[N,3]]: angular velocity of each link """ if isinstance(link_ids, int): return np.asarray(self.sim.get_link_state(self.id, link_ids, compute_velocity=True)[7]) @@ -1941,9 +1945,9 @@ class Robot(ControllableBody): Returns: if 1 link: - np.array[6]: linear and angular velocity of the link in the Cartesian world space + np.array[float[6]]: linear and angular velocity of the link in the Cartesian world space if multiple links: - np.array[N*6], np.array[N,6]: linear and angular velocity of each link + np.array[float[N*6]], np.array[float[N,6]]: linear and angular velocity of each link """ # check if cached if 'link_vel' in self._state: @@ -1983,9 +1987,9 @@ class Robot(ControllableBody): Returns: if 1 link: - np.array[6]: angular and linear velocity of the link in the Cartesian world space + np.array[float[6]]: angular and linear velocity of the link in the Cartesian world space if multiple links: - np.array[N*6], np.array[N,6]: angular and linear velocity of each link + np.array[float[N*6]], np.array[float[N,6]]: angular and linear velocity of each link """ velocities = self.get_link_world_velocities(link_ids=link_ids, flatten=False) @@ -2015,9 +2019,9 @@ class Robot(ControllableBody): Returns: if 1 link: - np.array[3]: the linear velocity of the given link wrt to the other link + np.array[float[3]]: the linear velocity of the given link wrt to the other link if multiple links: - np.array[N*3], np.array[N,3]: linear velocity of each link wrt to the other link(s) + np.array[float[N*3]], np.array[float[N,3]]: linear velocity of each link wrt to the other link(s) """ v1 = self.get_link_world_linear_velocities(link_ids, flatten=False) v0 = self.get_base_linear_velocity() if wrt_link_id is None or wrt_link_id == -1 \ @@ -2040,9 +2044,9 @@ class Robot(ControllableBody): Returns: if 1 link: - np.array[3]: the angular velocity of the given link wrt to the other link + np.array[float[3]]: the angular velocity of the given link wrt to the other link if multiple links: - np.array[N*3], np.array[N,3]: angular velocity of each link wrt to the other link(s) + np.array[float[N*3]], np.array[float[N,3]]: angular velocity of each link wrt to the other link(s) """ w1 = self.get_link_world_angular_velocities(link_ids, flatten=False) w0 = self.get_base_angular_velocity() if wrt_link_id is None or wrt_link_id == -1 \ @@ -2065,9 +2069,10 @@ class Robot(ControllableBody): Returns: if 1 link: - np.array[6]: the linear and angular velocity of the given link wrt to the other link + np.array[float[6]]: the linear and angular velocity of the given link wrt to the other link if multiple links: - np.array[N*6], np.array[N,6]: linear and angular velocity of each link wrt to the other link(s) + np.array[float[N*6]], np.array[float[N,6]]: linear and angular velocity of each link wrt to the other + link(s) """ v1 = self.get_link_world_velocities(link_ids, flatten=False) v0 = self.get_base_velocity() if wrt_link_id is None or wrt_link_id == -1 \ @@ -2140,9 +2145,9 @@ class Robot(ControllableBody): Returns: if 1 link: - np.array[6]: linear and angular acceleration of the link in the Cartesian world space + np.array[float[6]]: linear and angular acceleration of the link in the Cartesian world space if multiple links: - np.array[N*6], np.array[N,6]: linear and angular acceleration of each link + np.array[float[N*6]], np.array[float[N,6]]: linear and angular acceleration of each link References: - [1] "Rigid Body Dynamics Algorithms" (chap 2.11), Featherstone, 2008 @@ -2219,9 +2224,9 @@ class Robot(ControllableBody): Returns: if 1 link: - np.array[3]: linear acceleration of the link in the Cartesian world space + np.array[float[3]]: linear acceleration of the link in the Cartesian world space if multiple links: - np.array[N*3], np.array[N,3]: linear acceleration of each link + np.array[float[N*3]], np.array[float[N,3]]: linear acceleration of each link """ accelerations = self.get_link_world_accelerations(link_ids=link_ids, flatten=False) if isinstance(link_ids, int): @@ -2244,9 +2249,9 @@ class Robot(ControllableBody): Returns: if 1 link: - np.array[3]: angular acceleration of the link in the Cartesian world space + np.array[float[3]]: angular acceleration of the link in the Cartesian world space if multiple links: - np.array[N*3], np.array[N,3]: angular acceleration of each link + np.array[float[N*3]], np.array[float[N,3]]: angular acceleration of each link """ accelerations = self.get_link_world_accelerations(link_ids=link_ids, flatten=False) if isinstance(link_ids, int): @@ -2306,9 +2311,9 @@ class Robot(ControllableBody): Returns: if 1 link: - np.array[6]: angular and linear acceleration of the link in the Cartesian world space + np.array[float[6]]: angular and linear acceleration of the link in the Cartesian world space if multiple links: - np.array[N*6], np.array[N,6]: angular and linear acceleration of each link + np.array[float[N*6]], np.array[float[N,6]]: angular and linear acceleration of each link """ accelerations = self.get_link_world_accelerations(link_ids=link_ids, flatten=False) @@ -2342,9 +2347,9 @@ class Robot(ControllableBody): int: unique id of body B int: link index of body A (-1 for base, this should be the same as the given link) int: link index of body B (-1 for base) - np.array[3]: contact position on A (in Cartesian world coordinates) - np.array[3]: contact position on B (in Cartesian world coordinates) - np.array[3]: contact normal on B pointing towards A + np.array[float[3]]: contact position on A (in Cartesian world coordinates) + np.array[float[3]]: contact position on B (in Cartesian world coordinates) + np.array[float[3]]: contact normal on B pointing towards A float: contact distance (positive for separation and negative for penetration) float: normal force applied during the last simulation step if multiple links: list of above @@ -2363,9 +2368,9 @@ class Robot(ControllableBody): Returns: if 1 link: - np.array[3]: local inertia (diagonal vector) of the given link + np.array[float[3]]: local inertia (diagonal vector) of the given link else: - np.array[N]: mass of each link + np.array[float[N]]: mass of each link """ if isinstance(link_ids, int): return self.sim.get_dynamics_info(body_id=self.id, link_id=link_ids)[2] @@ -2382,9 +2387,9 @@ class Robot(ControllableBody): Args: link_ids (int, int[N]): link id, or list of desired link ids. - positions (np.array[3], [np.array[3]], np.array[N,3]): desired link position(s). - orientations (np.array[4], list of np.array[4], np.array[N,4]): desired link orientation(s) (expressed as - quaternions [x,y,z,w]) + positions (np.array[float[3]], list[np.array[float[3]]], np.array[float[N,3]]): desired link position(s). + orientations (np.array[float[4]], list[np.array[float[4]]], np.array[float[N,4]]): desired link + orientation(s) (expressed as quaternions [x,y,z,w]) """ # TODO: think when setting the position of multiple links where some joints are shared (need to use the # null-space) @@ -2483,12 +2488,12 @@ class Robot(ControllableBody): Return the Homogeneous transform matrix given the position vector and the orientation. Args: - position (np.array[3]): position vector - orientation (np.array[4], np.array[3,3], np.array[3]): orientation (expressed as a quaternion [x,y,z,w], - 3x3 rotation matrix, or roll-pitch-yaw angles). + position (np.array[float[3]]): position vector + orientation (np.array[float[4]], np.array[float[3,3]], np.array[float[3]]): orientation (expressed as a + quaternion [x,y,z,w], 3x3 rotation matrix, or roll-pitch-yaw angles). Returns: - np.array[4,4]: homogeneous matrix + np.array[float[4,4]],4]: homogeneous matrix """ return get_homogeneous_transform(position, orientation) @@ -2510,14 +2515,14 @@ class Robot(ControllableBody): Args: link_id (int): link id. - q (np.array[N], None): joint positions of size N, where N is the number of DoFs. If None, it will compute q - based on the current joint positions. - local_position (None, np.array[3]): the point on the specified link to compute the Jacobian (in link local - coordinates around its center of mass). If None, it will use the CoM position (in the link frame). + q (np.array[float[N]], None): joint positions of size N, where N is the number of DoFs. If None, it will + compute q based on the current joint positions. + local_position (None, np.array[float[3]]): the point on the specified link to compute the Jacobian (in link + local coordinates around its center of mass). If None, it will use the CoM position (in the link frame). Returns: - np.array[6,N], np.array[6,(6+N)]: full geometric (linear and angular) Jacobian matrix. The number of - columns depends if the base is fixed or floating. + np.array[float[6,N]], np.array[float[6,6+N]]: full geometric (linear and angular) Jacobian matrix. The + number of columns depends if the base is fixed or floating. """ if q is None: q = self.get_joint_positions() @@ -2548,14 +2553,14 @@ class Robot(ControllableBody): Args: link_id (int): link id - q (np.array[N]): joint positions of size N, where N is the number of DoFs. If None, it will compute q based - on the current joint positions. + q (np.array[float[N]]): joint positions of size N, where N is the number of DoFs. If None, it will compute + q based on the current joint positions. local_position: the point on the specified link to compute the Jacobian (in link local coordinates around its center of mass). If None, it will use the CoM position (in the link frame). Returns: - np.array[3,N], np.array[3,(6+N)]: full linear geometric Jacobian matrix. The number of columns depends if - the base is fixed or floating. + np.array[float[3,N]], np.array[float[3,6+N]]: full linear geometric Jacobian matrix. The number of + columns depends if the base is fixed or floating. """ return self.get_jacobian(link_id, q, local_position)[:3] @@ -2572,14 +2577,14 @@ class Robot(ControllableBody): Args: link_id (int): link id - q (np.array[N]): joint positions of size N, where N is the number of DoFs. If None, it will compute q based - on the current joint positions. + q (np.array[float[N]]): joint positions of size N, where N is the number of DoFs. If None, it will compute + q based on the current joint positions. local_position: the point on the specified link to compute the Jacobian (in link local coordinates around its center of mass). If None, it will use the CoM position (in the link frame). Returns: - np.array[3,N], np.array[3,(6+N)]: full angular geometric Jacobian matrix. The number of columns depends if - the base is fixed or floating. + np.array[float[3,N]], np.array[float[3,6+N]]: full angular geometric Jacobian matrix. The number of + columns depends if the base is fixed or floating. """ return self.get_jacobian(link_id, q, local_position)[3:] @@ -2592,14 +2597,14 @@ class Robot(ControllableBody): Args: link_id (int): link id. - q (np.array[N], None): joint positions of size N, where N is the number of DoFs. If None, it will compute q - based on the current joint positions. - local_position (None, np.array[3]): the point on the specified link to compute the Jacobian (in link local - coordinates around its center of mass). If None, it will use the CoM position (in the link frame). + q (np.array[float[N]], None): joint positions of size N, where N is the number of DoFs. If None, it will + compute q based on the current joint positions. + local_position (None, np.array[float[3]]): the point on the specified link to compute the Jacobian (in link + local coordinates around its center of mass). If None, it will use the CoM position (in the link frame). Returns: - np.array[6,N], np.array[6,(6+N)]: spatial Jacobian matrix. The number of columns depends if the base is - fixed or floating. + np.array[float[6,N]], np.array[float[6,6+N]]: spatial Jacobian matrix. The number of columns depends if + the base is fixed or floating. """ jacobian = self.get_jacobian(link_id=link_id, q=q, local_position=local_position) return np.vstack((jacobian[3:], jacobian[:3])) @@ -2612,10 +2617,10 @@ class Robot(ControllableBody): Warnings: :math:`T` is singular when the pitch angle :math:`\theta_p = \pm \frac{\pi}{2}` Args: - rpy_angle (np.array[3]): RPY Euler angles [rad] + rpy_angle (np.array[float[3]]): RPY Euler angles [rad] Returns: - np.array[3,3]: Jacobian matrix that maps RPY angle rates to angular velocities. + np.array[float[3,3]]: Jacobian matrix that maps RPY angle rates to angular velocities. """ r, p, y = rpy_angle T = np.array([[1., 0., np.sin(p)], @@ -2631,10 +2636,10 @@ class Robot(ControllableBody): Warnings: :math:`T` is singular when the angle associated with `Y` is :math:`0` or :math:`\pi`. Args: - zyz_angle (np.array[3]): ZYZ Euler angles [rad] + zyz_angle (np.array[float[3]]): ZYZ Euler angles [rad] Returns: - np.array[3,3]: Jacobian matrix that maps ZYZ angle rates to angular velocities. + np.array[float[3,3]]: Jacobian matrix that maps ZYZ angle rates to angular velocities. """ z, y = zyz_angle[:2] T = np.array([[0., -np.sin(z), np.cos(z) * np.sin(y)], @@ -2669,12 +2674,12 @@ class Robot(ControllableBody): Euler angles then T is singular when the pitch angle :math:`\theta_p = \pm \frac{\pi}{2}. Args: - jacobian (np.array[6,N], np.array[6,6+N]): full geometric Jacobian. - rpy_angle (np.array[3]): RPY Euler angles + jacobian (np.array[float[6,N]], np.array[float[6,6+N]]): full geometric Jacobian. + rpy_angle (np.array[float[3]]): RPY Euler angles Returns: - np.array[6,N], np.foat[6,(6+N)]: the full analytical Jacobian. The number of columns depends if the base - is fixed or floating. + np.array[float[6,N]], np.array[float[6,6+N]]: the full analytical Jacobian. The number of columns + depends if the base is fixed or floating. """ T = self.get_jacobian_derivative_rpy_to_angular_velocity(rpy_angle) Tinv = np.linalg.inv(T) @@ -2693,10 +2698,10 @@ class Robot(ControllableBody): .. math:: \frac{d}{dq} J(q) Args: - jacobian (np.array[6,N], np.array[6,6+N]): jacobian matrix J. + jacobian (np.array[float[6,N]], np.array[float[6,6+N]]): jacobian matrix J. Returns: - np.array[6,N,N]: derivative of the Jacobian wrt joint values (dJ/dq) + np.array[float[6,N,N]]: derivative of the Jacobian wrt joint values (dJ/dq) References: - [1] "Symbolic differentiation of the velocity mapping for a serial kinematic chain", Bruyninck et al., @@ -2740,13 +2745,13 @@ class Robot(ControllableBody): .. math:: \dot{J}(q) \sim \frac{ J(q(t)) - J(q(t-dt)) }{dt} Args: - prev_jacobian (np.array[6,N], np.array[6,(6+N)]): previous Jacobian. - curr_jacobian (np.array[6,N], np.array[6,(6+N)]): current Jacobian. + prev_jacobian (np.array[float[6,N]], np.array[float[6,6+N]]): previous Jacobian. + curr_jacobian (np.array[float[6,N]], np.array[float[6,6+N]]): current Jacobian. dt (float): time difference (should be bigger than 0). Returns: - np.array[6,N], np.array[6,(6+N)]: time derivative of the Jacobian matrix. The number of columns depends - if the base is fixed or floating. + np.array[float[6,N]], np.array[float[6,6+N]]: time derivative of the Jacobian matrix. The number of columns + depends if the base is fixed or floating. """ return (curr_jacobian - prev_jacobian) / dt @@ -2761,12 +2766,14 @@ class Robot(ControllableBody): Args: link_id (int): link id. - local_position (None, np.array[3]): the point on the specified link to compute the Jacobian (in link local - coordinates around its center of mass). If None, it will use the CoM position (in the link frame). + local_position (np.array[float[3]], None): the point on the specified link to compute the Jacobian (in + link local coordinates around its center of mass). If None, it will use the CoM position (in the link + frame). Returns: - np.array[6,N], np.array[6,(6+N)]: time derivative of the Jacobian matrix (which is the concatenation of - the linear and angular parts). The number of columns depends if the base is fixed or floating. + np.array[float[6,N]], np.array[float[6,6+N]]: time derivative of the Jacobian matrix (which is the + concatenation of the linear and angular parts). The number of columns depends if the base is fixed or + floating. """ # convert type if necessary local_position = None if local_position is None else tuple(local_position) @@ -2824,12 +2831,13 @@ class Robot(ControllableBody): Args: link_id (int): link id. - local_position (None, np.array[3]): the point on the specified link to compute the Jacobian (in link local - coordinates around its center of mass). If None, it will use the CoM position (in the link frame). + local_position (None, np.array[float[3]]): the point on the specified link to compute the Jacobian (in + link local coordinates around its center of mass). If None, it will use the CoM position (in the link + frame). Returns: - np.array[6,N], np.array[6,(6+N)]: time derivative of the spatial Jacobian matrix. The number of columns - depends if the base is fixed or floating. + np.array[float[6,N]], np.array[float[6,6+N]]: time derivative of the spatial Jacobian matrix. The number + of columns depends if the base is fixed or floating. """ jacobian = self.get_jacobian_time_derivative(link_id=link_id, local_position=local_position) return np.vstack((jacobian[3:], jacobian[:3])) @@ -2841,11 +2849,11 @@ class Robot(ControllableBody): method is [1]. Args: - q (np.array[N]): joint positions of size N, where N is the number of DoFs. If None, it will compute q - based on the current joint positions. + q (np.array[float[N]]): joint positions of size N, where N is the number of DoFs. If None, it will compute + q based on the current joint positions. Returns: - np.array[6,N]: CoM Jacobian + np.array[float[6,N]]: CoM Jacobian References: - [1] "Whole-body cooperative balancing of humanoid robot using COG Jacobian", Sugihara et al., IROS, 2002 @@ -2908,11 +2916,11 @@ class Robot(ControllableBody): Note that :math:`T` is singular when the pitch angle :math:`\theta_p = \pm \frac{\pi}{2}`. Args: - rpy_angle (np.array[3]): RPY Euler angles [rad] - dRPY (np.array[3]): time derivative of RPY Euler angles [rad/s] + rpy_angle (np.array[float[3]]): RPY Euler angles [rad] + dRPY (np.array[float[3]]): time derivative of RPY Euler angles [rad/s] Returns: - np.array[3]: angular velocities [rad/s] + np.array[float[3]]: angular velocities [rad/s] """ T = self.get_jacobian_derivative_rpy_to_angular_velocity(rpy_angle) return T.dot(dRPY) @@ -2927,11 +2935,11 @@ class Robot(ControllableBody): corresponding angular velocities :math:`\omega` are not defined. Args: - rpy_angle (np.array[3]): RPY Euler angles [rad] - angular_velocity (np.array[3]): angular velocities [rad/s] + rpy_angle (np.array[float[3]]): RPY Euler angles [rad] + angular_velocity (np.array[float[3]]): angular velocities [rad/s] Returns: - np.array[3]: time derivative of RPY Euler angles [rad/s] + np.array[float[3]]: time derivative of RPY Euler angles [rad/s] Raises: LinAlgError: if singular configuration. @@ -2946,10 +2954,10 @@ class Robot(ControllableBody): Given the Jacobian, it returns :math:`JJ^T`. This relation is used in many places in robotics. Args: - jacobian (np.array[D,N]): Jacobian matrix + jacobian (np.array[float[D,N]]): Jacobian matrix Returns: - np.array[D,D]: :math:`JJ^T` + np.array[float[D,D]]: :math:`JJ^T` """ return jacobian.dot(jacobian.T) @@ -2964,11 +2972,11 @@ class Robot(ControllableBody): :math:`\dot{q} = \hat{J} v`. Args: - jacobian (np.array[D,N]): Jacobian matrix + jacobian (np.array[float[D,N]]): Jacobian matrix damping_factor (float): damping factor Returns: - np.array[N,D]: DLS inverse matrix + np.array[float[N,D]]: DLS inverse matrix """ J, k = jacobian, damping_factor return J.T.dot(np.linalg.inv(J.dot(J.T) + k**2 * np.identity(J.shape[0]))) @@ -2979,10 +2987,10 @@ class Robot(ControllableBody): Return the right pseudo-inverse of the jacobian, i.e. :math:`J^\dagger = J^T(JJ^T)^{-1}`. Args: - jacobian (np.array[D,N]): Jacobian matrix + jacobian (np.array[float[D,N]]): Jacobian matrix Returns: - np.array[N,N]: right pseudo-inverse of the Jacobian + np.array[float[N,N]]: right pseudo-inverse of the Jacobian """ return np.linalg.pinv(jacobian) @@ -2994,10 +3002,10 @@ class Robot(ControllableBody): :math:`\dot{q} = J^\dagger v + P \dot{q}_0` with :math:`\dot{q}_0` representing arbitrary joint velocities. Args: - jacobian (np.array[D,N]): Jacobian matrix + jacobian (np.array[float[D,N]]): Jacobian matrix Returns: - np.array[N,N]: null space projector matrix + np.array[float[N,N]]: null space projector matrix """ J = jacobian I = np.identity(J.shape[1]) @@ -3010,7 +3018,7 @@ class Robot(ControllableBody): configurations (see [1]). Args: - jacobian (np.array[D,N]): Jacobian matrix + jacobian (np.array[float[D,N]]): Jacobian matrix Returns: float: manipulability measure :math:`w(q)` @@ -3025,10 +3033,10 @@ class Robot(ControllableBody): Compute the velocity manipulability ellipsoid (matrix) as `M = J(q)J(q)^T`. Args: - jacobian (np.array[D,N]): Jacobian matrix + jacobian (np.array[float[D,N]]): Jacobian matrix Returns: - np.array[D,D]: velocity manipulability + np.array[float[D,D]]: velocity manipulability References: - [1] "Robotics: Modelling, Planning and Control" (section 3.9), Siciliano et al., 2010 @@ -3040,10 +3048,10 @@ class Robot(ControllableBody): Compute the force manipulability ellipsoid (matrix) as `M = (J(q)J(q)^T)^-1`. Args: - jacobian (np.array[D,N]): Jacobian matrix + jacobian (np.array[float[D,N]]): Jacobian matrix Returns: - np.array[D,D]: force manipulability + np.array[float[D,D]]: force manipulability References: - [1] "Robotics: Modelling, Planning and Control" (section 3.9), Siciliano et al., 2010 @@ -3061,7 +3069,7 @@ class Robot(ControllableBody): - around them, small velocities in the task/operational space may cause large velocities in the joint space Args: - jacobian (np.array[D,N]): Jacobian matrix + jacobian (np.array[float[D,N]]): Jacobian matrix Returns: bool: True if in a singular configuration @@ -3084,11 +3092,11 @@ class Robot(ControllableBody): where :math:`J^\dagger` is the right pseudo-inverse of J, i.e. :math:`J^\dagger = J^T(JJ^T)^{-1}`. Args: - jacobian (np.array[3,N], np.array[6,N]): Jacobian matrix - velocity (np.array[3], np.array[6]): linear and/or angular velocities + jacobian (np.array[float[3,N]], np.array[float[6,N]]): Jacobian matrix + velocity (np.array[float[3]], np.array[float[6]]): linear and/or angular velocities Returns: - np.array[N]: joint velocities + np.array[float[N]]: joint velocities """ Jpinv = self.get_pinv_jacobian(jacobian) return Jpinv.dot(velocity) @@ -3102,11 +3110,11 @@ class Robot(ControllableBody): .. math:: v = J(q) \dot{q} Args: - jacobian (np.array[D,N], np.array[D,N]): Jacobian matrix - dq (np.array[N]): joint velocities + jacobian (np.array[float[D,N]], np.array[float[D,N]]): Jacobian matrix + dq (np.array[float[N]]): joint velocities Returns: - np.array[6]: Cartesian linear and angular velocities + np.array[float[6]]: Cartesian linear and angular velocities """ return jacobian.dot(dq) @@ -3119,28 +3127,28 @@ class Robot(ControllableBody): Args: link_id (int): end effector link index. - position (np.array[3]): target position of the end effector (its link coordinate, not center of mass + position (np.array[float[3]]): target position of the end effector (its link coordinate, not center of mass coordinate!). By default this is in Cartesian world space, unless you provide `q_curr` joint angles. - orientation (np.array[4]): target orientation in Cartesian world space, quaternion [x,y,w,z]. If not + orientation (np.array[float[4]]): target orientation in Cartesian world space, quaternion [x,y,w,z]. If not specified, pure position IK will be used. - lower_limits (np.array[N], list of N floats): lower joint limits. Optional null-space IK. - upper_limits (np.array[N], list of N floats): upper joint limits. Optional null-space IK. - joint_ranges (np.array[N], list of N floats): range of value of each joint. - rest_poses (np.array[N], list of N floats): joint rest poses. Favor an IK solution closer to a given rest - pose. - joint_dampings (np.array[N], list of N floats): joint damping factors. Allow to tune the IK solution using - joint damping factors. + lower_limits (np.array[float[N]], list of N floats): lower joint limits. Optional null-space IK. + upper_limits (np.array[float[N]], list of N floats): upper joint limits. Optional null-space IK. + joint_ranges (np.array[float[N]], list of N floats): range of value of each joint. + rest_poses (np.array[float[N]], list of N floats): joint rest poses. Favor an IK solution closer to a given + rest pose. + joint_dampings (np.array[float[N]], list of N floats): joint damping factors. Allow to tune the IK solution + using joint damping factors. solver (int): p.IK_DLS (=0) or p.IK_SDLS (=1), Damped Least Squares or Selective Damped Least Squares, as described in the paper by Samuel Buss "Selectively Damped Least Squares for Inverse Kinematics". - q_curr (np.array[N]): list of joint positions. By default PyBullet uses the joint positions of the body. - If provided, the target_position and targetOrientation is in local space! + q_curr (np.array[float[N]]): list of joint positions. By default PyBullet uses the joint positions of the + body. If provided, the target_position and targetOrientation is in local space! max_iters (int): maximum number of iterations. Refine the IK solution until the distance between target and actual end effector position is below this threshold, or the `max_iters` is reached. threshold (float): residual threshold. Refine the IK solution until the distance between target and actual end effector position is below this threshold, or the `max_iters` is reached. Returns: - np.array[M]: joint positions (for each actuated joint). + np.array[float[M]]: joint positions (for each actuated joint). """ # calculate joint positions solving IK and return them return self.sim.calculate_inverse_kinematics(self.id, link_id, position=position, orientation=orientation, @@ -3156,12 +3164,12 @@ class Robot(ControllableBody): all the actuated joints [1]. Args: - jacobian (np.array[D,N]): jacobian matrix - target_velocity_manipulability (np.array[D,D]): target velocity manipulability + jacobian (np.array[float[D,N]]): jacobian matrix + target_velocity_manipulability (np.array[float[D,D]]): target velocity manipulability Km (float[,]): Proportional gain for manipulability error Returns: - np.array[N]: joint velocities + np.array[float[N]]: joint velocities float: minimum of eigenvalues of the velocity manip. Jacobian float: Distance between desired and current manip. ellipsoids @@ -3193,11 +3201,11 @@ class Robot(ControllableBody): Compute the velocity manipulability Jacobian [1]. Args: - jacobian (np.array[D,N]): jacobian matrix + jacobian (np.array[float[D,N]]): jacobian matrix num_task_vars (int): number of task variables (usually 3 or 6) Returns: - np.array[(num_task_vars * num_task_vars + num_task_vars) / 2, N]: manipulability jacobian matrix + np.array[float[(num_task_vars * num_task_vars + num_task_vars) / 2, N]]: manipulability jacobian matrix References: - [1] "Geometry-aware Tracking of Manipulability Ellipsoids", Jaquier et al., R:SS, 2018 @@ -3279,12 +3287,12 @@ class Robot(ControllableBody): of motion in task/operational space (instead of joint space), check the references [1-4]. Args: - q (np.array[M]): joint positions - dq (np.array[M]): joint velocities - des_ddq (np.array[M]): desired joint accelerations + q (np.array[float[M]]): joint positions + dq (np.array[float[M]]): joint velocities + des_ddq (np.array[float[M]]): desired joint accelerations Returns: - np.array[M]: joint torques computed using the rigid-body equation of motion + np.array[float[M]]: joint torques computed using the rigid-body equation of motion References: - [1] "Rigid Body Dynamics Algorithms", Featherstone, 2008, chap1.1 @@ -3333,12 +3341,12 @@ class Robot(ControllableBody): of motion in task/operational space (instead of joint space), check the references [1-4]. Args: - q (np.array[M]): joint positions - dq (np.array[M]): joint velocities - torques (np.array[M]): desired joint torques + q (np.array[float[M]]): joint positions + dq (np.array[float[M]]): joint velocities + torques (np.array[float[M]]): desired joint torques Returns: - np.array[M]: joint accelerations computed using the rigid-body equation of motion + np.array[float[M]]: joint accelerations computed using the rigid-body equation of motion References: - [1] "Rigid Body Dynamics Algorithms", Featherstone, 2008, chap1.1 @@ -3374,12 +3382,12 @@ class Robot(ControllableBody): joints. If the base is fixed, it will return a [N,N] inertia matrix Args: - q (np.array[N], None): joint positions of size N, where N is the total number of DoFs. If None, it will - get the current joint positions (but note that this could lead to a decrease of performance). + q (np.array[float[N]], None): joint positions of size N, where N is the total number of DoFs. If None, it + will get the current joint positions. q_idx (slice, None): if provided, it will slice the inertia matrix at the given q indices (0 < M <= N). Returns: - np.array[N,N], np.array[6+N,6+N], np.array[M,M]: inertia matrix + np.array[float[N,N]], np.array[float[6+N,6+N]], np.array[float[M,M]]: inertia matrix """ if q is None: q = self.get_joint_positions() @@ -3406,7 +3414,7 @@ class Robot(ControllableBody): The computation is based on [1]. Args: - jacobian (np.array[D,N]): Jacobian matrix + jacobian (np.array[float[D,N]]): Jacobian matrix Returns: float[N,N,N]: derivative of the inertia matrix wrt joint values (dH/dq) @@ -3451,13 +3459,13 @@ class Robot(ControllableBody): :math:`v = [\dot{p} \omega]^T = J(q) \dot{q}`, where :math:`\omega` are the angular velocities. Args: - H (np.array[N,N], None): Joint inertia matrix. If None, it will be computed here (the q's then need to be - provided). - Ja (np.array[6,N], None): Analytical Jacobian. If None, it will be computed here (the q's then need to be - provided and the link_id + H (np.array[float[N,N]], None): Joint inertia matrix. If None, it will be computed here (the q's then need + to be provided). + Ja (np.array[float[6,N]], None): Analytical Jacobian. If None, it will be computed here (the q's then need + to be provided and the link_id Returns: - np.array[6,6]: Cartesian inertia matrix + np.array[float[6,6]]: Cartesian inertia matrix """ Ja_inv = np.linalg.inv(Ja) return Ja_inv.T.dot(H).dot(Ja_inv) @@ -3469,10 +3477,10 @@ class Robot(ControllableBody): .. math:: T(q,\dot{q}) = \frac{1}{2} \dot{q}^T H(q) \dot{q} Args: - q (np.array[N], None): joint positions of size N, where N is the total number of DoFs. If None, it will - get the current joint positions (but note that this could lead to a decrease of performance). - dq (np.array[M], None): joint velocities of size M (with 0 < M <= N). If None, it will - get the current joint velocities (but note that this could lead to a decrease of performance). + q (np.array[float[N]], None): joint positions of size N, where N is the total number of DoFs. If None, it + will get the current joint positions. + dq (np.array[float[M]], None): joint velocities of size M (with 0 < M <= N). If None, it will + get the current joint velocities. q_idx (slice, None): if provided, it will slice the inertia matrix at the given q indices (0 < M <= N), and the joint velocities vector. @@ -3496,11 +3504,12 @@ class Robot(ControllableBody): vector, and :math:`p_l` is the position of the link. Args: - q (np.array[N], None): joint positions of size N, where N is the total number of DoFs. THIS IS CURRENTLY - NOT USED, as we can get the link positions from the simulator (instead of using forward kinematics). - q_idx (int[M], None): if provided, it will slice the inertia matrix at the given q indices (0 < M <= N), - and the joint velocities vector. - g (np.array[3], tuple/list of 3 float): gravity vector. + q (np.array[float[N]], None): joint positions of size N, where N is the total number of DoFs. THIS IS + CURRENTLY NOT USED, as we can get the link positions from the simulator (instead of using forward + kinematics). + q_idx (list[int[M]], None): if provided, it will slice the inertia matrix at the given q indices + (0 < M <= N), and the joint velocities vector. + g (np.array[float[3]], tuple/list[float[3]]): gravity vector. Returns: float: potential energy due to gravity @@ -3523,10 +3532,10 @@ class Robot(ControllableBody): `get_gravity_potential_energy`. Args: - q (np.array[N], None): joint positions of size N, where N is the total number of DoFs. If None, it will - get the current joint positions (but note that this could lead to a decrease of performance). - dq (np.array[M], None): joint velocities of size M (with 0 < M <= N). If None, it will - get the current joint velocities (but note that this could lead to a decrease of performance). + q (np.array[float[N]], None): joint positions of size N, where N is the total number of DoFs. If None, it + will get the current joint positions. + dq (np.array[float[M]], None): joint velocities of size M (with 0 < M <= N). If None, it will + get the current joint velocities. q_idx (int[M], None): if provided, it will slice the inertia matrix at the given q indices (0 < M <= N), and the joint velocities vector. @@ -3544,10 +3553,10 @@ class Robot(ControllableBody): where :math:`T` and :math:`V` are the kinetic and potential energy respectively. Args: - q (np.array[N], None): joint positions of size N, where N is the total number of DoFs. If None, it will - get the current joint positions (but note that this could lead to a decrease of performance). - dq (np.array[M], None): joint velocities of size M (with 0 < M <= N). If None, it will - get the current joint velocities (but note that this could lead to a decrease of performance). + q (np.array[float[N]], None): joint positions of size N, where N is the total number of DoFs. If None, it + will get the current joint positions. + dq (np.array[float[M]], None): joint velocities of size M (with 0 < M <= N). If None, it will + get the current joint velocities. q_idx (int[M], None): if provided, it will slice the inertia matrix at the given q indices (0 < M <= N), and the joint velocities vector. @@ -3569,11 +3578,12 @@ class Robot(ControllableBody): applied at the link), and :math:`J` is the geometric Jacobian. Args: - jacobian (np.array[3,N], np.array[6,N]): jacobian matrix. - wrench (np.array[3], np.array[6]): wrench applied to the link (point) associated to the given jacobian. + jacobian (np.array[float[3,N]], np.array[float[6,N]]): jacobian matrix. + wrench (np.array[float[3]], np.array[float[6]]): wrench applied to the link (point) associated to the given + jacobian. Returns: - np.array[N]: joint torques [Nm] + np.array[float[N]]: joint torques [Nm] """ return jacobian.T.dot(wrench) @@ -3588,11 +3598,11 @@ class Robot(ControllableBody): applied at the link), and :math:`J` is the geometric Jacobian. Args: - jacobian (np.array[6,N]): jacobian matrix. - torques (np.array[N]): torques. + jacobian (np.array[float[6,N]]): jacobian matrix. + torques (np.array[float[N]]): torques. Returns: - np.array[6]: forces and torques (=wrench) in the Cartesian world space [N,Nm] + np.array[float[6]]: forces and torques (=wrench) in the Cartesian world space [N,Nm] """ J = jacobian return J.dot(np.linalg.inv(J.T.dot(J))).dot(torques) @@ -3624,15 +3634,14 @@ class Robot(ControllableBody): effects. Args: - q (np.array[N], None): all the joint positions. If None, it will get the current joint positions of all the - joints. However, note that if you already got the joint positions in your code, - it is better to pass them to this method for performance. - dq (np.array[N], None): all the joint velocities. If None, it will get the current joint velocities of + q (np.array[float[N]], None): all the joint positions. If None, it will get the current joint positions of all the joints. + dq (np.array[float[N]], None): all the joint velocities. If None, it will get the current joint velocities + of all the joints. q_idx (int[M], None): slice the torques at the given q indices (0 < M <= N). Returns: - np.array[M]: joint torques to be applied [Nm] + np.array[float[M]]: joint torques to be applied [Nm] """ if q is None: q = self.get_joint_positions() @@ -3663,13 +3672,12 @@ class Robot(ControllableBody): These are the torques that need to be applied to the robot joints to compensate for gravity. Args: - q (np.array[N], None): all the joint positions. If None, it will get the current joint positions of all the - joints. However, note that if you already got the joint positions in your code, - it is better to pass them to this method for performance. + q (np.array[float[N]], None): all the joint positions. If None, it will get the current joint positions of + all the joints. q_idx (int[M], None): slice the torques at the given q indices (0 < M <= N). Returns: - np.array[M]: joint torques to be applied [Nm] + np.array[float[M]]: joint torques to be applied [Nm] """ if q is None: q = self.get_joint_positions() @@ -3696,15 +3704,14 @@ class Robot(ControllableBody): We can then get :math:`C(q,\dot{q}) \dot{q} = \tau_1 - \tau_2`. Args: - q (np.array[N], None): all the joint positions. If None, it will get the current joint positions of all the - joints. However, note that if you already got the joint positions in your code, - it is better to pass them to this method for performance. - dq (np.array[N], None): all the joint velocities. If None, it will get the current joint velocities of + q (np.array[float[N]], None): all the joint positions. If None, it will get the current joint positions of all the joints. + dq (np.array[float[N]], None): all the joint velocities. If None, it will get the current joint velocities + of all the joints. q_idx (int[M], None): slice the torques at the given q indices (0 < M <= N). Returns: - np.array[M]: joint torques to be applied [Nm] + np.array[float[M]]: joint torques to be applied [Nm] """ if q is None: q = self.get_joint_positions() @@ -3725,13 +3732,12 @@ class Robot(ControllableBody): .. math:: \tau = C(q,\dot{q}) \dot{q} + g(q). Args: - q (np.array[N], None): all the joint positions. If None, it will get the current joint positions of all the - joints. However, note that if you already got the joint positions in your code, - it is better to pass them to this method for performance. - dq (np.array[N], None): all the joint velocities. If None, it will get the current joint velocities of + q (np.array[float[N]], None): all the joint positions. If None, it will get the current joint positions of all the joints. + dq (np.array[float[N]], None): all the joint velocities. If None, it will get the current joint velocities + of all the joints. q_idx (int[M], None): slice the torques at the given q indices (0 < M <= N). - external_torques (np.array[M], float): external torques to be applied. + external_torques (np.array[float[M]], float): external torques to be applied. """ joint_ids = self.joints if q_idx is None else self.joints[q_idx] torques = self.get_coriolis_and_gravity_compensation_torques(q, dq, q_idx) @@ -3751,17 +3757,16 @@ class Robot(ControllableBody): where :math:`F = - D v` with :math:`v` are the Cartesian velocities, and :math:`D` is the damping factor. Args: - q (np.array[N], None): all the joint positions. If None, it will get the current joint positions of all the - joints. However, note that if you already got the joint positions in your code, - it is better to pass them to this method for performance. - dq (np.array[N], None): all the joint velocities. If None, it will get the current joint velocities of + q (np.array[float[N]], None): all the joint positions. If None, it will get the current joint positions of all the joints. + dq (np.array[float[N]], None): all the joint velocities. If None, it will get the current joint velocities + of all the joints. q_idx (int[M], None): slice the torques at the given q indices (0 < M <= N). - jacobian (np.array[6,N], np.array[6,6+N]): Jacobian matrix. - link_velocity (np.array[6]): linear and angular velocity of the link in the Cartesian world space + jacobian (np.array[float[6,N]], np.array[float[6,6+N]]): Jacobian matrix. + link_velocity (np.array[float[6]]): linear and angular velocity of the link in the Cartesian world space Returns: - np.array[M]: joint torques to be applied [Nm] + np.array[float[M]]: joint torques to be applied [Nm] """ if q is None: q = self.get_joint_positions() @@ -3785,13 +3790,12 @@ class Robot(ControllableBody): force projected from the Cartesian space to the joint space. Args: - q (np.array[N], None): all the joint positions. If None, it will get the current joint positions of all the - joints. However, note that if you already got the joint positions in your code, - it is better to pass them to this method for performance. - dq (np.array[N], None): all the joint velocities. If None, it will get the current joint velocities of + q (np.array[float[N]], None): all the joint positions. If None, it will get the current joint positions of all the joints. + dq (np.array[float[N]], None): all the joint velocities. If None, it will get the current joint velocities + of all the joints. q_idx (int[M], None): slice the torques at the given q indices (0 < M <= N). - external_torques (float, np.array[M]): external torques. + external_torques (float, np.array[float[M]]): external torques. """ joint_id = self.joints if q_idx is None else self.joints[q_idx] torques = self.get_active_compliant_torques(q, dq, q_idx) @@ -3807,7 +3811,7 @@ class Robot(ControllableBody): # # # Returns: - # np.array[N]: impedance torques + # np.array[float[N]]: impedance torques # # References: # - [1] Lecture on "Impedance Control" by Prof. De Luca, Universita di Roma, @@ -3825,17 +3829,17 @@ class Robot(ControllableBody): and :math:`K` and :math:`D` are the stiffness and damping factor, respectively. Args: - q (np.array[N]): joint positions - dq (np.array[N]): joint velocities - x_des (np.array[3]): desired position of the link - x (np.array[3]): cartesian world position of the link - dx (np.array[3]): cartesian world linear velocity of the link - jacobian (np.array[3,N]): linear jacobian associated to the link - K (float, np.array[3,3]): proportional gain scalar or matrix - D (float, np.array[3,3]): derivative gain scalar or matrix + q (np.array[float[N]]): joint positions + dq (np.array[float[N]]): joint velocities + x_des (np.array[float[3]]): desired position of the link + x (np.array[float[3]]): cartesian world position of the link + dx (np.array[float[3]]): cartesian world linear velocity of the link + jacobian (np.array[float[3,N]]): linear jacobian associated to the link + K (float, np.array[float[3,3]]): proportional gain scalar or matrix + D (float, np.array[float[3,3]]): derivative gain scalar or matrix Returns: - np.array[N]: torques to apply + np.array[float[N]]: torques to apply References: - [1] Lecture on "Impedance Control" by Prof. De Luca, Universita di Roma, @@ -3869,11 +3873,11 @@ class Robot(ControllableBody): Compute the dynamic manipulability ellipsoid (matrix) as `M = J(q)H(q)^{-1} (J(q)H(q)^{-1})^T`. Args: - jacobian (np.array[D,N]): Jacobian matrix - inertia (np.array[N,N]): inertia matrix in joint space + jacobian (np.array[float[D,N]]): Jacobian matrix + inertia (np.array[float[N,N]]): inertia matrix in joint space Returns: - np.array[D,D]: dynamic manipulability + np.array[float[D,D]]: dynamic manipulability """ epsilon = jacobian.dot(np.linalg.inv(inertia)) return epsilon.dot(epsilon.T) @@ -3885,13 +3889,13 @@ class Robot(ControllableBody): the actuated joints. Args: - jacobian (np.array[D,N]): Jacobian matrix - inertia (np.array[N,N]): inertia matrix - target_dynamic_manipulability (np.array[D,D]): target dynamic manipulability + jacobian (np.array[float[D,N]]): Jacobian matrix + inertia (np.array[float[N,N]]): inertia matrix + target_dynamic_manipulability (np.array[float[D,D]]): target dynamic manipulability Km (float[,]): Proportional gain for manipulability error Returns: - np.array[N]: joint velocities + np.array[float[N]]: joint velocities float: minimum of eigenvalues of the dynamic manip. Jacobian float: Distance between desired and current manip. ellipsoids """ @@ -3922,8 +3926,8 @@ class Robot(ControllableBody): Compute the dynamic manipulability Jacobian. Args: - jacobian (np.array[D,N]): Jacobian matrix - inertia (np.array[N,N]): inertia matrix + jacobian (np.array[float[D,N]]): Jacobian matrix + inertia (np.array[float[N,N]]): inertia matrix num_task_vars (int): number of task variables (usually 3 or 6) Returns: @@ -3990,16 +3994,16 @@ class Robot(ControllableBody): Warnings: this currently does not work with a fixed base. Args: - q (np.array[N], None): joint positions of size N, where N is the total number of free joints. If None, it - will get the current joint positions (but note that this could lead to a decrease of performance). - dq (np.array[N], None): joint velocities of size N, where N is the total number of free joints. If None, it - will get the current joint velocities (but note that this could lead to a decrease of performance). - inertia (np.array[6+N,6+N]): inertia matrix. If None, it will get the current inertia matrix + q (np.array[float[N]], None): joint positions of size N, where N is the total number of free joints. If + None, it will get the current joint positions. + dq (np.array[float[N]], None): joint velocities of size N, where N is the total number of free joints. If + None, it will get the current joint velocities. + inertia (np.array[float[6+N,6+N]]): inertia matrix. If None, it will get the current inertia matrix (but note that this could lead to a decrease of performance if you have already computed it). Returns: - np.array[6, N+6]: the centroidal momentum matrix :math:`A_G` - np.array[6]: the centroidal dynamics velocity-dependent bias vector :math:`\dot{A}_G \dot{q}` + np.array[float[6,6+N]]: the centroidal momentum matrix :math:`A_G` + np.array[float[6]]: the centroidal dynamics velocity-dependent bias vector :math:`\dot{A}_G \dot{q}` Raises: RuntimeError: if the robot has not a floating base (i.e. it has a fixed base). @@ -4073,15 +4077,15 @@ class Robot(ControllableBody): angular momentum together. Args: - q (np.array[N], None): joint positions of size N, where N is the total number of free joints. If None, it - will get the current joint positions (but note that this could lead to a decrease of performance). - dq (np.array[N], None): joint velocities of size N, where N is the total number of free joints. If None, it - will get the current joint velocities (but note that this could lead to a decrease of performance). - inertia (np.array[6+N,6+N]): inertia matrix. If None, it will get the current inertia matrix + q (np.array[float[N]], None): joint positions of size N, where N is the total number of free joints. If + None, it will get the current joint positions. + dq (np.array[float[N]], None): joint velocities of size N, where N is the total number of free joints. If + None, it will get the current joint velocities. + inertia (np.array[float[6+N,6+N]]): inertia matrix. If None, it will get the current inertia matrix (but note that this could lead to a decrease of performance if you have already computed it). Returns: - np.array[6]: the centroidal momentum + np.array[float[6]]: the centroidal momentum Raises: RuntimeError: if the robot has not a floating base (i.e. it has a fixed base). @@ -4103,10 +4107,10 @@ class Robot(ControllableBody): Return the singular values of the centroidal momentum matrix. Args: - A_G (np.array[6, N+6]): centroidal momentum matrix + A_G (np.array[float[6,6+N]]): centroidal momentum matrix Returns: - np.array[6]: singular values + np.array[float[6]]: singular values """ u, s, vh = np.linalg.svd(A_G, full_matrices=True) return s @@ -4117,10 +4121,10 @@ class Robot(ControllableBody): Return the orientation and scale of the centroidal momentum matrix ellipsoid. Args: - A_G (np.array[6, N+6]): centroidal momentum matrix + A_G (np.array[float[6,6+N]]): centroidal momentum matrix Returns: - np.array[4]: orientation (expressed as a quaternion [x,y,z,w]) + np.array[float[4]]: orientation (expressed as a quaternion [x,y,z,w]) float: scale """ u, scale, vh = np.linalg.svd(A_G, full_matrices=True) @@ -4159,8 +4163,8 @@ class Robot(ControllableBody): # point: # # Returns: - # np.array[M,M]: :math:`A` matrix, where M is the size of the state vector - # np.array[M,N]: :math:`B` matrix, where N is the size of the input vector + # np.array[float[M,M]]: :math:`A` matrix, where M is the size of the state vector + # np.array[float[M,N]]: :math:`B` matrix, where N is the size of the input vector # # References: # - [1] "State-Space Representation of LTI Systems", Rowell, 2002 (handout): @@ -4623,7 +4627,7 @@ class Robot(ControllableBody): color (tuple/list of 4 float): rgba color of the sphere. By default, it is red. Returns: - np.array[3]: center of mass + np.array[float[3]]: center of mass """ self.get_center_of_mass_position() self.draw_com_position(radius=radius, color=color) @@ -4664,7 +4668,7 @@ class Robot(ControllableBody): max_depth (float): if there is an object more than max_depth, it is not considered Returns: - np.array[3], None: position of the projected CoM, or None if it couldn't project the CoM + np.array[float[3]], None: position of the projected CoM, or None if it couldn't project the CoM """ com = self.get_center_of_mass_position() object_id, _, _, hit_position, _ = self.sim.ray_test(com, com - np.array([0., 0., max_depth]))[0] @@ -4682,7 +4686,7 @@ class Robot(ControllableBody): color (tuple/list of 4 float): rgba color of the sphere. By default it is blue. Returns: - np.array[3], None: position of the projected CoM, or None if it couldn't project the CoM + np.array[float[3]], None: position of the projected CoM, or None if it couldn't project the CoM """ projected_com = self.get_projected_com_position() if projected_com is not None: @@ -4849,8 +4853,8 @@ class Robot(ControllableBody): Warnings: Currently, PyBullet doesn't support to load an ellipsoid, so we load from a mesh file. Args: - position (np.array[3]): position in the world space - orientation (np.array[4]): orientation in the world space + position (np.array[float[3]]): position in the world space + orientation (np.array[float[4]]): orientation in the world space scale (list/tuple of 3 float): scale in the (x,y,z) directions color (list/tuple of 4 float): RGBA color @@ -4873,7 +4877,7 @@ class Robot(ControllableBody): X (np.array): 2D matrix Returns: - np.array[4]: orientation (expressed as a quaternion [x,y,z,w]) + np.array[float[4]]: orientation (expressed as a quaternion [x,y,z,w]) float: scale """ # compute evecs and singular values @@ -4934,9 +4938,9 @@ class Robot(ControllableBody): Args: link_id (int): link id. This will be used to check where to draw the ellipsoid. - linear_jacobian (np.array[3,N], None): linear Jacobian matrix. It doesn't need to be provided if `JJT` is - given. - JJT (np.array[3,3], None): if None, it will compute it using the provided linear Jacobian matrix. + linear_jacobian (np.array[float[3,N]], None): linear Jacobian matrix. It doesn't need to be provided if + `JJT` is given. + JJT (np.array[float[3,3]], None): if None, it will compute it using the provided linear Jacobian matrix. color (tuple of 4 float): RGBA color (each channel is between 0 and 1) Returns: @@ -4964,9 +4968,9 @@ class Robot(ControllableBody): Args: link_id (int): link id. This will be used to check where to draw the ellipsoid. - linear_jacobian (np.array[3,N], None): linear Jacobian matrix. It doesn't need to be provided if `JJT` is - given. - JJT (np.array[3,3], None): if None, it will compute it using the provided linear Jacobian matrix. + linear_jacobian (np.array[float[3,N]], None): linear Jacobian matrix. It doesn't need to be provided if + `JJT` is given. + JJT (np.array[float[3,3]], None): if None, it will compute it using the provided linear Jacobian matrix. color (tuple of 4 float): RGBA color (each channel is between 0 and 1) Returns: diff --git a/pyrobolearn/robots/rrbot.py b/pyrobolearn/robots/rrbot.py index 3a4ab23..ca25c90 100644 --- a/pyrobolearn/robots/rrbot.py +++ b/pyrobolearn/robots/rrbot.py @@ -31,8 +31,8 @@ class RRBot(Robot): Args: simulator (Simulator): simulator instance. - position (np.array[3]): Cartesian world position. - orientation (np.array[4]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. + position (np.array[float[3]]): Cartesian world position. + orientation (np.array[float[4]]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. fixed_base (bool): if True, the robot base will be fixed in the world. scale (float): scaling factor that is used to scale the robot. urdf (str): path to the urdf. Do not change it unless you know what you are doing. diff --git a/pyrobolearn/robots/sawyer.py b/pyrobolearn/robots/sawyer.py index 2a616b9..2b423b9 100644 --- a/pyrobolearn/robots/sawyer.py +++ b/pyrobolearn/robots/sawyer.py @@ -33,8 +33,8 @@ class Sawyer(Manipulator, WheeledRobot): Args: simulator (Simulator): simulator instance. - position (np.array[3]): Cartesian world position. - orientation (np.array[4]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. + position (np.array[float[3]]): Cartesian world position. + orientation (np.array[float[4]]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. fixed_base (bool): if True, the robot base will be fixed in the world. scale (float): scaling factor that is used to scale the robot. urdf (str): path to the urdf. Do not change it unless you know what you are doing. diff --git a/pyrobolearn/robots/schunk_hand.py b/pyrobolearn/robots/schunk_hand.py index f854df6..98cf5d8 100644 --- a/pyrobolearn/robots/schunk_hand.py +++ b/pyrobolearn/robots/schunk_hand.py @@ -31,8 +31,8 @@ class SchunkHand(Hand): Args: simulator (Simulator): simulator instance. - position (np.array[3]): Cartesian world position. - orientation (np.array[4]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. + position (np.array[float[3]]): Cartesian world position. + orientation (np.array[float[4]]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. fixed_base (bool): if True, the hand base will be fixed in the world. scale (float): scaling factor that is used to scale the hand. """ diff --git a/pyrobolearn/robots/sea_hexapod.py b/pyrobolearn/robots/sea_hexapod.py index 603549e..2d4f017 100644 --- a/pyrobolearn/robots/sea_hexapod.py +++ b/pyrobolearn/robots/sea_hexapod.py @@ -29,8 +29,8 @@ class SEAHexapod(HexapodRobot): Args: simulator (Simulator): simulator instance. - position (np.array[3]): Cartesian world position. - orientation (np.array[4]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. + position (np.array[float[3]]): Cartesian world position. + orientation (np.array[float[4]]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. fixed_base (bool): if True, the robot base will be fixed in the world. scale (float): scaling factor that is used to scale the robot. urdf (str): path to the urdf. Do not change it unless you know what you are doing. diff --git a/pyrobolearn/robots/sea_snake.py b/pyrobolearn/robots/sea_snake.py index a55fc92..b209d1c 100644 --- a/pyrobolearn/robots/sea_snake.py +++ b/pyrobolearn/robots/sea_snake.py @@ -29,8 +29,8 @@ class SEASnake(Robot): Args: simulator (Simulator): simulator instance. - position (np.array[3]): Cartesian world position. - orientation (np.array[4]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. + position (np.array[float[3]]): Cartesian world position. + orientation (np.array[float[4]]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. fixed_base (bool): if True, the robot base will be fixed in the world. scale (float): scaling factor that is used to scale the robot. urdf (str): path to the urdf. Do not change it unless you know what you are doing. diff --git a/pyrobolearn/robots/sensors/altimeter.py b/pyrobolearn/robots/sensors/altimeter.py index 0f8b72e..c74720b 100644 --- a/pyrobolearn/robots/sensors/altimeter.py +++ b/pyrobolearn/robots/sensors/altimeter.py @@ -38,10 +38,10 @@ class AltimeterSensor(LinkSensor): noise (None, Noise): noise to be added. ticks (int): number of steps to wait/sleep before acquisition of the next sensor value. latency (int, float, None): latency time / step. - position (np.array[3], None): local position of the sensor with respect to the given link. If None, it will - be the zero vector. - orientation (np.array[4], None): local orientation of the sensor with respect to the given link (expressed - as a quaternion [x,y,z,w]). If None, it will be the unit quaternion [0,0,0,1]. + position (np.array[float[3]], None): local position of the sensor with respect to the given link. If None, + it will be the zero vector. + orientation (np.array[float[4]], None): local orientation of the sensor with respect to the given link + (expressed as a quaternion [x,y,z,w]). If None, it will be the unit quaternion [0,0,0,1]. """ super(AltimeterSensor, self).__init__(simulator, body_id=body_id, link_id=link_id, noise=noise, ticks=ticks, latency=latency, position=position, orientation=orientation) diff --git a/pyrobolearn/robots/sensors/camera.py b/pyrobolearn/robots/sensors/camera.py index 309584c..62f3a1a 100644 --- a/pyrobolearn/robots/sensors/camera.py +++ b/pyrobolearn/robots/sensors/camera.py @@ -73,10 +73,10 @@ class CameraSensor(LinkSensor): # TODO: double-check this class noise (None, Noise): noise to be added. ticks (int): number of steps to wait/sleep before acquisition of the next sensor value. latency (int, float, None): latency time / step. - position (np.array[3], None): local position of the sensor with respect to the given link. If None, it will - be the zero vector. - orientation (np.array[4], None): local orientation of the sensor with respect to the given link (expressed - as a quaternion [x,y,z,w]). If None, it will be the unit quaternion [0,0,0,1]. + position (np.array[float[3]], None): local position of the sensor with respect to the given link. If None, + it will be the zero vector. + orientation (np.array[float[4]], None): local orientation of the sensor with respect to the given link + (expressed as a quaternion [x,y,z,w]). If None, it will be the unit quaternion [0,0,0,1]. For a view matrix: target_position (list/tuple of 3 floats): target focus point in cartesian world coordinates diff --git a/pyrobolearn/robots/sensors/imu.py b/pyrobolearn/robots/sensors/imu.py index 1595fbd..c7dd917 100644 --- a/pyrobolearn/robots/sensors/imu.py +++ b/pyrobolearn/robots/sensors/imu.py @@ -57,10 +57,10 @@ class IMUSensor(LinkSensor): noise (None, Noise): noise to be added. ticks (int): number of steps to wait/sleep before acquisition of the next sensor value. latency (int, float, None): latency time / step. - position (np.array[3], None): local position of the sensor with respect to the given link. If None, it will - be the zero vector. - orientation (np.array[4], None): local orientation of the sensor with respect to the given link (expressed - as a quaternion [x,y,z,w]). If None, it will be the unit quaternion [0,0,0,1]. + position (np.array[float[3]], None): local position of the sensor with respect to the given link. If None, + it will be the zero vector. + orientation (np.array[float[4]], None): local orientation of the sensor with respect to the given link + (expressed as a quaternion [x,y,z,w]). If None, it will be the unit quaternion [0,0,0,1]. """ super(IMUSensor, self).__init__(simulator, body_id=body_id, link_id=link_id, noise=noise, ticks=ticks, latency=latency, position=position, orientation=orientation) diff --git a/pyrobolearn/robots/sensors/links.py b/pyrobolearn/robots/sensors/links.py index f02c7e4..d2a5371 100644 --- a/pyrobolearn/robots/sensors/links.py +++ b/pyrobolearn/robots/sensors/links.py @@ -39,10 +39,10 @@ class LinkSensor(Sensor): simulator (Simulator): simulator instance. body_id (int): unique id of the body. link_id (int): unique id of the link. - position (np.array[3], None): local position of the sensor with respect to the given link. If None, it will - be the zero vector. - orientation (np.array[4], None): local orientation of the sensor with respect to the given link (expressed - as a quaternion [x,y,z,w]). If None, it will be the unit quaternion [0,0,0,1]. + position (np.array[float[3]], None): local position of the sensor with respect to the given link. If None, + it will be the zero vector. + orientation (np.array[float[4]], None): local orientation of the sensor with respect to the given link + (expressed as a quaternion [x,y,z,w]). If None, it will be the unit quaternion [0,0,0,1]. noise (None, Noise): noise to be added. ticks (int): number of steps to wait/sleep before acquisition of the next sensor value. latency (int, float, None): latency time / step. @@ -100,7 +100,7 @@ class LinkSensor(Sensor): Return the CoM position (in the Cartesian world space coordinates) of the link associated with the sensor. Returns: - np.array[3]: the link CoM position in the world space + np.array[float[3]]: the link CoM position in the world space """ # check if cached if 'pos' in self._state: diff --git a/pyrobolearn/robots/sensors/ray.py b/pyrobolearn/robots/sensors/ray.py index e70114c..2354c9a 100644 --- a/pyrobolearn/robots/sensors/ray.py +++ b/pyrobolearn/robots/sensors/ray.py @@ -32,16 +32,16 @@ class RaySensor(LinkSensor): Args: simulator (Simulator): simulator instance. body_id (int): unique body id. - to_position (np.array[3]): position where the ray should stop with respect to the new local link frame - (specified by :attr:`position` and :attr:`orientation`). + to_position (np.array[float[3]]): position where the ray should stop with respect to the new local link + frame (specified by :attr:`position` and :attr:`orientation`). link_id (int): unique id of the link. noise (None, Noise): noise to be added. ticks (int): number of steps to wait/sleep before acquisition of the next sensor value. latency (int, float, None): latency time / step. - position (np.array[3], None): local position of the sensor with respect to the given link. If None, it will - be the zero vector. - orientation (np.array[4], None): local orientation of the sensor with respect to the given link (expressed - as a quaternion [x,y,z,w]). If None, it will be the unit quaternion [0,0,0,1]. + position (np.array[float[3]], None): local position of the sensor with respect to the given link. If None, + it will be the zero vector. + orientation (np.array[float[4]], None): local orientation of the sensor with respect to the given link + (expressed as a quaternion [x,y,z,w]). If None, it will be the unit quaternion [0,0,0,1]. """ super(RaySensor, self).__init__(simulator, body_id=body_id, link_id=link_id, noise=noise, ticks=ticks, latency=latency, position=position, orientation=orientation) @@ -73,6 +73,17 @@ class RaySensor(LinkSensor): hit = self._noise(hit) return hit + def render(self, enable=True, color=None): + """Render the ray in the simulator; they are only visual and attached to the sensor (link). The visual shape + is updated at runtime (each time you call this function). + + Args: + enable (bool): if we should render or not. + color (None, tuple/list of 4 float, np.ndarray[float[4]]): RGBA color of all the rays, where each channel + is between 0 and 1. + """ + pass + class RayBatchSensor(LinkSensor): r"""Ray batch sensor. @@ -98,10 +109,10 @@ class RayBatchSensor(LinkSensor): noise (None, Noise): noise to be added. ticks (int): number of steps to wait/sleep before acquisition of the next sensor value. latency (int, float, None): latency time / step. - position (np.array[3], None): local position of the sensor with respect to the given link. If None, it will - be the zero vector. - orientation (np.array[4], None): local orientation of the sensor with respect to the given link (expressed - as a quaternion [x,y,z,w]). If None, it will be the unit quaternion [0,0,0,1]. + position (np.array[float[3]], None): local position of the sensor with respect to the given link. If None, + it will be the zero vector. + orientation (np.array[float[4]], None): local orientation of the sensor with respect to the given link + (expressed as a quaternion [x,y,z,w]). If None, it will be the unit quaternion [0,0,0,1]. """ super(RayBatchSensor, self).__init__(simulator, body_id=body_id, link_id=link_id, noise=noise, ticks=ticks, latency=latency, position=position, orientation=orientation) @@ -140,6 +151,17 @@ class RayBatchSensor(LinkSensor): hit = self._noise(hit) return hit + def render(self, enable=True, color=None): + """Render the batch of rays in the simulator; they are only visual and attached to the sensor (link). The + visual shape of each ray is updated at runtime (each time you call this function). + + Args: + enable (bool): if we should render or not. + color (None, tuple/list of 4 float, np.ndarray[float[4]]): RGBA color of all the rays, where each channel + is between 0 and 1. + """ + pass + class HeightmapSensor(LinkSensor): r"""Heightmap Sensor @@ -168,10 +190,10 @@ class HeightmapSensor(LinkSensor): num_rays_height (int): number of rays along the height dimension (front-back axis). This will be the 'height' of the returned heightmap. This must be bigger or equal to 2. max_ray_length (float): maximum length of each ray. - position (np.array[3], None): local position of the sensor with respect to the given link. If None, it will - be the zero vector. This position represents the center of the map. - orientation (np.array[4], None): local orientation of the sensor with respect to the given link (expressed - as a quaternion [x,y,z,w]). If None, it will be the unit quaternion [0,0,0,1]. + position (np.array[float[3]], None): local position of the sensor with respect to the given link. If None, + it will be the zero vector. This position represents the center of the map. + orientation (np.array[float[4]], None): local orientation of the sensor with respect to the given link + (expressed as a quaternion [x,y,z,w]). If None, it will be the unit quaternion [0,0,0,1]. """ super(HeightmapSensor, self).__init__(simulator, body_id=body_id, link_id=link_id, position=position, orientation=orientation) @@ -246,3 +268,14 @@ class HeightmapSensor(LinkSensor): if apply_noise: hit = self._noise(hit) return hit + + def render(self, enable=True, color=None): + """Render the grid map in the simulator; each point/intersection in the grid is represented as a visual + sphere. The position of these spheres is updated at runtime (each time you call this function). + + Args: + enable (bool): if we should render or not. + color (None, tuple/list of 4 float, np.ndarray[float[4]]): RGBA color of all the rays, where each channel + is between 0 and 1. + """ + pass diff --git a/pyrobolearn/robots/sensors/sensor.py b/pyrobolearn/robots/sensors/sensor.py index 2532e0d..e7f7b39 100644 --- a/pyrobolearn/robots/sensors/sensor.py +++ b/pyrobolearn/robots/sensors/sensor.py @@ -56,10 +56,10 @@ class Sensor(object): # sensor attached to a link or joint noise (None, Noise): noise to be added. ticks (int): number of steps to wait/sleep before acquisition of the next sensor value. latency (int, float, None): latency time / step. - position (np.array[3], None): local position of the sensor with respect to the given link. If None, it will - be the zero vector. - orientation (np.array[4], None): local orientation of the sensor with respect to the given link (expressed - as a quaternion [x,y,z,w]). If None, it will be the unit quaternion [0,0,0,1]. + position (np.array[float[3]], None): local position of the sensor with respect to the given link. If None, + it will be the zero vector. + orientation (np.array[float[4]], None): local orientation of the sensor with respect to the given link + (expressed as a quaternion [x,y,z,w]). If None, it will be the unit quaternion [0,0,0,1]. """ # setting simulator if not isinstance(simulator, Simulator): diff --git a/pyrobolearn/robots/shadowhand.py b/pyrobolearn/robots/shadowhand.py index a029798..1cecc18 100644 --- a/pyrobolearn/robots/shadowhand.py +++ b/pyrobolearn/robots/shadowhand.py @@ -31,8 +31,8 @@ class ShadowHand(Hand): Args: simulator (Simulator): simulator instance. - position (np.array[3]): Cartesian world position. - orientation (np.array[4]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. + position (np.array[float[3]]): Cartesian world position. + orientation (np.array[float[4]]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. fixed_base (bool): if True, the robot base will be fixed in the world. scale (float): scaling factor that is used to scale the robot. left (bool): if we should create a left hand, or right hand. diff --git a/pyrobolearn/robots/slip.py b/pyrobolearn/robots/slip.py index 191a4ba..ae845c0 100644 --- a/pyrobolearn/robots/slip.py +++ b/pyrobolearn/robots/slip.py @@ -48,6 +48,18 @@ class SLIP2D(LeggedRobot): super(SLIP2D, self).__init__(simulator, urdf, position, orientation, fixed_base, scale) self.name = 'SLIP_2d' + # create mass sphere + + # create leg (capsule or cylinder with sphere at the end) + + # create spring (capsules or cylinders) + + # create prismatic constraint for spring + + # create planar constraint + + # simulate the force due to the spring (in step) + class DualSLIP2D(LeggedRobot): r"""Dual Linear Inverted Pendulum Model 2D diff --git a/pyrobolearn/robots/softhand.py b/pyrobolearn/robots/softhand.py index 08092fa..15a4792 100644 --- a/pyrobolearn/robots/softhand.py +++ b/pyrobolearn/robots/softhand.py @@ -30,8 +30,8 @@ class SoftHand(Hand): Args: simulator (Simulator): simulator instance. - position (np.array[3]): Cartesian world position. - orientation (np.array[4]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. + position (np.array[float[3]]): Cartesian world position. + orientation (np.array[float[4]]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. fixed_base (bool): if True, the robot base will be fixed in the world. scale (float): scaling factor that is used to scale the robot. left (bool): if we should create a left hand, or right hand. diff --git a/pyrobolearn/robots/techpod.py b/pyrobolearn/robots/techpod.py index 214e53e..443477b 100755 --- a/pyrobolearn/robots/techpod.py +++ b/pyrobolearn/robots/techpod.py @@ -41,8 +41,8 @@ class Techpod(FixedWingUAV): Args: simulator (Simulator): simulator instance. - position (np.array[3]): Cartesian world position. - orientation (np.array[4]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. + position (np.array[float[3]]): Cartesian world position. + orientation (np.array[float[4]]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. fixed_base (bool): if True, the robot base will be fixed in the world. scale (float): scaling factor that is used to scale the robot. urdf (str): path to the urdf. Do not change it unless you know what you are doing. diff --git a/pyrobolearn/robots/uav.py b/pyrobolearn/robots/uav.py index 9f1a931..6a7f509 100644 --- a/pyrobolearn/robots/uav.py +++ b/pyrobolearn/robots/uav.py @@ -27,8 +27,8 @@ class UAVRobot(Robot): Args: simulator (Simulator): simulator instance. urdf (str): path to the urdf. Do not change it unless you know what you are doing. - position (np.array[3]): Cartesian world position. - orientation (np.array[4]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. + position (np.array[float[3]]): Cartesian world position. + orientation (np.array[float[4]]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. fixed_base (bool): if True, the robot base will be fixed in the world. scale (float): scaling factor that is used to scale the robot. """ @@ -60,8 +60,8 @@ class FixedWingUAV(UAVRobot): Args: simulator (Simulator): simulator instance. urdf (str): path to the urdf. Do not change it unless you know what you are doing. - position (np.array[3]): Cartesian world position. - orientation (np.array[4]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. + position (np.array[float[3]]): Cartesian world position. + orientation (np.array[float[4]]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. fixed_base (bool): if True, the robot base will be fixed in the world. scale (float): scaling factor that is used to scale the robot. """ @@ -80,8 +80,8 @@ class RotaryWingUAV(UAVRobot): Args: simulator (Simulator): simulator instance. urdf (str): path to the urdf. Do not change it unless you know what you are doing. - position (np.array[3]): Cartesian world position. - orientation (np.array[4]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. + position (np.array[float[3]]): Cartesian world position. + orientation (np.array[float[4]]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. fixed_base (bool): if True, the robot base will be fixed in the world. scale (float): scaling factor that is used to scale the robot. """ @@ -133,8 +133,8 @@ class FlappingWingUAV(UAVRobot): Args: simulator (Simulator): simulator instance. urdf (str): path to the urdf. Do not change it unless you know what you are doing. - position (np.array[3]): Cartesian world position. - orientation (np.array[4]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. + position (np.array[float[3]]): Cartesian world position. + orientation (np.array[float[4]]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. fixed_base (bool): if True, the robot base will be fixed in the world. scale (float): scaling factor that is used to scale the robot. """ diff --git a/pyrobolearn/robots/ur.py b/pyrobolearn/robots/ur.py index 8f31dac..e4d6c58 100644 --- a/pyrobolearn/robots/ur.py +++ b/pyrobolearn/robots/ur.py @@ -36,8 +36,8 @@ class UR3(Manipulator): Args: simulator (Simulator): simulator instance. - position (np.array[3]): Cartesian world position. - orientation (np.array[4]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. + position (np.array[float[3]]): Cartesian world position. + orientation (np.array[float[4]]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. fixed_base (bool): if True, the robot base will be fixed in the world. scale (float): scaling factor that is used to scale the robot. urdf (str): path to the urdf. Do not change it unless you know what you are doing. @@ -71,8 +71,8 @@ class UR5(Manipulator): Args: simulator (Simulator): simulator instance. - position (np.array[3]): Cartesian world position. - orientation (np.array[4]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. + position (np.array[float[3]]): Cartesian world position. + orientation (np.array[float[4]]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. fixed_base (bool): if True, the robot base will be fixed in the world. scale (float): scaling factor that is used to scale the robot. urdf (str): path to the urdf. Do not change it unless you know what you are doing. @@ -106,8 +106,8 @@ class UR10(Manipulator): Args: simulator (Simulator): simulator instance. - position (np.array[3]): Cartesian world position. - orientation (np.array[4]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. + position (np.array[float[3]]): Cartesian world position. + orientation (np.array[float[4]]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. fixed_base (bool): if True, the robot base will be fixed in the world. scale (float): scaling factor that is used to scale the robot. urdf (str): path to the urdf. Do not change it unless you know what you are doing. diff --git a/pyrobolearn/robots/usv.py b/pyrobolearn/robots/usv.py index 7f5038d..bfe46e9 100644 --- a/pyrobolearn/robots/usv.py +++ b/pyrobolearn/robots/usv.py @@ -27,8 +27,8 @@ class USVRobot(Robot): Args: simulator (Simulator): simulator instance. urdf (str): path to the urdf. Do not change it unless you know what you are doing. - position (np.array[3]): Cartesian world position. - orientation (np.array[4]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. + position (np.array[float[3]]): Cartesian world position. + orientation (np.array[float[4]]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. fixed_base (bool): if True, the robot base will be fixed in the world. scale (float): scaling factor that is used to scale the robot. """ diff --git a/pyrobolearn/robots/uuv.py b/pyrobolearn/robots/uuv.py index dc80cb7..11fa36f 100644 --- a/pyrobolearn/robots/uuv.py +++ b/pyrobolearn/robots/uuv.py @@ -27,8 +27,8 @@ class UUVRobot(Robot): Args: simulator (Simulator): simulator instance. urdf (str): path to the urdf. Do not change it unless you know what you are doing. - position (np.array[3]): Cartesian world position. - orientation (np.array[4]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. + position (np.array[float[3]]): Cartesian world position. + orientation (np.array[float[4]]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. fixed_base (bool): if True, the robot base will be fixed in the world. scale (float): scaling factor that is used to scale the robot. """ diff --git a/pyrobolearn/robots/walkman.py b/pyrobolearn/robots/walkman.py index c0e55d6..c257382 100644 --- a/pyrobolearn/robots/walkman.py +++ b/pyrobolearn/robots/walkman.py @@ -37,8 +37,8 @@ class Walkman(BipedRobot, BiManipulator): Args: simulator (Simulator): simulator instance. - position (np.array[3]): Cartesian world position. - orientation (np.array[4]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. + position (np.array[float[3]]): Cartesian world position. + orientation (np.array[float[4]]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. fixed_base (bool): if True, the robot base will be fixed in the world. scale (float): scaling factor that is used to scale the robot. lower_body (bool): if True, it will instantiate only the lower part of the robot (i.e. the legs). diff --git a/pyrobolearn/robots/wam.py b/pyrobolearn/robots/wam.py index a150c90..3f7421c 100644 --- a/pyrobolearn/robots/wam.py +++ b/pyrobolearn/robots/wam.py @@ -31,8 +31,8 @@ class WAM(Manipulator): Args: simulator (Simulator): simulator instance. - position (np.array[3]): Cartesian world position. - orientation (np.array[4]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. + position (np.array[float[3]]): Cartesian world position. + orientation (np.array[float[4]]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. fixed_base (bool): if True, the robot base will be fixed in the world. scale (float): scaling factor that is used to scale the gripper. urdf (str): path to the urdf. Do not change it unless you know what you are doing. @@ -68,8 +68,8 @@ class BarrettHand(AngularGripper): Args: simulator (Simulator): simulator instance. - position (np.array[3]): Cartesian world position. - orientation (np.array[4]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. + position (np.array[float[3]]): Cartesian world position. + orientation (np.array[float[4]]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. fixed_base (bool): if True, the gripper will be fixed in the world. scale (float): scaling factor that is used to scale the gripper. urdf (str): path to the urdf. Do not change it unless you know what you are doing. diff --git a/pyrobolearn/robots/wheeled_robot.py b/pyrobolearn/robots/wheeled_robot.py index a28b519..01fd292 100644 --- a/pyrobolearn/robots/wheeled_robot.py +++ b/pyrobolearn/robots/wheeled_robot.py @@ -30,8 +30,8 @@ class WheeledRobot(Robot): Args: simulator (Simulator): simulator instance. urdf (str): path to the urdf. Do not change it unless you know what you are doing. - position (np.array[3]): Cartesian world position. - orientation (np.array[4]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. + position (np.array[float[3]]): Cartesian world position. + orientation (np.array[float[4]]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. fixed_base (bool): if True, the robot base will be fixed in the world. scale (float): scaling factor that is used to scale the robot. """ @@ -148,8 +148,8 @@ class DifferentialWheeledRobot(WheeledRobot): Args: simulator (Simulator): simulator instance. urdf (str): path to the urdf. Do not change it unless you know what you are doing. - position (np.array[3]): Cartesian world position. - orientation (np.array[4]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. + position (np.array[float[3]]): Cartesian world position. + orientation (np.array[float[4]]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. fixed_base (bool): if True, the robot base will be fixed in the world. scale (float): scaling factor that is used to scale the robot. """ @@ -206,8 +206,8 @@ class AckermannWheeledRobot(WheeledRobot): Args: simulator (Simulator): simulator instance. urdf (str): path to the urdf. Do not change it unless you know what you are doing. - position (np.array[3]): Cartesian world position. - orientation (np.array[4]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. + position (np.array[float[3]]): Cartesian world position. + orientation (np.array[float[4]]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. fixed_base (bool): if True, the robot base will be fixed in the world. scale (float): scaling factor that is used to scale the robot. """ diff --git a/pyrobolearn/robots/youbot.py b/pyrobolearn/robots/youbot.py index 0cf186b..1fd5388 100644 --- a/pyrobolearn/robots/youbot.py +++ b/pyrobolearn/robots/youbot.py @@ -35,8 +35,8 @@ class YoubotBase(DifferentialWheeledRobot): Args: simulator (Simulator): simulator instance. - position (np.array[3]): Cartesian world position. - orientation (np.array[4]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. + position (np.array[float[3]]): Cartesian world position. + orientation (np.array[float[4]]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. fixed_base (bool): if True, the robot base will be fixed in the world. scale (float): scaling factor that is used to scale the robot. urdf (str): path to the urdf. Do not change it unless you know what you are doing. @@ -73,8 +73,8 @@ class KukaYoubotArm(Manipulator): Args: simulator (Simulator): simulator instance. - position (np.array[3]): Cartesian world position. - orientation (np.array[4]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. + position (np.array[float[3]]): Cartesian world position. + orientation (np.array[float[4]]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. fixed_base (bool): if True, the robot base will be fixed in the world. scale (float): scaling factor that is used to scale the robot. urdf (str): path to the urdf. Do not change it unless you know what you are doing. @@ -107,8 +107,8 @@ class Youbot(Manipulator, DifferentialWheeledRobot): Args: simulator (Simulator): simulator instance. - position (np.array[3]): Cartesian world position. - orientation (np.array[4]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. + position (np.array[float[3]]): Cartesian world position. + orientation (np.array[float[4]]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. fixed_base (bool): if True, the robot base will be fixed in the world. scale (float): scaling factor that is used to scale the robot. urdf (str): path to the urdf. Do not change it unless you know what you are doing. @@ -145,8 +145,8 @@ class YoubotDualArm(BiManipulator, DifferentialWheeledRobot): Args: simulator (Simulator): simulator instance. - position (np.array[3]): Cartesian world position. - orientation (np.array[4]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. + position (np.array[float[3]]): Cartesian world position. + orientation (np.array[float[4]]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. fixed_base (bool): if True, the robot base will be fixed in the world. scale (float): scaling factor that is used to scale the robot. urdf (str): path to the urdf. Do not change it unless you know what you are doing. @@ -183,8 +183,8 @@ class YoubotGripper(ParallelGripper): Args: simulator (Simulator): simulator instance. - position (np.array[3]): Cartesian world position. - orientation (np.array[4]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. + position (np.array[float[3]]): Cartesian world position. + orientation (np.array[float[4]]): Cartesian world orientation expressed as a quaternion [x,y,z,w]. fixed_base (bool): if True, the gripper will be fixed in the world. scale (float): scaling factor that is used to scale the gripper. urdf (str): path to the urdf. Do not change it unless you know what you are doing. diff --git a/pyrobolearn/simulators/bullet.py b/pyrobolearn/simulators/bullet.py index d2e00bc..2d5ea09 100644 --- a/pyrobolearn/simulators/bullet.py +++ b/pyrobolearn/simulators/bullet.py @@ -586,7 +586,7 @@ class Bullet(Simulator): - STATE_LOGGING_PROFILE_TIMINGS (=6): This will dump a timings file in JSON format that can be opened using Google Chrome about://tracing LOAD. filename (str): file name (absolute or relative path) to store the log file data - object_unique_ids (list of int): If left empty, the logger may log every object, otherwise the logger just + object_unique_ids (list[int]): If left empty, the logger may log every object, otherwise the logger just logs the objects in the object_unique_ids list. max_log_dof (int): Maximum number of joint degrees of freedom to log (excluding the base dofs). This applies to STATE_LOGGING_GENERIC_ROBOT_DATA. Default value is 12. If a robot exceeds the number @@ -837,11 +837,11 @@ class Bullet(Simulator): Args: filename (str): path to file for the mesh. Currently, only Wavefront .obj. It will create convex hulls for each object (marked as 'o') in the .obj file. - position (list of 3 float, np.array[3]): position of the mesh in the Cartesian world space (in meters) - orientation (list of 4 float, np.array[4]): orientation of the mesh using quaternion [x,y,z,w]. + position (list[float[3]], np.array[float[3]]): position of the mesh in the Cartesian world space (in meters) + orientation (list[float[4]], np.array[float[4]]): orientation of the mesh using quaternion [x,y,z,w]. mass (float): mass of the mesh (in kg). If mass = 0, it won't move even if there is a collision. - scale (list of 3 float, np.array[3]): scale the mesh in the (x,y,z) directions - color (int[4], None): color of the mesh for red, green, blue, and alpha, each in range [0,1]. + scale (list[float[3]], np.array[float[3]]): scale the mesh in the (x,y,z) directions + color (list[int[4]], None): color of the mesh for red, green, blue, and alpha, each in range [0,1]. with_collision (bool): If True, it will also create the collision mesh, and not only a visual mesh. flags (int, None): if flag = `sim.GEOM_FORCE_CONCAVE_TRIMESH` (=1), this will create a concave static triangle mesh. This should not be used with dynamic/moving objects, only for static (mass=0) terrain. @@ -957,8 +957,8 @@ class Bullet(Simulator): collision_shape_id (int): unique id from createCollisionShape or -1. You can re-use the collision shape for multiple multibodies (instancing) mass (float): mass of the base, in kg (if using SI units) - position (np.array[3]): Cartesian world position of the base - orientation (np.array[4]): Orientation of base as quaternion [x,y,z,w] + position (np.array[float[3]]): Cartesian world position of the base + orientation (np.array[float[4]]): Orientation of base as quaternion [x,y,z,w] Returns: int: non-negative unique id or -1 for failure. @@ -1045,13 +1045,13 @@ class Bullet(Simulator): (which should really be called spherical), the child body's link will be able to rotate along the 3 axis while maintaining the given position relative to the parent body's link. If the JOINT_GEAR can be set between two links of the same body. - joint_axis (np.array[3]): joint axis, in child link frame - parent_frame_position (np.array[3]): position of the joint frame relative to parent CoM frame. - child_frame_position (np.array[3]): position of the joint frame relative to a given child CoM frame (or - world origin if no child specified) - parent_frame_orientation (np.array[4]): the orientation of the joint frame relative to parent CoM + joint_axis (np.array[float[3]]): joint axis, in child link frame + parent_frame_position (np.array[float[3]]): position of the joint frame relative to parent CoM frame. + child_frame_position (np.array[float[3]]): position of the joint frame relative to a given child CoM frame + (or world origin if no child specified) + parent_frame_orientation (np.array[float[4]]): the orientation of the joint frame relative to parent CoM coordinate frame - child_frame_orientation (np.array[4]): the orientation of the joint frame relative to the child CoM + child_frame_orientation (np.array[float[4]]): the orientation of the joint frame relative to the child CoM coordinate frame (or world origin frame if no child specified) Examples: @@ -1082,9 +1082,9 @@ class Bullet(Simulator): Args: constraint_id (int): constraint unique id. - child_joint_pivot (np.array[3]): updated position of the joint frame relative to a given child CoM frame - (or world origin if no child specified) - child_frame_orientation (np.array[4]): updated child frame orientation as quaternion [x,y,z,w] + child_joint_pivot (np.array[float[3]]): updated position of the joint frame relative to a given child CoM + frame (or world origin if no child specified) + child_frame_orientation (np.array[float[4]]): updated child frame orientation as quaternion [x,y,z,w] max_force (float): maximum force that constraint can apply gear_ratio (float): the ratio between the rates at which the two gears rotate gear_auxiliary_link (int): In some cases, such as a differential drive, a third (auxilary) link is used as @@ -1144,11 +1144,13 @@ class Bullet(Simulator): int: child_body_id (if -1, no body; specify a non-dynamic child frame in world coordinates) int: child_link_id (if -1, it is the base) int: constraint/joint type - np.array[3]: joint axis - np.array[3]: joint pivot (position) in parent CoM frame - np.array[3]: joint pivot (position) in specified child CoM frame (or world frame if no specified child) - np.array[4]: joint frame orientation relative to parent CoM coordinate frame - np.array[4]: joint frame orientation relative to child CoM frame (or world frame if no specified child) + np.array[float[3]]: joint axis + np.array[float[3]]: joint pivot (position) in parent CoM frame + np.array[float[3]]: joint pivot (position) in specified child CoM frame (or world frame if no specified + child) + np.array[float[4]]: joint frame orientation relative to parent CoM coordinate frame + np.array[float[4]]: joint frame orientation relative to child CoM frame (or world frame if no specified + child) float: maximum force that constraint can apply """ return self.sim.getConstraintInfo(constraint_id) @@ -1161,7 +1163,7 @@ class Bullet(Simulator): constraint_id (int): constraint unique id. Returns: - np.array[D]: applied constraint forces. Its dimension is the degrees of freedom that are affected by + list[float[D]]: applied constraint forces. Its dimension is the degrees of freedom that are affected by the constraint (a fixed constraint affects 6 DoF for example) """ return self.sim.getConstraintState(constraint_id) @@ -1210,11 +1212,11 @@ class Bullet(Simulator): Args: body_id (int): unique body id. - link_ids (list of int): link ids associated with the given body id. If None, it will take all the links + link_ids (list[int]): link ids associated with the given body id. If None, it will take all the links of the specified body. Returns: - np.array[3]: center of mass position in the Cartesian world coordinates + np.array[float[3]]: center of mass position in the Cartesian world coordinates """ if link_ids is None: link_ids = list(range(self.num_links(body_id))) @@ -1231,11 +1233,11 @@ class Bullet(Simulator): Args: body_id (int): unique body id. - link_ids (list of int): link ids associated with the given body id. If None, it will take all the links + link_ids (list[int]): link ids associated with the given body id. If None, it will take all the links of the specified body. Returns: - np.array[3]: center of mass linear velocity. + np.array[float[3]]: center of mass linear velocity. """ if link_ids is None: link_ids = list(range(self.num_links(body_id))) @@ -1251,7 +1253,7 @@ class Bullet(Simulator): Return the total linear momentum in the world space. Returns: - np.array[3]: linear momentum + np.array[float[3]]: linear momentum """ if link_ids is None: link_ids = list(range(self.num_links(body_id))) @@ -1267,8 +1269,8 @@ class Bullet(Simulator): body_id (int): object unique id, as returned from `load_urdf`. Returns: - np.array[3]: base position - np.array[4]: base orientation (quaternion [x,y,z,w]) + np.array[float[3]]: base position + np.array[float[4]]: base orientation (quaternion [x,y,z,w]) """ pos, orientation = self.sim.getBasePositionAndOrientation(body_id) return np.asarray(pos), np.asarray(orientation) @@ -1281,7 +1283,7 @@ class Bullet(Simulator): body_id (int): object unique id, as returned from `load_urdf`. Returns: - np.array[3]: base position. + np.array[float[3]]: base position. """ return self.get_base_pose(body_id)[0] @@ -1293,7 +1295,7 @@ class Bullet(Simulator): body_id (int): object unique id, as returned from `load_urdf`. Returns: - np.array[4]: base orientation in the form of a quaternion (x,y,z,w) + np.array[float[4]]: base orientation in the form of a quaternion (x,y,z,w) """ return self.get_base_pose(body_id)[1] @@ -1307,8 +1309,8 @@ class Bullet(Simulator): Args: body_id (int): unique object id. - position (np.array[3]): new base position. - orientation (np.array[4]): new base orientation (expressed as a quaternion [x,y,z,w]) + position (np.array[float[3]]): new base position. + orientation (np.array[float[4]]): new base orientation (expressed as a quaternion [x,y,z,w]) """ self.sim.resetBasePositionAndOrientation(body_id, position, orientation) @@ -1318,7 +1320,7 @@ class Bullet(Simulator): Args: body_id (int): unique object id. - position (np.array[3]): new base position. + position (np.array[float[3]]): new base position. """ orientation = self.get_base_orientation(body_id) self.reset_base_pose(body_id, position, orientation) @@ -1329,7 +1331,7 @@ class Bullet(Simulator): Args: body_id (int): unique object id. - orientation (np.array[4]): new base orientation (expressed as a quaternion [x,y,z,w]) + orientation (np.array[float[4]]): new base orientation (expressed as a quaternion [x,y,z,w]) """ position = self.get_base_position(body_id) self.reset_base_pose(body_id, position, orientation) @@ -1342,8 +1344,8 @@ class Bullet(Simulator): body_id (int): object unique id, as returned from `load_urdf`. Returns: - np.array[3]: linear velocity of the base in Cartesian world space coordinates - np.array[3]: angular velocity of the base in Cartesian world space coordinates + np.array[float[3]]: linear velocity of the base in Cartesian world space coordinates + np.array[float[3]]: angular velocity of the base in Cartesian world space coordinates """ lin_vel, ang_vel = self.sim.getBaseVelocity(body_id) return np.asarray(lin_vel), np.asarray(ang_vel) @@ -1356,7 +1358,7 @@ class Bullet(Simulator): body_id (int): object unique id, as returned from `load_urdf`. Returns: - np.array[3]: linear velocity of the base in Cartesian world space coordinates + np.array[float[3]]: linear velocity of the base in Cartesian world space coordinates """ return self.get_base_velocity(body_id)[0] @@ -1368,7 +1370,7 @@ class Bullet(Simulator): body_id (int): object unique id, as returned from `load_urdf`. Returns: - np.array[3]: angular velocity of the base in Cartesian world space coordinates + np.array[float[3]]: angular velocity of the base in Cartesian world space coordinates """ return self.get_base_velocity(body_id)[1] @@ -1378,8 +1380,8 @@ class Bullet(Simulator): Args: body_id (int): unique object id. - linear_velocity (np.array[3]): new linear velocity of the base. - angular_velocity (np.array[3]): new angular velocity of the base. + linear_velocity (np.array[float[3]]): new linear velocity of the base. + angular_velocity (np.array[float[3]]): new angular velocity of the base. """ if linear_velocity is not None and angular_velocity is not None: self.sim.resetBaseVelocity(body_id, linearVelocity=linear_velocity, angularVelocity=angular_velocity) @@ -1394,7 +1396,7 @@ class Bullet(Simulator): Args: body_id (int): unique object id. - linear_velocity (np.array[3]): new linear velocity of the base + linear_velocity (np.array[float[3]]): new linear velocity of the base """ self.sim.resetBaseVelocity(body_id, linearVelocity=linear_velocity) @@ -1404,7 +1406,7 @@ class Bullet(Simulator): Args: body_id (int): unique object id. - angular_velocity (np.array[3]): new angular velocity of the base + angular_velocity (np.array[float[3]]): new angular velocity of the base """ self.sim.resetBaseVelocity(body_id, angularVelocity=angular_velocity) @@ -1420,9 +1422,9 @@ class Bullet(Simulator): Args: body_id (int): unique body id. link_id (int): unique link id. If -1, it will be the base. - force (np.array[3]): external force to be applied. - position (np.array[3], None): position on the link where the force is applied. See `flags` for coordinate - systems. If None, it is the center of mass of the body (or the link if specified). + force (np.array[float[3]]): external force to be applied. + position (np.array[float[3]], None): position on the link where the force is applied. See `flags` for + coordinate systems. If None, it is the center of mass of the body (or the link if specified). frame (int): Specify the coordinate system of force/position: either `pybullet.WORLD_FRAME` (=2) for Cartesian world coordinates or `pybullet.LINK_FRAME` (=1) for local link coordinates. """ @@ -1529,9 +1531,9 @@ class Bullet(Simulator): [11] float: maximum velocity specified in URDF. Note that this value is not used in actual motor control commands at the moment. [12] str: name of the link (as specified in the URDF/SDF/etc file) - [13] np.array[3]: joint axis in local frame (ignored for JOINT_FIXED) - [14] np.array[3]: joint position in parent frame - [15] np.array[4]: joint orientation in parent frame + [13] np.array[float[3]]: joint axis in local frame (ignored for JOINT_FIXED) + [14] np.array[float[3]]: joint position in parent frame + [15] np.array[float[4]]: joint orientation in parent frame [16] int: parent link index, -1 for base """ info = list(self.sim.getJointInfo(body_id, joint_id)) @@ -1553,7 +1555,7 @@ class Bullet(Simulator): Returns: float: The position value of this joint. float: The velocity value of this joint. - np.array[6]: These are the joint reaction forces, if a torque sensor is enabled for this joint it is + np.array[float[6]]: These are the joint reaction forces, if a torque sensor is enabled for this joint it is [Fx, Fy, Fz, Mx, My, Mz]. Without torque sensor, it is [0, 0, 0, 0, 0, 0]. float: This is the motor torque applied during the last stepSimulation. Note that this only applies in VELOCITY_CONTROL and POSITION_CONTROL. If you use TORQUE_CONTROL then the applied joint motor torque @@ -1568,14 +1570,14 @@ class Bullet(Simulator): Args: body_id (int): body unique id. - joint_ids (list of int): list of joint ids. + joint_ids (list[int]): list of joint ids. Returns: list: float: The position value of this joint. float: The velocity value of this joint. - np.array[6]: These are the joint reaction forces, if a torque sensor is enabled for this joint it is - [Fx, Fy, Fz, Mx, My, Mz]. Without torque sensor, it is [0, 0, 0, 0, 0, 0]. + np.array[float[6]]: These are the joint reaction forces, if a torque sensor is enabled for this joint + it is [Fx, Fy, Fz, Mx, My, Mz]. Without torque sensor, it is [0, 0, 0, 0, 0, 0]. float: This is the motor torque applied during the last `step`. Note that this only applies in VELOCITY_CONTROL and POSITION_CONTROL. If you use TORQUE_CONTROL then the applied joint motor torque is exactly what you provide, so there is no need to report it separately. @@ -1646,17 +1648,17 @@ class Bullet(Simulator): joint_ids ((list of) int): joint/link id, or list of joint ids. control_mode (int): POSITION_CONTROL (=2) (which is in fact CONTROL_MODE_POSITION_VELOCITY_PD), VELOCITY_CONTROL (=0), TORQUE_CONTROL (=1) and PD_CONTROL (=3). - positions (float, np.array[N]): target joint position(s) (used in POSITION_CONTROL). - velocities (float, np.array[N]): target joint velocity(ies). In VELOCITY_CONTROL and POSITION_CONTROL, - the target velocity(ies) is(are) the desired velocity of the joint. Note that the target velocity(ies) - is(are) not the maximum joint velocity(ies). In PD_CONTROL and + positions (float, np.array[float[N]]): target joint position(s) (used in POSITION_CONTROL). + velocities (float, np.array[float[N]]): target joint velocity(ies). In VELOCITY_CONTROL and + POSITION_CONTROL, the target velocity(ies) is(are) the desired velocity of the joint. Note that the + target velocity(ies) is(are) not the maximum joint velocity(ies). In PD_CONTROL and POSITION_CONTROL/CONTROL_MODE_POSITION_VELOCITY_PD, the final target velocities are computed using: `kp*(erp*(desiredPosition-currentPosition)/dt)+currentVelocity+kd*(m_desiredVelocity - currentVelocity)` - forces (float, list of float): in POSITION_CONTROL and VELOCITY_CONTROL, these are the maximum motor + forces (float, list[float]): in POSITION_CONTROL and VELOCITY_CONTROL, these are the maximum motor forces used to reach the target values. In TORQUE_CONTROL these are the forces / torques to be applied each simulation step. - kp (float, list of float): position (stiffness) gain(s) (used in POSITION_CONTROL). - kd (float, list of float): velocity (damping) gain(s) (used in POSITION_CONTROL). + kp (float, list[float]): position (stiffness) gain(s) (used in POSITION_CONTROL). + kd (float, list[float]): velocity (damping) gain(s) (used in POSITION_CONTROL). max_velocity (float): in POSITION_CONTROL this limits the velocity to a maximum. """ kwargs = {} @@ -1705,15 +1707,16 @@ class Bullet(Simulator): using forward kinematics. Returns: - np.array[3]: Cartesian world position of CoM - np.array[4]: Cartesian world orientation of CoM, in quaternion [x,y,z,w] - np.array[3]: local position offset of inertial frame (center of mass) expressed in the URDF link frame - np.array[4]: local orientation (quaternion [x,y,z,w]) offset of the inertial frame expressed in URDF link - frame - np.array[3]: world position of the URDF link frame - np.array[4]: world orientation of the URDF link frame (expressed as a quaternion [x,y,z,w]) - np.array[3]: Cartesian world linear velocity. Only returned if `compute_velocity` is True. - np.array[3]: Cartesian world angular velocity. Only returned if `compute_velocity` is True. + np.array[float[3]]: Cartesian world position of CoM + np.array[float[4]]: Cartesian world orientation of CoM, in quaternion [x,y,z,w] + np.array[float[3]]: local position offset of inertial frame (center of mass) expressed in the URDF + link frame + np.array[float[4]]: local orientation (quaternion [x,y,z,w]) offset of the inertial frame expressed in URDF + link frame + np.array[float[3]]: world position of the URDF link frame + np.array[float[4]]: world orientation of the URDF link frame (expressed as a quaternion [x,y,z,w]) + np.array[float[3]]: Cartesian world linear velocity. Only returned if `compute_velocity` is True. + np.array[float[3]]: Cartesian world angular velocity. Only returned if `compute_velocity` is True. """ results = self.sim.getLinkState(body_id, link_id, computeLinkVelocity=int(compute_velocity), computeForwardKinematics=int(compute_forward_kinematics)) @@ -1725,22 +1728,23 @@ class Bullet(Simulator): Args: body_id (int): body unique id. - link_ids (list of int): list of link index. + link_ids (list[int]): list of link index. compute_velocity (bool): If True, the Cartesian world velocity will be computed and returned. compute_forward_kinematics (bool): if True, the Cartesian world position/orientation will be recomputed using forward kinematics. Returns: list: - np.array[3]: Cartesian position of CoM - np.array[4]: Cartesian orientation of CoM, in quaternion [x,y,z,w] - np.array[3]: local position offset of inertial frame (center of mass) expressed in the URDF link frame - np.array[4]: local orientation (quaternion [x,y,z,w]) offset of the inertial frame expressed in URDF + np.array[float[3]]: Cartesian position of CoM + np.array[float[4]]: Cartesian orientation of CoM, in quaternion [x,y,z,w] + np.array[float[3]]: local position offset of inertial frame (center of mass) expressed in the URDF link frame - np.array[3]: world position of the URDF link frame - np.array[4]: world orientation of the URDF link frame - np.array[3]: Cartesian world linear velocity. Only returned if `compute_velocity` is True. - np.array[3]: Cartesian world angular velocity. Only returned if `compute_velocity` is True. + np.array[float[4]]: local orientation (quaternion [x,y,z,w]) offset of the inertial frame expressed in + URDF link frame + np.array[float[3]]: world position of the URDF link frame + np.array[float[4]]: world orientation of the URDF link frame + np.array[float[3]]: Cartesian world linear velocity. Only returned if `compute_velocity` is True. + np.array[float[3]]: Cartesian world angular velocity. Only returned if `compute_velocity` is True. """ return [self.get_link_state(body_id, link_id, compute_velocity, compute_forward_kinematics) for link_id in link_ids] @@ -1751,7 +1755,7 @@ class Bullet(Simulator): Args: body_id (int): unique body id. - link_ids (int, list of int): link id, or list of link ids. + link_ids (int, list[int]): link id, or list of link ids. Returns: if 1 link: @@ -1782,7 +1786,7 @@ class Bullet(Simulator): Args: body_id (int): unique body id. - link_ids (int, list of int): link id, or list of link ids. + link_ids (int, list[int]): link id, or list of link ids. Returns: if 1 link: @@ -1804,11 +1808,11 @@ class Bullet(Simulator): Returns: if 1 link: - np.array[3]: the link frame position in the world space - np.array[4]: Cartesian orientation of the link frame [x,y,z,w] + np.array[float[3]]: the link frame position in the world space + np.array[float[4]]: Cartesian orientation of the link frame [x,y,z,w] if multiple links: - np.array[N, 3]: link frame position of each link in world space - np.array[N, 4]: orientation of each link frame [x,y,z,w] + np.array[float[N,3]]: link frame position of each link in world space + np.array[float[N,4]]: orientation of each link frame [x,y,z,w] """ if isinstance(link_ids, int): if link_ids == -1: @@ -1830,13 +1834,13 @@ class Bullet(Simulator): Args: body_id (int): unique body id. - link_ids (list of int): list of link indices. + link_ids (list[int]): list of link indices. Returns: if 1 link: - np.array[3]: the link CoM position in the world space + np.array[float[3]]: the link CoM position in the world space if multiple links: - np.array[N,3]: CoM position of each link in world space + np.array[float[N,3]]: CoM position of each link in world space """ if isinstance(link_ids, int): if link_ids == -1: @@ -1859,13 +1863,13 @@ class Bullet(Simulator): Args: body_id (int): unique body id. - link_ids (list of int): list of link indices. + link_ids (list[int]): list of link indices. Returns: if 1 link: - np.array[4]: Cartesian orientation of the link CoM (x,y,z,w) + np.array[float[4]]: Cartesian orientation of the link CoM (x,y,z,w) if multiple links: - np.array[N,4]: CoM orientation of each link (x,y,z,w) + np.array[float[N,4]]: CoM orientation of each link (x,y,z,w) """ if isinstance(link_ids, int): if link_ids == -1: @@ -1888,13 +1892,13 @@ class Bullet(Simulator): Args: body_id (int): unique body id. - link_ids (list of int): list of link indices. + link_ids (list[int]): list of link indices. Returns: if 1 link: - np.array[3]: linear velocity of the link in the Cartesian world space + np.array[float[3]]: linear velocity of the link in the Cartesian world space if multiple links: - np.array[N,3]: linear velocity of each link + np.array[float[N,3]]: linear velocity of each link """ if isinstance(link_ids, int): if link_ids == -1: @@ -1914,13 +1918,13 @@ class Bullet(Simulator): Args: body_id (int): unique body id. - link_ids (list of int): list of link indices. + link_ids (list[int]): list of link indices. Returns: if 1 link: - np.array[3]: angular velocity of the link in the Cartesian world space + np.array[float[3]]: angular velocity of the link in the Cartesian world space if multiple links: - np.array[N,3]: angular velocity of each link + np.array[float[N,3]]: angular velocity of each link """ if isinstance(link_ids, int): if link_ids == -1: @@ -1941,13 +1945,13 @@ class Bullet(Simulator): Args: body_id (int): unique body id. - link_ids (list of int): list of link indices. + link_ids (list[int]): list of link indices. Returns: if 1 link: - np.array[6]: linear and angular velocity of the link in the Cartesian world space + np.array[float[6]]: linear and angular velocity of the link in the Cartesian world space if multiple links: - np.array[N,6]: linear and angular velocity of each link + np.array[float[N,6]]: linear and angular velocity of each link """ if isinstance(link_ids, int): if link_ids == -1: @@ -1973,13 +1977,13 @@ class Bullet(Simulator): Args: body_id (int): unique body id. - joint_ids (int, list of int): a joint id, or list of joint ids. + joint_ids (int, list[int]): a joint id, or list of joint ids. Returns: if 1 joint: int: q index if multiple joints: - np.int[N]: q indices + np.array[int[N]]: q indices """ if isinstance(joint_ids, int): return self.sim.getJointInfo(body_id, joint_ids)[3] - 7 @@ -1996,7 +2000,7 @@ class Bullet(Simulator): body_id (int): unique body id. Returns: - list of int: actuated joint ids. + list[int]: actuated joint ids. """ joint_ids = [] for joint_id in range(self.num_joints(body_id)): @@ -2012,7 +2016,7 @@ class Bullet(Simulator): Args: body_id (int): unique body id. - joint_ids (int, list of int): a joint id, or list of joint ids. + joint_ids (int, list[int]): a joint id, or list of joint ids. Returns: if 1 joint: @@ -2038,7 +2042,7 @@ class Bullet(Simulator): Args: body_id (int): unique body id. - joint_ids (int, list of int): a joint id, or list of joint ids. + joint_ids (int, list[int]): a joint id, or list of joint ids. Returns: if 1 joint: @@ -2055,7 +2059,7 @@ class Bullet(Simulator): Args: body_id (int): unique body id. - joint_ids (int, list of int): a joint id, or list of joint ids. + joint_ids (int, list[int]): a joint id, or list of joint ids. Returns: if 1 joint: @@ -2073,13 +2077,13 @@ class Bullet(Simulator): Args: body_id (int): unique body id. - joint_ids (int, list of int): a joint id, or list of joint ids. + joint_ids (int, list[int]): a joint id, or list of joint ids. Returns: if 1 joint: float: damping coefficient of the given joint if multiple joints: - np.array[N]: damping coefficient for each specified joint + np.array[float[N]]: damping coefficient for each specified joint """ if isinstance(joint_ids, int): return self.sim.getJointInfo(body_id, joint_ids)[6] @@ -2091,13 +2095,13 @@ class Bullet(Simulator): Args: body_id (int): unique body id. - joint_ids (int, list of int): a joint id, or list of joint ids. + joint_ids (int, list[int]): a joint id, or list of joint ids. Returns: if 1 joint: float: friction coefficient of the given joint if multiple joints: - np.array[N]: friction coefficient for each specified joint + np.array[float[N]]: friction coefficient for each specified joint """ if isinstance(joint_ids, int): return self.sim.getJointInfo(body_id, joint_ids)[7] @@ -2109,13 +2113,13 @@ class Bullet(Simulator): Args: body_id (int): unique body id. - joint_ids (int, list of int): a joint id, or list of joint ids. + joint_ids (int, list[int]): a joint id, or list of joint ids. Returns: if 1 joint: - np.array[2]: lower and upper limit + np.array[float[2]]: lower and upper limit if multiple joints: - np.array[N,2]: lower and upper limit for each specified joint + np.array[float[N,2]]: lower and upper limit for each specified joint """ if isinstance(joint_ids, int): return np.asarray(self.sim.getJointInfo(body_id, joint_ids)[8:10]) @@ -2129,13 +2133,13 @@ class Bullet(Simulator): Args: body_id (int): unique body id. - joint_ids (int, list of int): a joint id, or list of joint ids. + joint_ids (int, list[int]): a joint id, or list of joint ids. Returns: if 1 joint: float: maximum force [N] if multiple joints: - np.array[N]: maximum force for each specified joint [N] + np.array[float[N]]: maximum force for each specified joint [N] """ if isinstance(joint_ids, int): return self.sim.getJointInfo(body_id, joint_ids)[10] @@ -2149,13 +2153,13 @@ class Bullet(Simulator): Args: body_id (int): unique body id. - joint_ids (int, list of int): a joint id, or list of joint ids. + joint_ids (int, list[int]): a joint id, or list of joint ids. Returns: if 1 joint: float: maximum velocity [rad/s] if multiple joints: - np.array[N]: maximum velocities for each specified joint [rad/s] + np.array[float[N]]: maximum velocities for each specified joint [rad/s] """ if isinstance(joint_ids, int): return self.sim.getJointInfo(body_id, joint_ids)[11] @@ -2167,13 +2171,13 @@ class Bullet(Simulator): Args: body_id (int): unique body id. - joint_ids (int, list of int): a joint id, or list of joint ids. + joint_ids (int, list[int]): a joint id, or list of joint ids. Returns: if 1 joint: - np.array[3]: joint axis + np.array[float[3]]: joint axis if multiple joint: - np.array[N,3]: list of joint axis + np.array[float[N,3]]: list of joint axis """ if isinstance(joint_ids, int): return np.asarray(self.sim.getJointInfo(body_id, joint_ids)[-4]) @@ -2185,12 +2189,12 @@ class Bullet(Simulator): Args: body_id (int): unique body id. - joint_ids (int, list of int): joint id, or list of joint ids. - positions (float, np.array[N]): desired position, or list of desired positions [rad] - velocities (None, float, np.array[N]): desired velocity, or list of desired velocities [rad/s] - kps (None, float, np.array[N]): position gain(s) - kds (None, float, np.array[N]): velocity gain(s) - forces (None, float, np.array[N]): maximum motor force(s)/torque(s) used to reach the target values. + joint_ids (int, list[int]): joint id, or list of joint ids. + positions (float, np.array[float[N]]): desired position, or list of desired positions [rad] + velocities (None, float, np.array[float[N]]): desired velocity, or list of desired velocities [rad/s] + kps (None, float, np.array[float[N]]): position gain(s) + kds (None, float, np.array[float[N]]): velocity gain(s) + forces (None, float, np.array[float[N]]): maximum motor force(s)/torque(s) used to reach the target values. """ self.set_joint_motor_control(body_id, joint_ids, control_mode=pybullet.POSITION_CONTROL, positions=positions, velocities=velocities, forces=forces, kp=kps, kd=kds) @@ -2201,13 +2205,13 @@ class Bullet(Simulator): Args: body_id (int): unique body id. - joint_ids (int, list of int): joint id, or list of joint ids. + joint_ids (int, list[int]): joint id, or list of joint ids. Returns: if 1 joint: float: joint position [rad] if multiple joints: - np.array[N]: joint positions [rad] + np.array[float[N]]: joint positions [rad] """ if isinstance(joint_ids, int): return self.sim.getJointState(body_id, joint_ids)[0] @@ -2219,9 +2223,9 @@ class Bullet(Simulator): Args: body_id (int): unique body id. - joint_ids (int, list of int): joint id, or list of joint ids. - velocities (float, np.array[N]): desired velocity, or list of desired velocities [rad/s] - max_force (None, float, np.array[N]): maximum motor forces/torques + joint_ids (int, list[int]): joint id, or list of joint ids. + velocities (float, np.array[float[N]]): desired velocity, or list of desired velocities [rad/s] + max_force (None, float, np.array[float[N]]): maximum motor forces/torques """ if isinstance(joint_ids, int): if max_force is None: @@ -2240,13 +2244,13 @@ class Bullet(Simulator): Args: body_id (int): unique body id. - joint_ids (int, list of int): joint id, or list of joint ids. + joint_ids (int, list[int]): joint id, or list of joint ids. Returns: if 1 joint: float: joint velocity [rad/s] if multiple joints: - np.array[N]: joint velocities [rad/s] + np.array[float[N]]: joint velocities [rad/s] """ if isinstance(joint_ids, int): return self.sim.getJointState(body_id, joint_ids)[1] @@ -2259,11 +2263,11 @@ class Bullet(Simulator): Args: body_id (int): unique body id. - joint_ids (int, list of int): joint id, or list of joint ids. - accelerations (float, np.array[N]): desired joint acceleration, or list of desired joint accelerations - [rad/s^2] - q (None, list of float, float): current joint positions. - dq (None, list of float, float): current joint velocities. + joint_ids (int, list[int]): joint id, or list of joint ids. + accelerations (float, np.array[float[N]]): desired joint acceleration, or list of desired joint + accelerations [rad/s^2] + q (None, list[float], float): current joint positions. + dq (None, list[float], float): current joint velocities. """ # check joint ids if isinstance(joint_ids, int): @@ -2309,15 +2313,15 @@ class Bullet(Simulator): # # Args: # body_id (int): unique body id. - # joint_ids (int, list of int): joint id, or list of joint ids. - # q (list of int, None): all the joint positions. If None, it will compute it. - # dq (list of int, None): all the joint velocities. If None, it will compute it. + # joint_ids (int, list[int]): joint id, or list of joint ids. + # q (list[int], None): all the joint positions. If None, it will compute it. + # dq (list[int], None): all the joint velocities. If None, it will compute it. # # Returns: # if 1 joint: # float: joint acceleration [rad/s^2] # if multiple joints: - # np.array[N]: joint accelerations [rad/s^2] + # np.array[float[N]]: joint accelerations [rad/s^2] # """ # # get the torques # torques = self.get_joint_torques(body_id, joint_ids) @@ -2343,8 +2347,8 @@ class Bullet(Simulator): Args: body_id (int): unique body id. - joint_ids (int, list of int): joint id, or list of joint ids. - torques (float, list of float): desired torque(s) to apply to the joint(s) [N]. + joint_ids (int, list[int]): joint id, or list of joint ids. + torques (float, list[float]): desired torque(s) to apply to the joint(s) [N]. """ if isinstance(joint_ids, int): self.sim.setJointMotorControl2(body_id, joint_ids, self.sim.TORQUE_CONTROL, force=torques) @@ -2358,13 +2362,13 @@ class Bullet(Simulator): Args: body_id (int): unique body id. - joint_ids (int, list of int): a joint id, or list of joint ids. + joint_ids (int, list[int]): a joint id, or list of joint ids. Returns: if 1 joint: float: torque [Nm] if multiple joints: - np.array[N]: torques associated to the given joints [Nm] + np.array[float[N]]: torques associated to the given joints [Nm] """ if isinstance(joint_ids, int): return self.sim.getJointState(body_id, joint_ids)[3] @@ -2381,9 +2385,9 @@ class Bullet(Simulator): Returns: if 1 joint: - np.array[6]: joint reaction force (fx,fy,fz,mx,my,mz) [N,Nm] + np.array[float[6]]: joint reaction force (fx,fy,fz,mx,my,mz) [N,Nm] if multiple joints: - np.array[N,6]: joint reaction forces [N, Nm] + np.array[float[N,6]]: joint reaction forces [N, Nm] """ if isinstance(joint_ids, int): return np.asarray(self.sim.getJointState(body_id, joint_ids)[2]) @@ -2401,7 +2405,7 @@ class Bullet(Simulator): if 1 joint: float: joint power [W] if multiple joints: - np.array[N]: power at each joint [W] + np.array[float[N]]: power at each joint [W] """ torque = self.get_joint_torques(body_id, joint_ids) velocity = self.get_joint_velocities(body_id, joint_ids) @@ -2422,25 +2426,26 @@ class Bullet(Simulator): shape_type (int): type of shape; GEOM_SPHERE (=2), GEOM_BOX (=3), GEOM_CAPSULE (=7), GEOM_CYLINDER (=4), GEOM_PLANE (=6), GEOM_MESH (=5) radius (float): only for GEOM_SPHERE, GEOM_CAPSULE, GEOM_CYLINDER - half_extents (np.array[3], list/tuple of 3 floats): only for GEOM_BOX. + half_extents (np.array[float[3]], list/tuple of 3 floats): only for GEOM_BOX. length (float): only for GEOM_CAPSULE, GEOM_CYLINDER (length = height). filename (str): Filename for GEOM_MESH, currently only Wavefront .obj. Will create convex hulls for each object (marked as 'o') in the .obj file. - mesh_scale (np.array[3], list/tuple of 3 floats): scale of mesh (only for GEOM_MESH). - plane_normal (np.array[3], list/tuple of 3 floats): plane normal (only for GEOM_PLANE). + mesh_scale (np.array[float[3]], list/tuple of 3 floats): scale of mesh (only for GEOM_MESH). + plane_normal (np.array[float[3]], list/tuple of 3 floats): plane normal (only for GEOM_PLANE). flags (int): unused / to be decided rgba_color (list/tuple of 4 floats): color components for red, green, blue and alpha, each in range [0..1]. specular_color (list/tuple of 3 floats): specular reflection color, red, green, blue components in range [0..1] - visual_frame_position (np.array[3]): translational offset of the visual shape with respect to the link frame - vertices (list of np.array[3]): Instead of creating a mesh from obj file, you can provide vertices, indices, - uvs and normals - indices (list of int): triangle indices, should be a multiple of 3. + visual_frame_position (np.array[float[3]]): translational offset of the visual shape with respect to the + link frame + vertices (list of np.array[float[3]]): Instead of creating a mesh from obj file, you can provide vertices, + indices, uvs and normals + indices (list[int]): triangle indices, should be a multiple of 3. uvs (list of np.array[2]): uv texture coordinates for vertices. Use changeVisualShape to choose the texture image. The number of uvs should be equal to number of vertices - normals (list of np.array[3]): vertex normals, number should be equal to number of vertices. - visual_frame_orientation (np.array[4]): rotational offset (quaternion x,y,z,w) of the visual shape with - respect to the link frame + normals (list of np.array[float[3]]): vertex normals, number should be equal to number of vertices. + visual_frame_orientation (np.array[float[4]]): rotational offset (quaternion x,y,z,w) of the visual shape + with respect to the link frame Returns: int: The return value is a non-negative int unique id for the visual shape or -1 if the call failed. @@ -2493,12 +2498,12 @@ class Bullet(Simulator): int: object unique id. int: link index or -1 for the base int: visual geometry type (TBD) - np.array[3]: dimensions (size, local scale) of the geometry + np.array[float[3]]: dimensions (size, local scale) of the geometry str: path to the triangle mesh, if any. Typically relative to the URDF, SDF or MJCF file location, but could be absolute - np.array[3]: position of local visual frame, relative to link/joint frame - np.array[4]: orientation of local visual frame relative to link/joint frame - list of 4 floats: URDF color (if any specified) in Red / Green / Blue / Alpha + np.array[float[3]]: position of local visual frame, relative to link/joint frame + np.array[float[4]]: orientation of local visual frame relative to link/joint frame + list[float[4]]: URDF color (if any specified) in Red / Green / Blue / Alpha int: texture unique id of the shape or -1 if None. This field only exists if using VISUAL_SHAPE_DATA_TEXTURE_UNIQUE_IDS (=1) flag. """ @@ -2557,12 +2562,12 @@ class Bullet(Simulator): of turning the camera to capture what we want in the world, we keep the camera fixed and turn the world. Args: - eye_position (np.array[3]): eye position in Cartesian world coordinates - target_position (np.array[3]): position of the target (focus) point in Cartesian world coordinates - up_vector (np.array[3]): up vector of the camera in Cartesian world coordinates + eye_position (np.array[float[3]]): eye position in Cartesian world coordinates + target_position (np.array[float[3]]): position of the target (focus) point in Cartesian world coordinates + up_vector (np.array[float[3]]): up vector of the camera in Cartesian world coordinates Returns: - np.array[4,4]: the view matrix + np.array[float[4,4]]: the view matrix More info: [1] http://www.codinglabs.net/article_world_view_projection_matrix.aspx @@ -2580,7 +2585,7 @@ class Bullet(Simulator): of turning the camera to capture what we want in the world, we keep the camera fixed and turn the world. Args: - target_position (np.array[3]): target focus point in Cartesian world coordinates + target_position (np.array[float[3]]): target focus point in Cartesian world coordinates distance (float): distance from eye to focus point yaw (float): yaw angle in radians left/right around up-axis pitch (float): pitch in radians up/down. @@ -2588,7 +2593,7 @@ class Bullet(Simulator): up_axis_index (int): either 1 for Y or 2 for Z axis up. Returns: - np.array[4,4]: the view matrix + np.array[float[4,4]]: the view matrix More info: [1] http://www.codinglabs.net/article_world_view_projection_matrix.aspx @@ -2620,7 +2625,7 @@ class Bullet(Simulator): far (float): far plane distance Returns: - np.array[4,4]: the perspective projection matrix + np.array[float[4,4]]: the perspective projection matrix More info: [1] http://www.codinglabs.net/article_world_view_projection_matrix.aspx @@ -2639,7 +2644,7 @@ class Bullet(Simulator): far (float): far plane distance Returns: - np.array[4,4]: the perspective projection matrix + np.array[float[4,4]]: the perspective projection matrix More info: [1] http://www.codinglabs.net/article_world_view_projection_matrix.aspx @@ -2663,11 +2668,11 @@ class Bullet(Simulator): Args: width (int): horizontal image resolution in pixels height (int): vertical image resolution in pixels - view_matrix (np.array[4,4]): 4x4 view matrix, see `compute_view_matrix` - projection_matrix (np.array[4,4]): 4x4 projection matrix, see `compute_projection` - light_direction (np.array[3]): `light_direction` specifies the world position of the light source, + view_matrix (np.array[float[4,4]]): 4x4 view matrix, see `compute_view_matrix` + projection_matrix (np.array[float[4,4]]): 4x4 projection matrix, see `compute_projection` + light_direction (np.array[float[3]]): `light_direction` specifies the world position of the light source, the direction is from the light source position to the origin of the world frame. - light_color (np.array[3]): directional light color in [RED,GREEN,BLUE] in range 0..1 + light_color (np.array[float[3]]): directional light color in [RED,GREEN,BLUE] in range 0..1 light_distance (float): distance of the light along the normalized `light_direction` shadow (bool): True for shadows, False for no shadows light_ambient_coeff (float): light ambient coefficient @@ -2682,13 +2687,13 @@ class Bullet(Simulator): Returns: int: width image resolution in pixels (horizontal) int: height image resolution in pixels (vertical) - np.int[width, height, 4]: RBGA pixels (each pixel is in the range [0..255] for each channel R, G, B, A) - np.array[width, height]: Depth buffer. Bullet uses OpenGL to render, and the convention is non-linear + np.array[int[width, height, 4]]: RBGA pixels (each pixel is in the range [0..255] for each channel). + np.array[float[width, height]]: Depth buffer. Bullet uses OpenGL to render, and the convention is non-linear z-buffer. See https://stackoverflow.com/questions/6652253/getting-the-true-z-value-from-the-depth-buffer Using the projection matrix, the depth is computed as: `depth = far * near / (far - (far - near) * depthImg)`, where `depthImg` is the depth from Bullet `get_camera_image`, far=1000. and near=0.01. - np.int[width, height]: Segmentation mask buffer. For each pixels the visible object unique id. + np.array[int[width, height]]: Segmentation mask buffer. For each pixels the visible object unique id. If ER_SEGMENTATION_MASK_OBJECT_AND_LINKINDEX (=1) is used, the segmentationMaskBuffer combines the object unique id and link index as follows: value = objectUniqueId + (linkIndex+1)<<24. So for a free floating body without joints/links, the segmentation mask is equal to its body unique id, @@ -2751,11 +2756,11 @@ class Bullet(Simulator): Args: width (int): horizontal image resolution in pixels height (int): vertical image resolution in pixels - view_matrix (np.array[4,4]): 4x4 view matrix, see `compute_view_matrix` - projection_matrix (np.array[4,4]): 4x4 projection matrix, see `compute_projection` - light_direction (np.array[3]): `light_direction` specifies the world position of the light source, + view_matrix (np.array[float[4,4]]): 4x4 view matrix, see `compute_view_matrix` + projection_matrix (np.array[float[4,4]]): 4x4 projection matrix, see `compute_projection` + light_direction (np.array[float[3]]): `light_direction` specifies the world position of the light source, the direction is from the light source position to the origin of the world frame. - light_color (np.array[3]): directional light color in [RED,GREEN,BLUE] in range 0..1 + light_color (np.array[float[3]]): directional light color in [RED,GREEN,BLUE] in range 0..1 light_distance (float): distance of the light along the normalized `light_direction` shadow (bool): True for shadows, False for no shadows light_ambient_coeff (float): light ambient coefficient @@ -2768,7 +2773,7 @@ class Bullet(Simulator): segmentation mask. Returns: - np.int[width, height, 4]: RBGA pixels (each pixel is in the range [0..255] for each channel R, G, B, A) + np.array[int[width, height, 4]]: RBGA pixels (each pixel is in the range [0..255] for each channel). """ kwargs = {} if view_matrix is not None: @@ -2824,11 +2829,11 @@ class Bullet(Simulator): Args: width (int): horizontal image resolution in pixels height (int): vertical image resolution in pixels - view_matrix (np.array[4,4]): 4x4 view matrix, see `compute_view_matrix` - projection_matrix (np.array[4,4]): 4x4 projection matrix, see `compute_projection` - light_direction (np.array[3]): `light_direction` specifies the world position of the light source, + view_matrix (np.array[float[4,4]]): 4x4 view matrix, see `compute_view_matrix` + projection_matrix (np.array[float[4,4]]): 4x4 projection matrix, see `compute_projection` + light_direction (np.array[float[3]]): `light_direction` specifies the world position of the light source, the direction is from the light source position to the origin of the world frame. - light_color (np.array[3]): directional light color in [RED,GREEN,BLUE] in range 0..1 + light_color (np.array[float[3]]): directional light color in [RED,GREEN,BLUE] in range 0..1 light_distance (float): distance of the light along the normalized `light_direction` shadow (bool): True for shadows, False for no shadows light_ambient_coeff (float): light ambient coefficient @@ -2841,7 +2846,7 @@ class Bullet(Simulator): segmentation mask. Returns: - np.array[width, height]: Depth buffer. Bullet uses OpenGL to render, and the convention is non-linear + np.array[float[width, height]]: Depth buffer. Bullet uses OpenGL to render, and the convention is non-linear z-buffer. See https://stackoverflow.com/questions/6652253/getting-the-true-z-value-from-the-depth-buffer Using the projection matrix, the depth is computed as: `depth = far * near / (far - (far - near) * depthImg)`, where `depthImg` is the depth from Bullet @@ -2902,11 +2907,11 @@ class Bullet(Simulator): Args: width (int): horizontal image resolution in pixels height (int): vertical image resolution in pixels - view_matrix (np.array[4,4]): 4x4 view matrix, see `compute_view_matrix` - projection_matrix (np.array[4,4]): 4x4 projection matrix, see `compute_projection` - light_direction (np.array[3]): `light_direction` specifies the world position of the light source, + view_matrix (np.array[float[4,4]]): 4x4 view matrix, see `compute_view_matrix` + projection_matrix (np.array[float[4,4]]): 4x4 projection matrix, see `compute_projection` + light_direction (np.array[float[3]]): `light_direction` specifies the world position of the light source, the direction is from the light source position to the origin of the world frame. - light_color (np.array[3]): directional light color in [RED,GREEN,BLUE] in range 0..1 + light_color (np.array[float[3]]): directional light color in [RED,GREEN,BLUE] in range 0..1 light_distance (float): distance of the light along the normalized `light_direction` shadow (bool): True for shadows, False for no shadows light_ambient_coeff (float): light ambient coefficient @@ -2919,7 +2924,7 @@ class Bullet(Simulator): segmentation mask. Returns: - np.int[width, height]: Segmentation mask buffer. For each pixels the visible object unique id. + np.array[int[width, height]]: Segmentation mask buffer. For each pixels the visible object unique id. If ER_SEGMENTATION_MASK_OBJECT_AND_LINKINDEX (=1) is used, the segmentationMaskBuffer combines the object unique id and link index as follows: value = objectUniqueId + (linkIndex+1)<<24. So for a free floating body without joints/links, the segmentation mask is equal to its body unique id, @@ -2979,17 +2984,17 @@ class Bullet(Simulator): shape_type (int): type of shape; GEOM_SPHERE (=2), GEOM_BOX (=3), GEOM_CAPSULE (=7), GEOM_CYLINDER (=4), GEOM_PLANE (=6), GEOM_MESH (=5) radius (float): only for GEOM_SPHERE, GEOM_CAPSULE, GEOM_CYLINDER - half_extents (np.array[3], list/tuple of 3 floats): only for GEOM_BOX. + half_extents (np.array[float[3]], list/tuple of 3 floats): only for GEOM_BOX. height (float): only for GEOM_CAPSULE, GEOM_CYLINDER (length = height). filename (str): Filename for GEOM_MESH, currently only Wavefront .obj. Will create convex hulls for each object (marked as 'o') in the .obj file. - mesh_scale (np.array[3], list/tuple of 3 floats): scale of mesh (only for GEOM_MESH). - plane_normal (np.array[3], list/tuple of 3 floats): plane normal (only for GEOM_PLANE). + mesh_scale (np.array[float[3]], list/tuple of 3 floats): scale of mesh (only for GEOM_MESH). + plane_normal (np.array[float[3]], list/tuple of 3 floats): plane normal (only for GEOM_PLANE). flags (int): unused / to be decided - collision_frame_position (np.array[3]): translational offset of the collision shape with respect to the - link frame - collision_frame_orientation (np.array[4]): rotational offset (quaternion x,y,z,w) of the collision shape - with respect to the link frame + collision_frame_position (np.array[float[3]]): translational offset of the collision shape with respect + to the link frame + collision_frame_orientation (np.array[float[4]]): rotational offset (quaternion x,y,z,w) of the collision + shape with respect to the link frame Returns: int: The return value is a non-negative int unique id for the collision shape or -1 if the call failed. @@ -3030,14 +3035,15 @@ class Bullet(Simulator): int: object unique id. int: link id. int: geometry type; GEOM_BOX (=3), GEOM_SPHERE (=2), GEOM_CAPSULE (=7), GEOM_MESH (=5), GEOM_PLANE (=6) - np.array[3]: depends on geometry type: + np.array[float[3]]: depends on geometry type: for GEOM_BOX: extents, for GEOM_SPHERE: dimensions[0] = radius, for GEOM_CAPSULE and GEOM_CYLINDER: dimensions[0] = height (length), dimensions[1] = radius. For GEOM_MESH: dimensions is the scaling factor. str: Only for GEOM_MESH: file name (and path) of the collision mesh asset. - np.array[3]: Local position of the collision frame with respect to the center of mass/inertial frame - np.array[4]: Local orientation of the collision frame with respect to the inertial frame + np.array[float[3]]: Local position of the collision frame with respect to the center of mass/inertial + frame + np.array[float[4]]: Local orientation of the collision frame with respect to the inertial frame """ collision = self.sim.getCollisionShapeData(object_id, link_id) if len(collision) == 0: @@ -3054,11 +3060,11 @@ class Bullet(Simulator): enlarges the AABBs a bit (extra margin and extruded along the velocity vector). Args: - aabb_min (np.array[3]): minimum coordinates of the aabb - aabb_max (np.array[3]): maximum coordinates of the aabb + aabb_min (np.array[float[3]]): minimum coordinates of the aabb + aabb_max (np.array[float[3]]): maximum coordinates of the aabb Returns: - list of int: list of object unique ids. + list[int]: list of object unique ids. """ return self.sim.getOverlappingObjects(aabb_min, aabb_max) @@ -3072,8 +3078,8 @@ class Bullet(Simulator): link_id (int): link index in range [0..`getNumJoints(..)] Returns: - np.array[3]: minimum coordinates of the axis aligned bounding box - np.array[3]: maximum coordinates of the axis aligned bounding box + np.array[float[3]]: minimum coordinates of the axis aligned bounding box + np.array[float[3]]: maximum coordinates of the axis aligned bounding box """ aabb_min, aabb_max = self.sim.getAABB(body_id, link_id) return np.asarray(aabb_min), np.asarray(aabb_max) @@ -3096,15 +3102,15 @@ class Bullet(Simulator): int: body unique id of body B int: link index of body A, -1 for base int: link index of body B, -1 for base - np.array[3]: contact position on A, in Cartesian world coordinates - np.array[3]: contact position on B, in Cartesian world coordinates - np.array[3]: contact normal on B, pointing towards A + np.array[float[3]]: contact position on A, in Cartesian world coordinates + np.array[float[3]]: contact position on B, in Cartesian world coordinates + np.array[float[3]]: contact normal on B, pointing towards A float: contact distance, positive for separation, negative for penetration float: normal force applied during the last `step` float: lateral friction force in the first lateral friction direction (see next returned value) - np.array[3]: first lateral friction direction + np.array[float[3]]: first lateral friction direction float: lateral friction force in the second lateral friction direction (see next returned value) - np.array[3]: second lateral friction direction + np.array[float[3]]: second lateral friction direction """ kwargs = {} if body1 is not None: @@ -3142,15 +3148,15 @@ class Bullet(Simulator): int: body unique id of body B int: link index of body A, -1 for base int: link index of body B, -1 for base - np.array[3]: contact position on A, in Cartesian world coordinates - np.array[3]: contact position on B, in Cartesian world coordinates - np.array[3]: contact normal on B, pointing towards A + np.array[float[3]]: contact position on A, in Cartesian world coordinates + np.array[float[3]]: contact position on B, in Cartesian world coordinates + np.array[float[3]]: contact normal on B, pointing towards A float: contact distance, positive for separation, negative for penetration float: normal force applied during the last `step`. Always equal to 0. float: lateral friction force in the first lateral friction direction (see next returned value) - np.array[3]: first lateral friction direction + np.array[float[3]]: first lateral friction direction float: lateral friction force in the second lateral friction direction (see next returned value) - np.array[3]: second lateral friction direction + np.array[float[3]]: second lateral friction direction """ kwargs = {} if link1_id is not None: @@ -3169,16 +3175,16 @@ class Bullet(Simulator): Performs a single raycast to find the intersection information of the first object hit. Args: - from_position (np.array[3]): start of the ray in world coordinates - to_position (np.array[3]): end of the ray in world coordinates + from_position (np.array[float[3]]): start of the ray in world coordinates + to_position (np.array[float[3]]): end of the ray in world coordinates Returns: list: int: object unique id of the hit object int: link index of the hit object, or -1 if none/parent float: hit fraction along the ray in range [0,1] along the ray. - np.array[3]: hit position in Cartesian world coordinates - np.array[3]: hit normal in Cartesian world coordinates + np.array[float[3]]: hit position in Cartesian world coordinates + np.array[float[3]]: hit normal in Cartesian world coordinates """ if isinstance(from_position, np.ndarray): from_position = from_position.ravel().tolist() @@ -3197,8 +3203,8 @@ class Bullet(Simulator): per batch is `pybullet.MAX_RAY_INTERSECTION_BATCH_SIZE`. Args: - from_positions (np.array[N,3]): list of start points for each ray, in world coordinates - to_positions (np.array[N,3]): list of end points for each ray in world coordinates + from_positions (np.array[float[N,3]]): list of start points for each ray, in world coordinates + to_positions (np.array[float[N,3]]): list of end points for each ray in world coordinates parent_object_id (int): ray from/to is in local space of a parent object parent_link_id (int): ray from/to is in local space of a parent object @@ -3207,8 +3213,8 @@ class Bullet(Simulator): int: object unique id of the hit object int: link index of the hit object, or -1 if none/parent float: hit fraction along the ray in range [0,1] along the ray. - np.array[3]: hit position in Cartesian world coordinates - np.array[3]: hit normal in Cartesian world coordinates + np.array[float[3]]: hit position in Cartesian world coordinates + np.array[float[3]]: hit normal in Cartesian world coordinates """ if isinstance(from_positions, np.ndarray): from_positions = from_positions.tolist() @@ -3268,10 +3274,10 @@ class Bullet(Simulator): Returns: float: mass in kg float: lateral friction coefficient - np.array[3]: local inertia diagonal. Note that links and base are centered around the center of mass and - aligned with the principal axes of inertia. - np.array[3]: position of inertial frame in local coordinates of the joint frame - np.array[4]: orientation of inertial frame in local coordinates of joint frame + np.array[float[3]]: local inertia diagonal. Note that links and base are centered around the center of + mass and aligned with the principal axes of inertia. + np.array[float[3]]: position of inertial frame in local coordinates of the joint frame + np.array[float[4]]: orientation of inertial frame in local coordinates of joint frame float: coefficient of restitution float: rolling friction coefficient orthogonal to contact normal float: spinning friction coefficient around contact normal @@ -3306,9 +3312,9 @@ class Bullet(Simulator): section. friction_anchor (int): enable or disable a friction anchor: positional friction correction (disabled by default, unless set in the URDF contact section) - local_inertia_diagonal (np.array[3]): diagonal elements of the inertia tensor. Note that the base and - links are centered around the center of mass and aligned with the principal axes of inertia so there - are no off-diagonal elements in the inertia tensor. + local_inertia_diagonal (np.array[float[3]]): diagonal elements of the inertia tensor. Note that the base + and links are centered around the center of mass and aligned with the principal axes of inertia so + there are no off-diagonal elements in the inertia tensor. joint_damping (float): joint damping coefficient applied at each joint. This coefficient is read from URDF joint damping field. Keep the value close to 0. `joint_damping_force = -damping_coefficient * joint_velocity`. @@ -3355,15 +3361,15 @@ class Bullet(Simulator): Args: body_id (int): unique body id. link_id (int): link id. - local_position (np.array[3]): the point on the specified link to compute the Jacobian (in link local + local_position (np.array[float[3]]): the point on the specified link to compute the Jacobian (in link local coordinates around its center of mass). If None, it will use the CoM position (in the link frame). - q (np.array[N]): joint positions of size N, where N is the number of DoFs. - dq (np.array[N]): joint velocities of size N, where N is the number of DoFs. - des_ddq (np.array[N]): desired joint accelerations of size N. + q (np.array[float[N]]): joint positions of size N, where N is the number of DoFs. + dq (np.array[float[N]]): joint velocities of size N, where N is the number of DoFs. + des_ddq (np.array[float[N]]): desired joint accelerations of size N. Returns: - np.array[6,N], np.array[6,(6+N)]: full geometric (linear and angular) Jacobian matrix. The number of - columns depends if the base is fixed or floating. + np.array[float[6,N]], np.array[float[6,6+N]]: full geometric (linear and angular) Jacobian matrix. The + number of columns depends if the base is fixed or floating. """ # Note that q, dq, ddq have to be lists in PyBullet (it doesn't work with numpy arrays) if isinstance(local_position, np.ndarray): @@ -3397,10 +3403,10 @@ class Bullet(Simulator): Args: body_id (int): body unique id. - q (np.array[N]): joint positions of size N, where N is the total number of DoFs. + q (np.array[float[N]]): joint positions of size N, where N is the total number of DoFs. Returns: - np.array[N,N], np.array[6+N,6+N]: inertia matrix + np.array[float[N,N]], np.array[float[6+N,6+N]]: inertia matrix """ if isinstance(q, np.ndarray): q = q.ravel().tolist() # Note that pybullet doesn't accept numpy arrays here @@ -3422,28 +3428,28 @@ class Bullet(Simulator): Args: body_id (int): body unique id, as returned by `load_urdf`, etc. link_id (int): end effector link index. - position (np.array[3]): target position of the end effector (its link coordinate, not center of mass + position (np.array[float[3]]): target position of the end effector (its link coordinate, not center of mass coordinate!). By default this is in Cartesian world space, unless you provide `q_curr` joint angles. - orientation (np.array[4]): target orientation in Cartesian world space, quaternion [x,y,w,z]. If not + orientation (np.array[float[4]]): target orientation in Cartesian world space, quaternion [x,y,w,z]. If not specified, pure position IK will be used. - lower_limits (np.array[N], list of N floats): lower joint limits. Optional null-space IK. - upper_limits (np.array[N], list of N floats): upper joint limits. Optional null-space IK. - joint_ranges (np.array[N], list of N floats): range of value of each joint. - rest_poses (np.array[N], list of N floats): joint rest poses. Favor an IK solution closer to a given rest - pose. - joint_dampings (np.array[N], list of N floats): joint damping factors. Allow to tune the IK solution using - joint damping factors. + lower_limits (np.array[float[N]], list of N floats): lower joint limits. Optional null-space IK. + upper_limits (np.array[float[N]], list of N floats): upper joint limits. Optional null-space IK. + joint_ranges (np.array[float[N]], list of N floats): range of value of each joint. + rest_poses (np.array[float[N]], list of N floats): joint rest poses. Favor an IK solution closer to a given + rest pose. + joint_dampings (np.array[float[N]], list of N floats): joint damping factors. Allow to tune the IK solution + using joint damping factors. solver (int): p.IK_DLS (=0) or p.IK_SDLS (=1), Damped Least Squares or Selective Damped Least Squares, as described in the paper by Samuel Buss "Selectively Damped Least Squares for Inverse Kinematics". - q_curr (np.array[N]): list of joint positions. By default PyBullet uses the joint positions of the body. - If provided, the target_position and targetOrientation is in local space! + q_curr (np.array[float[N]]): list of joint positions. By default PyBullet uses the joint positions of the + body. If provided, the target_position and targetOrientation is in local space! max_iters (int): maximum number of iterations. Refine the IK solution until the distance between target and actual end effector position is below this threshold, or the `max_iters` is reached. threshold (float): residual threshold. Refine the IK solution until the distance between target and actual end effector position is below this threshold, or the `max_iters` is reached. Returns: - np.array[N]: joint positions (for each actuated joint). + np.array[float[N]]: joint positions (for each actuated joint). """ kwargs = {} if orientation is not None: @@ -3505,12 +3511,12 @@ class Bullet(Simulator): Args: body_id (int): body unique id. - q (np.array[N]): joint positions - dq (np.array[N]): joint velocities - des_ddq (np.array[N]): desired joint accelerations + q (np.array[float[N]]): joint positions + dq (np.array[float[N]]): joint velocities + des_ddq (np.array[float[N]]): desired joint accelerations Returns: - np.array[N]: joint torques computed using the rigid-body equation of motion + np.array[float[N]]: joint torques computed using the rigid-body equation of motion References: - [1] "Rigid Body Dynamics Algorithms", Featherstone, 2008, chap1.1 @@ -3562,12 +3568,12 @@ class Bullet(Simulator): Args: body_id (int): unique body id. - q (np.array[N]): joint positions - dq (np.array[N]): joint velocities - torques (np.array[N]): desired joint torques + q (np.array[float[N]]): joint positions + dq (np.array[float[N]]): joint velocities + torques (np.array[float[N]]): desired joint torques Returns: - np.array[N]: joint accelerations computed using the rigid-body equation of motion + np.array[float[N]]: joint accelerations computed using the rigid-body equation of motion References: - [1] "Rigid Body Dynamics Algorithms", Featherstone, 2008, chap1.1 @@ -3599,9 +3605,9 @@ class Bullet(Simulator): a line width and a duration in seconds. Args: - from_pos (np.array[3]): starting point of the line in Cartesian world coordinates - to_pos (np.array[3]): end point of the line in Cartesian world coordinates - rgb_color (np.array[3]): RGB color (each channel in range [0,1]) + from_pos (np.array[float[3]]): starting point of the line in Cartesian world coordinates + to_pos (np.array[float[3]]): end point of the line in Cartesian world coordinates + rgb_color (np.array[float[3]]): RGB color (each channel in range [0,1]) width (float): line width (limited by OpenGL implementation). lifetime (float): use 0 for permanent line, or positive time in seconds (afterwards the line with be removed automatically) @@ -3635,16 +3641,16 @@ class Bullet(Simulator): Args: text (str): text. - position (np.array[3]): 3d position of the text in Cartesian world coordinates. + position (np.array[float[3]]): 3d position of the text in Cartesian world coordinates. rgb_color (list/tuple of 3 floats): RGB color; each component in range [0..1] size (float): text size lifetime (float): use 0 for permanent text, or positive time in seconds (afterwards the text with be removed automatically) - orientation (np.array[4]): By default, debug text will always face the camera, automatically rotation. - By specifying a text orientation (quaternion), the orientation will be fixed in world space or local - space (when parent is specified). Note that a different implementation/shader is used for camera - facing text, with different appearance: camera facing text uses bitmap fonts, text with specified - orientation uses TrueType font. + orientation (np.array[float[4]]): By default, debug text will always face the camera, automatically + rotation. By specifying a text orientation (quaternion), the orientation will be fixed in world space + or local space (when parent is specified). Note that a different implementation/shader is used for + camera facing text, with different appearance: camera facing text uses bitmap fonts, text with + specified orientation uses TrueType font. parent_object_id (int): draw text in local coordinates of a parent object. parent_link_id (int): draw text in local coordinates of a parent link. text_id (int): replace an existing text item (to avoid flickering of remove/add). @@ -3840,18 +3846,18 @@ class Bullet(Simulator): Returns: int: width of the visualizer camera int: height of the visualizer camera - np.array[4,4]: view matrix [4,4] - np.array[4,4]: perspective projection matrix [4,4] - np.array[3]: camera up vector expressed in the Cartesian world space - np.array[3]: forward axis of the camera expressed in the Cartesian world space - np.array[3]: This is a horizontal vector that can be used to generate rays (for mouse picking or creating - a simple ray tracer for example) - np.array[3]: This is a vertical vector that can be used to generate rays (for mouse picking or creating a - simple ray tracer for example) + np.array[float[4,4]]: view matrix [4,4] + np.array[float[4,4]]: perspective projection matrix [4,4] + np.array[float[3]]: camera up vector expressed in the Cartesian world space + np.array[float[3]]: forward axis of the camera expressed in the Cartesian world space + np.array[float[3]]: This is a horizontal vector that can be used to generate rays (for mouse picking or + creating a simple ray tracer for example) + np.array[float[3]]: This is a vertical vector that can be used to generate rays (for mouse picking or + creating a simple ray tracer for example) float: yaw angle (in radians) of the camera, in Cartesian local space coordinates float: pitch angle (in radians) of the camera, in Cartesian local space coordinates float: distance between the camera and the camera target - np.array[3]: target of the camera, in Cartesian world space coordinates + np.array[float[3]]: target of the camera, in Cartesian world space coordinates """ width, height, view, proj, up_vec, forward_vec,\ horizontal, vertical, yaw, pitch, dist, target = self.sim.getDebugVisualizerCamera() @@ -3880,7 +3886,7 @@ class Bullet(Simulator): distance (float): distance from eye to camera target position yaw (float): camera yaw angle (in radians) left/right pitch (float): camera pitch angle (in radians) up/down - target_position (np.array[3]): target focus point of the camera + target_position (np.array[float[3]]): target focus point of the camera """ self.sim.resetDebugVisualizerCamera(cameraDistance=distance, cameraYaw=np.rad2deg(yaw), cameraPitch=np.rad2deg(pitch), cameraTargetPosition=target_position) diff --git a/pyrobolearn/simulators/dart.py b/pyrobolearn/simulators/dart.py index 592e80f..c3a3761 100644 --- a/pyrobolearn/simulators/dart.py +++ b/pyrobolearn/simulators/dart.py @@ -643,8 +643,8 @@ class Dart(Simulator): collision_shape_id (int): unique id from createCollisionShape or -1. You can re-use the collision shape for multiple multibodies (instancing) mass (float): mass of the base, in kg (if using SI units) - position (np.float[3]): Cartesian world position of the base - orientation (np.float[4]): Orientation of base as quaternion [x,y,z,w] + position (np.array[float[3]]): Cartesian world position of the base + orientation (np.array[float[4]]): Orientation of base as quaternion [x,y,z,w] Returns: int: non-negative unique id or -1 for failure. @@ -716,13 +716,13 @@ class Dart(Simulator): child_link_id (int): child link index, or -1 for the base joint_type (int): joint type: JOINT_PRISMATIC (=1), JOINT_FIXED (=4), JOINT_POINT2POINT (=5), JOINT_GEAR (=6) - joint_axis (np.float[3]): joint axis, in child link frame - parent_frame_position (np.float[3]): position of the joint frame relative to parent CoM frame. - child_frame_position (np.float[3]): position of the joint frame relative to a given child CoM frame (or - world origin if no child specified) - parent_frame_orientation (np.float[4]): the orientation of the joint frame relative to parent CoM + joint_axis (np.array[float[3]]): joint axis, in child link frame + parent_frame_position (np.array[float[3]]): position of the joint frame relative to parent CoM frame. + child_frame_position (np.array[float[3]]): position of the joint frame relative to a given child CoM frame + (or world origin if no child specified) + parent_frame_orientation (np.array[float[4]]): the orientation of the joint frame relative to parent CoM coordinate frame - child_frame_orientation (np.float[4]): the orientation of the joint frame relative to the child CoM + child_frame_orientation (np.array[float[4]]): the orientation of the joint frame relative to the child CoM coordinate frame (or world origin frame if no child specified) Returns: @@ -842,11 +842,11 @@ class Dart(Simulator): Args: body_id (int): unique body id. - link_ids (list of int): link ids associated with the given body id. If None, it will take all the links + link_ids (list[int]): link ids associated with the given body id. If None, it will take all the links of the specified body. Returns: - np.float[3]: center of mass position in the Cartesian world coordinates + np.array[float[3]]: center of mass position in the Cartesian world coordinates """ skeleton = self.world.getSkeleton(body_id) @@ -870,11 +870,11 @@ class Dart(Simulator): Args: body_id (int): unique body id. - link_ids (list of int): link ids associated with the given body id. If None, it will take all the links + link_ids (list[int]): link ids associated with the given body id. If None, it will take all the links of the specified body. Returns: - np.float[3]: center of mass linear velocity. + np.array[float[3]]: center of mass linear velocity. """ skeleton = self.world.getSkeleton(body_id) @@ -892,8 +892,8 @@ class Dart(Simulator): body_id (int): object unique id, as returned from `load_urdf`. Returns: - np.float[3]: base position - np.float[4]: base orientation (quaternion [x,y,z,w]) + np.array[float[3]]: base position + np.array[float[4]]: base orientation (quaternion [x,y,z,w]) """ base = self.world.getSkeleton(body_id).getRootBodyNode() transform = base.getWorldTransform() @@ -910,7 +910,7 @@ class Dart(Simulator): body_id (int): object unique id, as returned from `load_urdf`. Returns: - np.float[3]: base position. + np.array[float[3]]: base position. """ base = self.world.getSkeleton(body_id).getRootBodyNode() # return base.getWorldTransform()[:-1, 3] @@ -924,7 +924,7 @@ class Dart(Simulator): body_id (int): object unique id, as returned from `load_urdf`. Returns: - np.float[4]: base orientation in the form of a quaternion (x,y,z,w) + np.array[float[4]]: base orientation in the form of a quaternion (x,y,z,w) """ base = self.world.getSkeleton(body_id).getRootBodyNode() transform = base.getWorldTransform() @@ -936,8 +936,8 @@ class Dart(Simulator): Args: body_id (int): unique object id. - position (np.float[3]): new base position. - orientation (np.float[4]): new base orientation (expressed as a quaternion [x,y,z,w]) + position (np.array[float[3]]): new base position. + orientation (np.array[float[4]]): new base orientation (expressed as a quaternion [x,y,z,w]) """ pass @@ -947,7 +947,7 @@ class Dart(Simulator): Args: body_id (int): unique object id. - position (np.float[3]): new base position. + position (np.array[float[3]]): new base position. """ pass @@ -957,7 +957,7 @@ class Dart(Simulator): Args: body_id (int): unique object id. - orientation (np.float[4]): new base orientation (expressed as a quaternion [x,y,z,w]) + orientation (np.array[float[4]]): new base orientation (expressed as a quaternion [x,y,z,w]) """ pass @@ -969,8 +969,8 @@ class Dart(Simulator): body_id (int): object unique id, as returned from `load_urdf`. Returns: - np.float[3]: linear velocity of the base in Cartesian world space coordinates - np.float[3]: angular velocity of the base in Cartesian world space coordinates + np.array[float[3]]: linear velocity of the base in Cartesian world space coordinates + np.array[float[3]]: angular velocity of the base in Cartesian world space coordinates """ base = self.world.getSkeleton(body_id).getRootBodyNode() lin_vel = base.getLinearVelocity() @@ -985,7 +985,7 @@ class Dart(Simulator): body_id (int): object unique id, as returned from `load_urdf`. Returns: - np.float[3]: linear velocity of the base in Cartesian world space coordinates + np.array[float[3]]: linear velocity of the base in Cartesian world space coordinates """ base = self.world.getSkeleton(body_id).getRootBodyNode() lin_vel = base.getLinearVelocity() @@ -999,7 +999,7 @@ class Dart(Simulator): body_id (int): object unique id, as returned from `load_urdf`. Returns: - np.float[3]: angular velocity of the base in Cartesian world space coordinates + np.array[float[3]]: angular velocity of the base in Cartesian world space coordinates """ base = self.world.getSkeleton(body_id).getRootBodyNode() ang_vel = base.getAngularVelocity() @@ -1011,8 +1011,8 @@ class Dart(Simulator): Args: body_id (int): unique object id. - linear_velocity (np.float[3]): new linear velocity of the base. - angular_velocity (np.float[3]): new angular velocity of the base. + linear_velocity (np.array[float[3]]): new linear velocity of the base. + angular_velocity (np.array[float[3]]): new angular velocity of the base. """ pass @@ -1022,7 +1022,7 @@ class Dart(Simulator): Args: body_id (int): unique object id. - linear_velocity (np.float[3]): new linear velocity of the base + linear_velocity (np.array[float[3]]): new linear velocity of the base """ pass @@ -1032,7 +1032,7 @@ class Dart(Simulator): Args: body_id (int): unique object id. - angular_velocity (np.float[3]): new angular velocity of the base + angular_velocity (np.array[float[3]]): new angular velocity of the base """ pass @@ -1043,8 +1043,8 @@ class Dart(Simulator): Args: body_id (int): unique body id. link_id (int): unique link id. If -1, it will be the base. - force (np.float[3]): external force to be applied. - position (np.float[3]): position on the link where the force is applied. See `flags` for coordinate + force (np.array[float[3]]): external force to be applied. + position (np.array[float[3]]): position on the link where the force is applied. See `flags` for coordinate systems. If None, it is the center of mass of the body (or the link if specified). frame (int): if frame = 1, then the force / position is described in the link frame. If frame = 2, they are described in the world frame. @@ -1149,9 +1149,9 @@ class Dart(Simulator): [11] float: maximum velocity specified in URDF. Note that this value is not used in actual motor control commands at the moment. [12] str: name of the link (as specified in the URDF/SDF/etc file) - [13] np.array[3]: joint axis in local frame (ignored for JOINT_FIXED) - [14] np.array[3]: joint position in parent frame - [15] np.array[4]: joint orientation in parent frame + [13] np.array[float[3]]: joint axis in local frame (ignored for JOINT_FIXED) + [14] np.array[float[3]]: joint position in parent frame + [15] np.array[float[4]]: joint orientation in parent frame [16] int: parent link index, -1 for base """ pass @@ -1167,7 +1167,7 @@ class Dart(Simulator): Returns: float: The position value of this joint. float: The velocity value of this joint. - np.float[6]: These are the joint reaction forces, if a torque sensor is enabled for this joint it is + np.array[float[6]]: These are the joint reaction forces, if a torque sensor is enabled for this joint it is [Fx, Fy, Fz, Mx, My, Mz]. Without torque sensor, it is [0, 0, 0, 0, 0, 0]. float: This is the motor torque applied during the last stepSimulation. Note that this only applies in VELOCITY_CONTROL and POSITION_CONTROL. If you use TORQUE_CONTROL then the applied joint motor torque @@ -1186,14 +1186,14 @@ class Dart(Simulator): Args: body_id (int): unique body id. - joint_ids (list of int): list of joint ids. + joint_ids (list[int]): list of joint ids. Returns: list: float: The position value of this joint. float: The velocity value of this joint. - np.float[6]: These are the joint reaction forces, if a torque sensor is enabled for this joint it is - [Fx, Fy, Fz, Mx, My, Mz]. Without torque sensor, it is [0, 0, 0, 0, 0, 0]. + np.array[float[6]]: These are the joint reaction forces, if a torque sensor is enabled for this joint + it is [Fx, Fy, Fz, Mx, My, Mz]. Without torque sensor, it is [0, 0, 0, 0, 0, 0]. float: This is the motor torque applied during the last `step`. Note that this only applies in VELOCITY_CONTROL and POSITION_CONTROL. If you use TORQUE_CONTROL then the applied joint motor torque is exactly what you provide, so there is no need to report it separately. @@ -1249,17 +1249,17 @@ class Dart(Simulator): joint_ids (int): joint/link id, or list of joint ids. control_mode (int): POSITION_CONTROL (=2) (which is in fact CONTROL_MODE_POSITION_VELOCITY_PD), VELOCITY_CONTROL (=0), TORQUE_CONTROL (=1) and PD_CONTROL (=3). - positions (float, np.float[N]): target joint position(s) (used in POSITION_CONTROL). - velocities (float, np.float[N]): target joint velocity(ies). In VELOCITY_CONTROL and POSITION_CONTROL, - the target velocity(ies) is(are) the desired velocity of the joint. Note that the target velocity(ies) - is(are) not the maximum joint velocity(ies). In PD_CONTROL and + positions (float, np.array[float[N]]): target joint position(s) (used in POSITION_CONTROL). + velocities (float, np.array[float[N]]): target joint velocity(ies). In VELOCITY_CONTROL and + POSITION_CONTROL, the target velocity(ies) is(are) the desired velocity of the joint. Note that the + target velocity(ies) is(are) not the maximum joint velocity(ies). In PD_CONTROL and POSITION_CONTROL/CONTROL_MODE_POSITION_VELOCITY_PD, the final target velocities are computed using: `kp*(erp*(desiredPosition-currentPosition)/dt)+currentVelocity+kd*(m_desiredVelocity - currentVelocity)` - forces (float, list of float): in POSITION_CONTROL and VELOCITY_CONTROL, these are the maximum motor + forces (float, list[float]): in POSITION_CONTROL and VELOCITY_CONTROL, these are the maximum motor forces used to reach the target values. In TORQUE_CONTROL these are the forces / torques to be applied each simulation step. - kp (float, list of float): position (stiffness) gain(s) (used in POSITION_CONTROL). - kd (float, list of float): velocity (damping) gain(s) (used in POSITION_CONTROL). + kp (float, list[float]): position (stiffness) gain(s) (used in POSITION_CONTROL). + kd (float, list[float]): velocity (damping) gain(s) (used in POSITION_CONTROL). max_velocity (float): in POSITION_CONTROL this limits the velocity to a maximum. """ pass @@ -1276,15 +1276,16 @@ class Dart(Simulator): using forward kinematics. Returns: - np.float[3]: Cartesian position of CoM - np.float[4]: Cartesian orientation of CoM, in quaternion [x,y,z,w] - np.float[3]: local position offset of inertial frame (center of mass) expressed in the URDF link frame - np.float[4]: local orientation (quaternion [x,y,z,w]) offset of the inertial frame expressed in URDF link + np.array[float[3]]: Cartesian position of CoM + np.array[float[4]]: Cartesian orientation of CoM, in quaternion [x,y,z,w] + np.array[float[3]]: local position offset of inertial frame (center of mass) expressed in the URDF link frame - np.float[3]: world position of the URDF link frame - np.float[4]: world orientation of the URDF link frame - np.float[3]: Cartesian world linear velocity. Only returned if `compute_velocity` is True. - np.float[3]: Cartesian world angular velocity. Only returned if `compute_velocity` is True. + np.array[float[4]]: local orientation (quaternion [x,y,z,w]) offset of the inertial frame expressed in URDF + link frame + np.array[float[3]]: world position of the URDF link frame + np.array[float[4]]: world orientation of the URDF link frame + np.array[float[3]]: Cartesian world linear velocity. Only returned if `compute_velocity` is True. + np.array[float[3]]: Cartesian world angular velocity. Only returned if `compute_velocity` is True. """ body = self.world.getSkeleton(body_id).getBodyNode(link_id + 1) transform = body.getWorldTransform() @@ -1313,22 +1314,23 @@ class Dart(Simulator): Args: body_id (int): body unique id. - link_ids (list of int): list of link index. + link_ids (list[int]): list of link index. compute_velocity (bool): If True, the Cartesian world velocity will be computed and returned. compute_forward_kinematics (bool): if True, the Cartesian world position/orientation will be recomputed using forward kinematics. Returns: list: - np.float[3]: Cartesian position of CoM - np.float[4]: Cartesian orientation of CoM, in quaternion [x,y,z,w] - np.float[3]: local position offset of inertial frame (center of mass) expressed in the URDF link frame - np.float[4]: local orientation (quaternion [x,y,z,w]) offset of the inertial frame expressed in URDF + np.array[float[3]]: Cartesian position of CoM + np.array[float[4]]: Cartesian orientation of CoM, in quaternion [x,y,z,w] + np.array[float[3]]: local position offset of inertial frame (center of mass) expressed in the URDF link frame - np.float[3]: world position of the URDF link frame - np.float[4]: world orientation of the URDF link frame - np.float[3]: Cartesian world linear velocity. Only returned if `compute_velocity` is True. - np.float[3]: Cartesian world angular velocity. Only returned if `compute_velocity` is True. + np.array[float[4]]: local orientation (quaternion [x,y,z,w]) offset of the inertial frame expressed in + URDF link frame + np.array[float[3]]: world position of the URDF link frame + np.array[float[4]]: world orientation of the URDF link frame + np.array[float[3]]: Cartesian world linear velocity. Only returned if `compute_velocity` is True. + np.array[float[3]]: Cartesian world angular velocity. Only returned if `compute_velocity` is True. """ if isinstance(link_ids, int): return self.get_link_state(body_id, link_ids, compute_velocity, compute_forward_kinematics) @@ -1341,7 +1343,7 @@ class Dart(Simulator): Args: body_id (int): unique body id. - link_ids (int, list of int): link id, or list of link ids. + link_ids (int, list[int]): link id, or list of link ids. Returns: if 1 link: @@ -1362,7 +1364,7 @@ class Dart(Simulator): Args: body_id (int): unique body id. - link_ids (int, list of int): link id, or list of link ids. + link_ids (int, list[int]): link id, or list of link ids. Returns: if 1 link: @@ -1387,11 +1389,11 @@ class Dart(Simulator): Returns: if 1 link: - np.array[3]: the link frame position in the world space - np.array[4]: Cartesian orientation of the link frame [x,y,z,w] + np.array[float[3]]: the link frame position in the world space + np.array[float[4]]: Cartesian orientation of the link frame [x,y,z,w] if multiple links: - np.array[N,3]: link frame position of each link in world space - np.array[N,4]: orientation of each link frame [x,y,z,w] + np.array[float[N,3]]: link frame position of each link in world space + np.array[float[N,4]]: orientation of each link frame [x,y,z,w] """ skeleton = self.world.getSkeleton(body_id) @@ -1413,13 +1415,13 @@ class Dart(Simulator): Args: body_id (int): unique body id. - link_ids (list of int): list of link indices. + link_ids (list[int]): list of link indices. Returns: if 1 link: - np.float[3]: the link CoM position in the world space + np.array[float[3]]: the link CoM position in the world space if multiple links: - np.float[N,3]: CoM position of each link in world space + np.array[float[N,3]]: CoM position of each link in world space """ skeleton = self.world.getSkeleton(body_id) @@ -1437,13 +1439,13 @@ class Dart(Simulator): Args: body_id (int): unique body id. - link_ids (list of int): list of link indices. + link_ids (list[int]): list of link indices. Returns: if 1 link: - np.float[4]: Cartesian orientation of the link CoM (x,y,z,w) + np.array[float[4]]: Cartesian orientation of the link CoM (x,y,z,w) if multiple links: - np.float[N,4]: CoM orientation of each link (x,y,z,w) + np.array[float[N,4]]: CoM orientation of each link (x,y,z,w) """ skeleton = self.world.getSkeleton(body_id) @@ -1462,13 +1464,13 @@ class Dart(Simulator): Args: body_id (int): unique body id. - link_ids (list of int): list of link indices. + link_ids (list[int]): list of link indices. Returns: if 1 link: - np.float[3]: linear velocity of the link in the Cartesian world space + np.array[float[3]]: linear velocity of the link in the Cartesian world space if multiple links: - np.float[N,3]: linear velocity of each link + np.array[float[N,3]]: linear velocity of each link """ skeleton = self.world.getSkeleton(body_id) @@ -1483,13 +1485,13 @@ class Dart(Simulator): Args: body_id (int): unique body id. - link_ids (list of int): list of link indices. + link_ids (list[int]): list of link indices. Returns: if 1 link: - np.float[3]: angular velocity of the link in the Cartesian world space + np.array[float[3]]: angular velocity of the link in the Cartesian world space if multiple links: - np.float[N,3]: angular velocity of each link + np.array[float[N,3]]: angular velocity of each link """ skeleton = self.world.getSkeleton(body_id) @@ -1505,13 +1507,13 @@ class Dart(Simulator): Args: body_id (int): unique body id. - link_ids (list of int): list of link indices. + link_ids (list[int]): list of link indices. Returns: if 1 link: - np.float[6]: linear and angular velocity of the link in the Cartesian world space + np.array[float[6]]: linear and angular velocity of the link in the Cartesian world space if multiple links: - np.float[N,6]: linear and angular velocity of each link + np.array[float[N,6]]: linear and angular velocity of each link """ skeleton = self.world.getSkeleton(body_id) @@ -1538,13 +1540,13 @@ class Dart(Simulator): Args: body_id (int): unique body id. - joint_ids (int, list of int): a joint id, or list of joint ids. + joint_ids (int, list[int]): a joint id, or list of joint ids. Returns: if 1 joint: int: q index if multiple joints: - np.int[N]: q indices + np.array[int[N]]: q indices """ pass @@ -1556,7 +1558,7 @@ class Dart(Simulator): body_id (int): unique body id. Returns: - list of int: actuated joint ids. + list[int]: actuated joint ids. """ skeleton = self.world.getSkeleton(body_id) @@ -1573,7 +1575,7 @@ class Dart(Simulator): Args: body_id (int): unique body id. - joint_ids (int, list of int): a joint id, or list of joint ids. + joint_ids (int, list[int]): a joint id, or list of joint ids. Returns: if 1 joint: @@ -1594,7 +1596,7 @@ class Dart(Simulator): Args: body_id (int): unique body id. - joint_ids (int, list of int): a joint id, or list of joint ids. + joint_ids (int, list[int]): a joint id, or list of joint ids. Returns: if 1 joint: @@ -1609,7 +1611,7 @@ class Dart(Simulator): Args: body_id (int): unique body id. - joint_ids (int, list of int): a joint id, or list of joint ids. + joint_ids (int, list[int]): a joint id, or list of joint ids. Returns: if 1 joint: @@ -1631,13 +1633,13 @@ class Dart(Simulator): Args: body_id (int): unique body id. - joint_ids (int, list of int): a joint id, or list of joint ids. + joint_ids (int, list[int]): a joint id, or list of joint ids. Returns: if 1 joint: float: damping coefficient of the given joint if multiple joints: - np.float[N]: damping coefficient for each specified joint + np.array[float[N]]: damping coefficient for each specified joint """ skeleton = self.world.getSkeleton(body_id) @@ -1652,13 +1654,13 @@ class Dart(Simulator): Args: body_id (int): unique body id. - joint_ids (int, list of int): a joint id, or list of joint ids. + joint_ids (int, list[int]): a joint id, or list of joint ids. Returns: if 1 joint: float: friction coefficient of the given joint if multiple joints: - np.float[N]: friction coefficient for each specified joint + np.array[float[N]]: friction coefficient for each specified joint """ skeleton = self.world.getSkeleton(body_id) @@ -1673,13 +1675,13 @@ class Dart(Simulator): Args: body_id (int): unique body id. - joint_ids (int, list of int): a joint id, or list of joint ids. + joint_ids (int, list[int]): a joint id, or list of joint ids. Returns: if 1 joint: - np.float[2]: lower and upper limit + np.array[float[2]]: lower and upper limit if multiple joints: - np.float[N,2]: lower and upper limit for each specified joint + np.array[float[N,2]]: lower and upper limit for each specified joint """ skeleton = self.world.getSkeleton(body_id) @@ -1701,13 +1703,13 @@ class Dart(Simulator): Args: body_id (int): unique body id. - joint_ids (int, list of int): a joint id, or list of joint ids. + joint_ids (int, list[int]): a joint id, or list of joint ids. Returns: if 1 joint: float: maximum force [N] if multiple joints: - np.float[N]: maximum force for each specified joint [N] + np.array[float[N]]: maximum force for each specified joint [N] """ # TODO skeleton = self.world.getSkeleton(body_id) @@ -1730,13 +1732,13 @@ class Dart(Simulator): Args: body_id (int): unique body id. - joint_ids (int, list of int): a joint id, or list of joint ids. + joint_ids (int, list[int]): a joint id, or list of joint ids. Returns: if 1 joint: float: maximum velocity [rad/s] if multiple joints: - np.float[N]: maximum velocities for each specified joint [rad/s] + np.array[float[N]]: maximum velocities for each specified joint [rad/s] """ # TODO skeleton = self.world.getSkeleton(body_id) @@ -1757,13 +1759,13 @@ class Dart(Simulator): Args: body_id (int): unique body id. - joint_ids (int, list of int): a joint id, or list of joint ids. + joint_ids (int, list[int]): a joint id, or list of joint ids. Returns: if 1 joint: - np.float[3]: joint axis + np.array[float[3]]: joint axis if multiple joint: - np.float[N,3]: list of joint axis + np.array[float[N,3]]: list of joint axis """ skeleton = self.world.getSkeleton(body_id) @@ -1786,12 +1788,12 @@ class Dart(Simulator): Args: body_id (int): unique body id. - joint_ids (int, list of int): joint id, or list of joint ids. - positions (float, np.float[N]): desired position, or list of desired positions [rad] - velocities (None, float, np.float[N]): desired velocity, or list of desired velocities [rad/s] - kps (None, float, np.float[N]): position gain(s) - kds (None, float, np.float[N]): velocity gain(s) - forces (None, float, np.float[N]): maximum motor force(s)/torque(s) used to reach the target values. + joint_ids (int, list[int]): joint id, or list of joint ids. + positions (float, np.array[float[N]]): desired position, or list of desired positions [rad] + velocities (None, float, np.array[float[N]]): desired velocity, or list of desired velocities [rad/s] + kps (None, float, np.array[float[N]]): position gain(s) + kds (None, float, np.array[float[N]]): velocity gain(s) + forces (None, float, np.array[float[N]]): maximum motor force(s)/torque(s) used to reach the target values. """ skeleton = self.world.getSkeleton(body_id) @@ -1810,13 +1812,13 @@ class Dart(Simulator): Args: body_id (int): unique body id. - joint_ids (int, list of int): joint id, or list of joint ids. + joint_ids (int, list[int]): joint id, or list of joint ids. Returns: if 1 joint: float: joint position [rad] if multiple joints: - np.float[N]: joint positions [rad] + np.array[float[N]]: joint positions [rad] """ skeleton = self.world.getSkeleton(body_id) @@ -1832,9 +1834,9 @@ class Dart(Simulator): Args: body_id (int): unique body id. - joint_ids (int, list of int): joint id, or list of joint ids. - velocities (float, np.float[N]): desired velocity, or list of desired velocities [rad/s] - max_force (None, float, np.float[N]): maximum motor forces/torques + joint_ids (int, list[int]): joint id, or list of joint ids. + velocities (float, np.array[float[N]]): desired velocity, or list of desired velocities [rad/s] + max_force (None, float, np.array[float[N]]): maximum motor forces/torques """ skeleton = self.world.getSkeleton(body_id) @@ -1853,13 +1855,13 @@ class Dart(Simulator): Args: body_id (int): unique body id. - joint_ids (int, list of int): joint id, or list of joint ids. + joint_ids (int, list[int]): joint id, or list of joint ids. Returns: if 1 joint: float: joint velocity [rad/s] if multiple joints: - np.float[N]: joint velocities [rad/s] + np.array[float[N]]: joint velocities [rad/s] """ skeleton = self.world.getSkeleton(body_id) @@ -1876,9 +1878,9 @@ class Dart(Simulator): Args: body_id (int): unique body id. - joint_ids (int, list of int): joint id, or list of joint ids. - accelerations (float, np.float[N]): desired joint acceleration, or list of desired joint accelerations - [rad/s^2] + joint_ids (int, list[int]): joint id, or list of joint ids. + accelerations (float, np.array[float[N]]): desired joint acceleration, or list of desired joint + accelerations [rad/s^2] """ pass @@ -1889,15 +1891,15 @@ class Dart(Simulator): Args: body_id (int): unique body id. - joint_ids (int, list of int): joint id, or list of joint ids. - q (list of int, None): all the joint positions. If None, it will compute it. - dq (list of int, None): all the joint velocities. If None, it will compute it. + joint_ids (int, list[int]): joint id, or list of joint ids. + q (list[int], None): all the joint positions. If None, it will compute it. + dq (list[int], None): all the joint velocities. If None, it will compute it. Returns: if 1 joint: float: joint acceleration [rad/s^2] if multiple joints: - np.float[N]: joint accelerations [rad/s^2] + np.array[float[N]]: joint accelerations [rad/s^2] """ skeleton = self.world.getSkeleton(body_id) @@ -1913,8 +1915,8 @@ class Dart(Simulator): Args: body_id (int): unique body id. - joint_ids (int, list of int): joint id, or list of joint ids. - torques (float, list of float): desired torque(s) to apply to the joint(s) [N]. + joint_ids (int, list[int]): joint id, or list of joint ids. + torques (float, list[float]): desired torque(s) to apply to the joint(s) [N]. """ skeleton = self.world.getSkeleton(body_id) @@ -1933,13 +1935,13 @@ class Dart(Simulator): Args: body_id (int): unique body id. - joint_ids (int, list of int): a joint id, or list of joint ids. + joint_ids (int, list[int]): a joint id, or list of joint ids. Returns: if 1 joint: float: torque [Nm] if multiple joints: - np.float[N]: torques associated to the given joints [Nm] + np.array[float[N]]: torques associated to the given joints [Nm] """ skeleton = self.world.getSkeleton(body_id) @@ -1959,9 +1961,9 @@ class Dart(Simulator): Returns: if 1 joint: - np.float[6]: joint reaction force (fx,fy,fz,mx,my,mz) [N,Nm] + np.array[float[6]]: joint reaction force (fx,fy,fz,mx,my,mz) [N,Nm] if multiple joints: - np.float[N,6]: joint reaction forces [N, Nm] + np.array[float[N,6]]: joint reaction forces [N, Nm] """ pass @@ -1976,7 +1978,7 @@ class Dart(Simulator): if 1 joint: float: joint power [W] if multiple joints: - np.float[N]: power at each joint [W] + np.array[float[N]]: power at each joint [W] """ torque = self.get_joint_torques(body_id, joint_ids) velocity = self.get_joint_velocities(body_id, joint_ids) @@ -1997,25 +1999,26 @@ class Dart(Simulator): shape_type (int): type of shape; GEOM_SPHERE (=2), GEOM_BOX (=3), GEOM_CAPSULE (=7), GEOM_CYLINDER (=4), GEOM_PLANE (=6), GEOM_MESH (=5) radius (float): only for GEOM_SPHERE, GEOM_CAPSULE, GEOM_CYLINDER - half_extents (np.float[3], list/tuple of 3 floats): only for GEOM_BOX. + half_extents (np.array[float[3]], list/tuple of 3 floats): only for GEOM_BOX. length (float): only for GEOM_CAPSULE, GEOM_CYLINDER (length = height). filename (str): Filename for GEOM_MESH, currently only Wavefront .obj. Will create convex hulls for each object (marked as 'o') in the .obj file. - mesh_scale (np.float[3], list/tuple of 3 floats): scale of mesh (only for GEOM_MESH). - plane_normal (np.float[3], list/tuple of 3 floats): plane normal (only for GEOM_PLANE). + mesh_scale (np.array[float[3]], list/tuple of 3 floats): scale of mesh (only for GEOM_MESH). + plane_normal (np.array[float[3]], list/tuple of 3 floats): plane normal (only for GEOM_PLANE). flags (int): unused / to be decided rgba_color (list/tuple of 4 floats): color components for red, green, blue and alpha, each in range [0..1]. specular_color (list/tuple of 3 floats): specular reflection color, red, green, blue components in range [0..1] - visual_frame_position (np.float[3]): translational offset of the visual shape with respect to the link frame - vertices (list of np.float[3]): Instead of creating a mesh from obj file, you can provide vertices, indices, - uvs and normals - indices (list of int): triangle indices, should be a multiple of 3. - uvs (list of np.float[2]): uv texture coordinates for vertices. Use changeVisualShape to choose the + visual_frame_position (np.array[float[3]]): translational offset of the visual shape with respect to the + link frame + vertices (list of np.array[float[3]]): Instead of creating a mesh from obj file, you can provide vertices, + indices, uvs and normals + indices (list[int]): triangle indices, should be a multiple of 3. + uvs (list of np.array[float[2]]): uv texture coordinates for vertices. Use changeVisualShape to choose the texture image. The number of uvs should be equal to number of vertices - normals (list of np.float[3]): vertex normals, number should be equal to number of vertices. - visual_frame_orientation (np.float[4]): rotational offset (quaternion x,y,z,w) of the visual shape with - respect to the link frame + normals (list of np.array[float[3]]): vertex normals, number should be equal to number of vertices. + visual_frame_orientation (np.array[float[4]]): rotational offset (quaternion x,y,z,w) of the visual shape + with respect to the link frame Returns: int: The return value is a non-negative int unique id for the visual shape or -1 if the call failed. @@ -2035,11 +2038,11 @@ class Dart(Simulator): int: object unique id. int: link index or -1 for the base int: visual geometry type (TBD) - np.float[3]: dimensions (size, local scale) of the geometry + np.array[float[3]]: dimensions (size, local scale) of the geometry str: path to the triangle mesh, if any. Typically relative to the URDF, SDF or MJCF file location, but could be absolute - np.float[3]: position of local visual frame, relative to link/joint frame - np.float[4]: orientation of local visual frame relative to link/joint frame + np.array[float[3]]: position of local visual frame, relative to link/joint frame + np.array[float[4]]: orientation of local visual frame relative to link/joint frame list of 4 floats: URDF color (if any specified) in Red / Green / Blue / Alpha int: texture unique id of the shape or -1 if None. This field only exists if using VISUAL_SHAPE_DATA_TEXTURE_UNIQUE_IDS (=1) flag. @@ -2084,12 +2087,12 @@ class Dart(Simulator): of turning the camera to capture what we want in the world, we keep the camera fixed and turn the world. Args: - eye_position (np.float[3]): eye position in Cartesian world coordinates - target_position (np.float[3]): position of the target (focus) point in Cartesian world coordinates - up_vector (np.float[3]): up vector of the camera in Cartesian world coordinates + eye_position (np.array[float[3]]): eye position in Cartesian world coordinates + target_position (np.array[float[3]]): position of the target (focus) point in Cartesian world coordinates + up_vector (np.array[float[3]]): up vector of the camera in Cartesian world coordinates Returns: - np.float[4,4]: the view matrix + np.array[float[4,4]]: the view matrix """ pass @@ -2101,7 +2104,7 @@ class Dart(Simulator): of turning the camera to capture what we want in the world, we keep the camera fixed and turn the world. Args: - target_position (np.float[3]): target focus point in Cartesian world coordinates + target_position (np.array[float[3]]): target focus point in Cartesian world coordinates distance (float): distance from eye to focus point yaw (float): yaw angle in radians left/right around up-axis pitch (float): pitch in radians up/down. @@ -2109,7 +2112,7 @@ class Dart(Simulator): up_axis_index (int): either 1 for Y or 2 for Z axis up. Returns: - np.float[4,4]: the view matrix + np.array[float[4,4]]: the view matrix """ pass @@ -2134,7 +2137,7 @@ class Dart(Simulator): far (float): far plane distance Returns: - np.float[4,4]: the perspective projection matrix + np.array[float[4,4]]: the perspective projection matrix """ pass @@ -2148,7 +2151,7 @@ class Dart(Simulator): far (float): far plane distance Returns: - np.float[4,4]: the perspective projection matrix + np.array[float[4,4]]: the perspective projection matrix """ pass @@ -2162,11 +2165,11 @@ class Dart(Simulator): Args: width (int): horizontal image resolution in pixels height (int): vertical image resolution in pixels - view_matrix (np.float[4,4]): 4x4 view matrix, see `compute_view_matrix` - projection_matrix (np.float[4,4]): 4x4 projection matrix, see `compute_projection` - light_direction (np.float[3]): `light_direction` specifies the world position of the light source, + view_matrix (np.array[float[4,4]]): 4x4 view matrix, see `compute_view_matrix` + projection_matrix (np.array[float[4,4]]): 4x4 projection matrix, see `compute_projection` + light_direction (np.array[float[3]]): `light_direction` specifies the world position of the light source, the direction is from the light source position to the origin of the world frame. - light_color (np.float[3]): directional light color in [RED,GREEN,BLUE] in range 0..1 + light_color (np.array[float[3]]): directional light color in [RED,GREEN,BLUE] in range 0..1 light_distance (float): distance of the light along the normalized `light_direction` shadow (bool): True for shadows, False for no shadows light_ambient_coeff (float): light ambient coefficient @@ -2178,9 +2181,9 @@ class Dart(Simulator): Returns: int: width image resolution in pixels (horizontal) int: height image resolution in pixels (vertical) - np.int[width, height, 4]: RBGA pixels (each pixel is in the range [0..255] for each channel R, G, B, A) - np.float[width, heigth]: Depth buffer. - np.int[width, height]: Segmentation mask buffer. For each pixels the visible object unique id. + np.array[int[width, height, 4]]: RBGA pixels (each pixel is in the range [0..255] for each channel). + np.array[float[width, heigth]]: Depth buffer. + np.array[int[width, height]]: Segmentation mask buffer. For each pixels the visible object unique id. """ pass @@ -2193,11 +2196,11 @@ class Dart(Simulator): Args: width (int): horizontal image resolution in pixels height (int): vertical image resolution in pixels - view_matrix (np.float[4,4]): 4x4 view matrix, see `compute_view_matrix` - projection_matrix (np.float[4,4]): 4x4 projection matrix, see `compute_projection` - light_direction (np.float[3]): `light_direction` specifies the world position of the light source, + view_matrix (np.array[float[4,4]]): 4x4 view matrix, see `compute_view_matrix` + projection_matrix (np.array[float[4,4]]): 4x4 projection matrix, see `compute_projection` + light_direction (np.array[float[3]]): `light_direction` specifies the world position of the light source, the direction is from the light source position to the origin of the world frame. - light_color (np.float[3]): directional light color in [RED,GREEN,BLUE] in range 0..1 + light_color (np.array[float[3]]): directional light color in [RED,GREEN,BLUE] in range 0..1 light_distance (float): distance of the light along the normalized `light_direction` shadow (bool): True for shadows, False for no shadows light_ambient_coeff (float): light ambient coefficient @@ -2207,7 +2210,7 @@ class Dart(Simulator): flags (int): flags. Returns: - np.int[width, height, 4]: RBGA pixels (each pixel is in the range [0..255] for each channel R, G, B, A) + np.array[int[width, height, 4]]: RBGA pixels (each pixel is in the range [0..255] for each channel). """ pass @@ -2220,11 +2223,11 @@ class Dart(Simulator): Args: width (int): horizontal image resolution in pixels height (int): vertical image resolution in pixels - view_matrix (np.float[4,4]): 4x4 view matrix, see `compute_view_matrix` - projection_matrix (np.float[4,4]): 4x4 projection matrix, see `compute_projection` - light_direction (np.float[3]): `light_direction` specifies the world position of the light source, + view_matrix (np.array[float[4,4]]): 4x4 view matrix, see `compute_view_matrix` + projection_matrix (np.array[float[4,4]]): 4x4 projection matrix, see `compute_projection` + light_direction (np.array[float[3]]): `light_direction` specifies the world position of the light source, the direction is from the light source position to the origin of the world frame. - light_color (np.float[3]): directional light color in [RED,GREEN,BLUE] in range 0..1 + light_color (np.array[float[3]]): directional light color in [RED,GREEN,BLUE] in range 0..1 light_distance (float): distance of the light along the normalized `light_direction` shadow (bool): True for shadows, False for no shadows light_ambient_coeff (float): light ambient coefficient @@ -2234,7 +2237,7 @@ class Dart(Simulator): flags (int): flags. Returns: - np.float[width, heigth]: Depth buffer. + np.array[float[width, heigth]]: Depth buffer. """ pass @@ -2248,11 +2251,11 @@ class Dart(Simulator): Args: width (int): horizontal image resolution in pixels height (int): vertical image resolution in pixels - view_matrix (np.float[4,4]): 4x4 view matrix, see `compute_view_matrix` - projection_matrix (np.float[4,4]): 4x4 projection matrix, see `compute_projection` - light_direction (np.float[3]): `light_direction` specifies the world position of the light source, + view_matrix (np.array[float[4,4]]): 4x4 view matrix, see `compute_view_matrix` + projection_matrix (np.array[float[4,4]]): 4x4 projection matrix, see `compute_projection` + light_direction (np.array[float[3]]): `light_direction` specifies the world position of the light source, the direction is from the light source position to the origin of the world frame. - light_color (np.float[3]): directional light color in [RED,GREEN,BLUE] in range 0..1 + light_color (np.array[float[3]]): directional light color in [RED,GREEN,BLUE] in range 0..1 light_distance (float): distance of the light along the normalized `light_direction` shadow (bool): True for shadows, False for no shadows light_ambient_coeff (float): light ambient coefficient @@ -2262,7 +2265,7 @@ class Dart(Simulator): flags (int): flags Returns: - np.int[width, height]: Segmentation mask buffer. For each pixels the visible object unique id. + np.array[int[width, height]]: Segmentation mask buffer. For each pixels the visible object unique id. """ pass @@ -2280,17 +2283,17 @@ class Dart(Simulator): shape_type (int): type of shape; GEOM_SPHERE (=2), GEOM_BOX (=3), GEOM_CAPSULE (=7), GEOM_CYLINDER (=4), GEOM_PLANE (=6), GEOM_MESH (=5) radius (float): only for GEOM_SPHERE, GEOM_CAPSULE, GEOM_CYLINDER - half_extents (np.float[3], list/tuple of 3 floats): only for GEOM_BOX. + half_extents (np.array[float[3]], list/tuple of 3 floats): only for GEOM_BOX. height (float): only for GEOM_CAPSULE, GEOM_CYLINDER (length = height). filename (str): Filename for GEOM_MESH, currently only Wavefront .obj. Will create convex hulls for each object (marked as 'o') in the .obj file. - mesh_scale (np.float[3], list/tuple of 3 floats): scale of mesh (only for GEOM_MESH). - plane_normal (np.float[3], list/tuple of 3 floats): plane normal (only for GEOM_PLANE). + mesh_scale (np.array[float[3]], list/tuple of 3 floats): scale of mesh (only for GEOM_MESH). + plane_normal (np.array[float[3]], list/tuple of 3 floats): plane normal (only for GEOM_PLANE). flags (int): unused / to be decided - collision_frame_position (np.float[3]): translational offset of the collision shape with respect to the - link frame - collision_frame_orientation (np.float[4]): rotational offset (quaternion x,y,z,w) of the collision shape - with respect to the link frame + collision_frame_position (np.array[float[3]]): translational offset of the collision shape with respect to + the link frame + collision_frame_orientation (np.array[float[4]]): rotational offset (quaternion x,y,z,w) of the collision + shape with respect to the link frame Returns: int: The return value is a non-negative int unique id for the collision shape or -1 if the call failed. @@ -2309,14 +2312,14 @@ class Dart(Simulator): int: object unique id. int: link id. int: geometry type; GEOM_BOX (=3), GEOM_SPHERE (=2), GEOM_CAPSULE (=7), GEOM_MESH (=5), GEOM_PLANE (=6) - np.float[3]: depends on geometry type: + np.array[float[3]]: depends on geometry type: for GEOM_BOX: extents, for GEOM_SPHERE: dimensions[0] = radius, for GEOM_CAPSULE and GEOM_CYLINDER: dimensions[0] = height (length), dimensions[1] = radius. For GEOM_MESH: dimensions is the scaling factor. str: Only for GEOM_MESH: file name (and path) of the collision mesh asset. - np.float[3]: Local position of the collision frame with respect to the center of mass/inertial frame - np.float[4]: Local orientation of the collision frame with respect to the inertial frame + np.array[float[3]]: Local position of the collision frame with respect to the center of mass/inertial frame + np.array[float[4]]: Local orientation of the collision frame with respect to the inertial frame """ pass @@ -2328,11 +2331,11 @@ class Dart(Simulator): enlarges the AABBs a bit (extra margin and extruded along the velocity vector). Args: - aabb_min (np.float[3]): minimum coordinates of the aabb - aabb_max (np.float[3]): maximum coordinates of the aabb + aabb_min (np.array[float[3]]): minimum coordinates of the aabb + aabb_max (np.array[float[3]]): maximum coordinates of the aabb Returns: - list of int: list of object unique ids. + list[int]: list of object unique ids. """ pass @@ -2346,8 +2349,8 @@ class Dart(Simulator): link_id (int): link index in range [0..`getNumJoints(..)] Returns: - np.float[3]: minimum coordinates of the axis aligned bounding box - np.float[3]: maximum coordinates of the axis aligned bounding box + np.array[float[3]]: minimum coordinates of the axis aligned bounding box + np.array[float[3]]: maximum coordinates of the axis aligned bounding box """ pass @@ -2369,15 +2372,15 @@ class Dart(Simulator): int: body unique id of body B int: link index of body A, -1 for base int: link index of body B, -1 for base - np.float[3]: contact position on A, in Cartesian world coordinates - np.float[3]: contact position on B, in Cartesian world coordinates - np.float[3]: contact normal on B, pointing towards A + np.array[float[3]]: contact position on A, in Cartesian world coordinates + np.array[float[3]]: contact position on B, in Cartesian world coordinates + np.array[float[3]]: contact normal on B, pointing towards A float: contact distance, positive for separation, negative for penetration float: normal force applied during the last `step` float: lateral friction force in the first lateral friction direction (see next returned value) - np.float[3]: first lateral friction direction + np.array[float[3]]: first lateral friction direction float: lateral friction force in the second lateral friction direction (see next returned value) - np.float[3]: second lateral friction direction + np.array[float[3]]: second lateral friction direction """ # results: contact point, normal and penetration depth results = self.world.checkCollision() @@ -2403,15 +2406,15 @@ class Dart(Simulator): int: body unique id of body B int: link index of body A, -1 for base int: link index of body B, -1 for base - np.float[3]: contact position on A, in Cartesian world coordinates - np.float[3]: contact position on B, in Cartesian world coordinates - np.float[3]: contact normal on B, pointing towards A + np.array[float[3]]: contact position on A, in Cartesian world coordinates + np.array[float[3]]: contact position on B, in Cartesian world coordinates + np.array[float[3]]: contact normal on B, pointing towards A float: contact distance, positive for separation, negative for penetration float: normal force applied during the last `step`. Always equal to 0. float: lateral friction force in the first lateral friction direction (see next returned value) - np.float[3]: first lateral friction direction + np.array[float[3]]: first lateral friction direction float: lateral friction force in the second lateral friction direction (see next returned value) - np.float[3]: second lateral friction direction + np.array[float[3]]: second lateral friction direction """ pass @@ -2420,16 +2423,16 @@ class Dart(Simulator): Performs a single raycast to find the intersection information of the first object hit. Args: - from_position (np.float[3]): start of the ray in world coordinates - to_position (np.float[3]): end of the ray in world coordinates + from_position (np.array[float[3]]): start of the ray in world coordinates + to_position (np.array[float[3]]): end of the ray in world coordinates Returns: list: int: object unique id of the hit object int: link index of the hit object, or -1 if none/parent float: hit fraction along the ray in range [0,1] along the ray. - np.float[3]: hit position in Cartesian world coordinates - np.float[3]: hit normal in Cartesian world coordinates + np.array[float[3]]: hit position in Cartesian world coordinates + np.array[float[3]]: hit normal in Cartesian world coordinates """ pass @@ -2442,8 +2445,8 @@ class Dart(Simulator): the objectUniqueId is -1, there is no hit. In that case, the 'hit fraction' is 1. Args: - from_positions (np.array[N,3]): list of start points for each ray, in world coordinates - to_positions (np.array[N,3]): list of end points for each ray in world coordinates + from_positions (np.array[float[N,3]]): list of start points for each ray, in world coordinates + to_positions (np.array[float[N,3]]): list of end points for each ray in world coordinates parent_object_id (int): ray from/to is in local space of a parent object parent_link_id (int): ray from/to is in local space of a parent object @@ -2452,8 +2455,8 @@ class Dart(Simulator): int: object unique id of the hit object int: link index of the hit object, or -1 if none/parent float: hit fraction along the ray in range [0,1] along the ray. - np.float[3]: hit position in Cartesian world coordinates - np.float[3]: hit normal in Cartesian world coordinates + np.array[float[3]]: hit position in Cartesian world coordinates + np.array[float[3]]: hit normal in Cartesian world coordinates """ pass @@ -2499,10 +2502,10 @@ class Dart(Simulator): Returns: float: mass in kg float: lateral friction coefficient - np.float[3]: local inertia diagonal. Note that links and base are centered around the center of mass and - aligned with the principal axes of inertia. - np.float[3]: position of inertial frame in local coordinates of the joint frame - np.float[4]: orientation of inertial frame in local coordinates of joint frame + np.array[float[3]]: local inertia diagonal. Note that links and base are centered around the center of mass + and aligned with the principal axes of inertia. + np.array[float[3]]: position of inertial frame in local coordinates of the joint frame + np.array[float[4]]: orientation of inertial frame in local coordinates of joint frame float: coefficient of restitution float: rolling friction coefficient orthogonal to contact normal float: spinning friction coefficient around contact normal @@ -2555,9 +2558,9 @@ class Dart(Simulator): section. friction_anchor (int): enable or disable a friction anchor: positional friction correction (disabled by default, unless set in the URDF contact section) - local_inertia_diagonal (np.float[3]): diagonal elements of the inertia tensor. Note that the base and - links are centered around the center of mass and aligned with the principal axes of inertia so there - are no off-diagonal elements in the inertia tensor. + local_inertia_diagonal (np.array[float[3]]): diagonal elements of the inertia tensor. Note that the base + and links are centered around the center of mass and aligned with the principal axes of inertia so + there are no off-diagonal elements in the inertia tensor. joint_damping (float): joint damping coefficient applied at each joint. This coefficient is read from URDF joint damping field. Keep the value close to 0. `joint_damping_force = -damping_coefficient * joint_velocity`. @@ -2601,15 +2604,15 @@ class Dart(Simulator): Args: body_id (int): unique body id. link_id (int): link id. - local_position (np.float[3]): the point on the specified link to compute the Jacobian (in link local + local_position (np.array[float[3]]): the point on the specified link to compute the Jacobian (in link local coordinates around its center of mass). If None, it will use the CoM position (in the link frame). - q (np.float[N]): joint positions of size N, where N is the number of DoFs. - dq (np.float[N]): joint velocities of size N, where N is the number of DoFs. - des_ddq (np.float[N]): desired joint accelerations of size N. + q (np.array[float[N]]): joint positions of size N, where N is the number of DoFs. + dq (np.array[float[N]]): joint velocities of size N, where N is the number of DoFs. + des_ddq (np.array[float[N]]): desired joint accelerations of size N. Returns: - np.float[6,N], np.float[6,(6+N)]: full geometric (linear and angular) Jacobian matrix. The number of - columns depends if the base is fixed or floating. + np.array[float[6,N]], np.array[float[6,6+N]]: full geometric (linear and angular) Jacobian matrix. The + number of columns depends if the base is fixed or floating. """ skeleton = self.world.getSkeleton(body_id) body = skeleton.getBodyNode(link_id + 1) @@ -2633,10 +2636,10 @@ class Dart(Simulator): Args: body_id (int): body unique id. - q (np.float[N]): joint positions of size N, where N is the total number of DoFs. + q (np.array[float[N]]): joint positions of size N, where N is the total number of DoFs. Returns: - np.float[N,N], np.float[6+N,6+N]: inertia matrix + np.array[float[N,N]], np.array[float[6+N,6+N]]: inertia matrix """ skeleton = self.world.getSkeleton(body_id) # TODO: set q? @@ -2658,28 +2661,28 @@ class Dart(Simulator): Args: body_id (int): body unique id, as returned by `load_urdf`, etc. link_id (int): end effector link index. - position (np.float[3]): target position of the end effector (its link coordinate, not center of mass + position (np.array[float[3]]): target position of the end effector (its link coordinate, not center of mass coordinate!). By default this is in Cartesian world space, unless you provide `q_curr` joint angles. - orientation (np.float[4]): target orientation in Cartesian world space, quaternion [x,y,w,z]. If not + orientation (np.array[float[4]]): target orientation in Cartesian world space, quaternion [x,y,w,z]. If not specified, pure position IK will be used. - lower_limits (np.float[N], list of N floats): lower joint limits. Optional null-space IK. - upper_limits (np.float[N], list of N floats): upper joint limits. Optional null-space IK. - joint_ranges (np.float[N], list of N floats): range of value of each joint. - rest_poses (np.float[N], list of N floats): joint rest poses. Favor an IK solution closer to a given rest - pose. - joint_dampings (np.float[N], list of N floats): joint damping factors. Allow to tune the IK solution using - joint damping factors. + lower_limits (np.array[float[N]], list of N floats): lower joint limits. Optional null-space IK. + upper_limits (np.array[float[N]], list of N floats): upper joint limits. Optional null-space IK. + joint_ranges (np.array[float[N]], list of N floats): range of value of each joint. + rest_poses (np.array[float[N]], list of N floats): joint rest poses. Favor an IK solution closer to a + given rest pose. + joint_dampings (np.array[float[N]], list of N floats): joint damping factors. Allow to tune the IK solution + using joint damping factors. solver (int): p.IK_DLS (=0) or p.IK_SDLS (=1), Damped Least Squares or Selective Damped Least Squares, as described in the paper by Samuel Buss "Selectively Damped Least Squares for Inverse Kinematics". - q_curr (np.float[N]): list of joint positions. By default PyBullet uses the joint positions of the body. - If provided, the target_position and targetOrientation is in local space! + q_curr (np.array[float[N]]): list of joint positions. By default PyBullet uses the joint positions of the + body. If provided, the target_position and targetOrientation is in local space! max_iters (int): maximum number of iterations. Refine the IK solution until the distance between target and actual end effector position is below this threshold, or the `max_iters` is reached. threshold (float): residual threshold. Refine the IK solution until the distance between target and actual end effector position is below this threshold, or the `max_iters` is reached. Returns: - np.float[N]: joint positions (for each actuated joint). + np.array[float[N]]: joint positions (for each actuated joint). """ pass @@ -2715,12 +2718,12 @@ class Dart(Simulator): Args: body_id (int): body unique id. - q (np.float[N]): joint positions - dq (np.float[N]): joint velocities - des_ddq (np.float[N]): desired joint accelerations + q (np.array[float[N]]): joint positions + dq (np.array[float[N]]): joint velocities + des_ddq (np.array[float[N]]): desired joint accelerations Returns: - np.float[N]: joint torques computed using the rigid-body equation of motion + np.array[float[N]]: joint torques computed using the rigid-body equation of motion References: - [1] "Rigid Body Dynamics Algorithms", Featherstone, 2008, chap1.1 @@ -2766,12 +2769,12 @@ class Dart(Simulator): Args: body_id (int): unique body id. - q (np.float[N]): joint positions - dq (np.float[N]): joint velocities - torques (np.float[N]): desired joint torques + q (np.array[float[N]]): joint positions + dq (np.array[float[N]]): joint velocities + torques (np.array[float[N]]): desired joint torques Returns: - np.float[N]: joint accelerations computed using the rigid-body equation of motion + np.array[float[N]]: joint accelerations computed using the rigid-body equation of motion References: - [1] "Rigid Body Dynamics Algorithms", Featherstone, 2008, chap1.1 @@ -2799,9 +2802,9 @@ class Dart(Simulator): a line width and a duration in seconds. Args: - from_pos (np.float[3]): starting point of the line in Cartesian world coordinates - to_pos (np.float[3]): end point of the line in Cartesian world coordinates - rgb_color (np.float[3]): RGB color (each channel in range [0,1]) + from_pos (np.array[float[3]]): starting point of the line in Cartesian world coordinates + to_pos (np.array[float[3]]): end point of the line in Cartesian world coordinates + rgb_color (np.array[float[3]]): RGB color (each channel in range [0,1]) width (float): line width (limited by OpenGL implementation). lifetime (float): use 0 for permanent line, or positive time in seconds (afterwards the line with be removed automatically) @@ -2821,16 +2824,16 @@ class Dart(Simulator): Args: text (str): text. - position (np.float[3]): 3d position of the text in Cartesian world coordinates. + position (np.array[float[3]]): 3d position of the text in Cartesian world coordinates. rgb_color (list/tuple of 3 floats): RGB color; each component in range [0..1] size (float): text size lifetime (float): use 0 for permanent text, or positive time in seconds (afterwards the text with be removed automatically) - orientation (np.float[4]): By default, debug text will always face the camera, automatically rotation. - By specifying a text orientation (quaternion), the orientation will be fixed in world space or local - space (when parent is specified). Note that a different implementation/shader is used for camera - facing text, with different appearance: camera facing text uses bitmap fonts, text with specified - orientation uses TrueType font. + orientation (np.array[float[4]]): By default, debug text will always face the camera, automatically + rotation. By specifying a text orientation (quaternion), the orientation will be fixed in world space + or local space (when parent is specified). Note that a different implementation/shader is used for + camera facing text, with different appearance: camera facing text uses bitmap fonts, text with + specified orientation uses TrueType font. parent_object_id (int): draw text in local coordinates of a parent object. parent_link_id (int): draw text in local coordinates of a parent link. text_id (int): replace an existing text item (to avoid flickering of remove/add). @@ -3009,18 +3012,18 @@ class Dart(Simulator): Returns: float: width of the visualizer camera float: height of the visualizer camera - np.float[4,4]: view matrix [4,4] - np.float[4,4]: perspective projection matrix [4,4] - np.float[3]: camera up vector expressed in the Cartesian world space - np.float[3]: forward axis of the camera expressed in the Cartesian world space - np.float[3]: This is a horizontal vector that can be used to generate rays (for mouse picking or creating - a simple ray tracer for example) - np.float[3]: This is a vertical vector that can be used to generate rays (for mouse picking or creating a - simple ray tracer for example) + np.array[float[4,4]]: view matrix [4,4] + np.array[float[4,4]]: perspective projection matrix [4,4] + np.array[float[3]]: camera up vector expressed in the Cartesian world space + np.array[float[3]]: forward axis of the camera expressed in the Cartesian world space + np.array[float[3]]: This is a horizontal vector that can be used to generate rays (for mouse picking or + creating a simple ray tracer for example) + np.array[float[3]]: This is a vertical vector that can be used to generate rays (for mouse picking or + creating a simple ray tracer for example) float: yaw angle (in radians) of the camera, in Cartesian local space coordinates float: pitch angle (in radians) of the camera, in Cartesian local space coordinates float: distance between the camera and the camera target - np.float[3]: target of the camera, in Cartesian world space coordinates + np.array[float[3]]: target of the camera, in Cartesian world space coordinates """ pass @@ -3034,7 +3037,7 @@ class Dart(Simulator): distance (float): distance from eye to camera target position yaw (float): camera yaw angle (in radians) left/right pitch (float): camera pitch angle (in radians) up/down - target_position (np.float[3]): target focus point of the camera + target_position (np.array[float[3]]): target focus point of the camera """ pass diff --git a/pyrobolearn/simulators/gazebo.py b/pyrobolearn/simulators/gazebo.py index c716874..7c69e43 100644 --- a/pyrobolearn/simulators/gazebo.py +++ b/pyrobolearn/simulators/gazebo.py @@ -20,7 +20,7 @@ References: from pyrobolearn.simulators.simulator import Simulator __author__ = "Brian Delhaisse" -__copyright__ = "Copyright 2018, PyRoboLearn" +__copyright__ = "Copyright 2019, PyRoboLearn" __credits__ = ["Gazebo", "ROS", "Brian Delhaisse"] __license__ = "GNU GPLv3" __version__ = "1.0.0" diff --git a/pyrobolearn/simulators/gazebo_ros.py b/pyrobolearn/simulators/gazebo_ros.py index 88203ef..23a9508 100644 --- a/pyrobolearn/simulators/gazebo_ros.py +++ b/pyrobolearn/simulators/gazebo_ros.py @@ -42,7 +42,7 @@ import tf.transformations as tft from pyrobolearn.simulators.ros_rbdl import ROS_RBDL __author__ = "Brian Delhaisse" -__copyright__ = "Copyright 2018, PyRoboLearn" +__copyright__ = "Copyright 2019, PyRoboLearn" __credits__ = ["Brian Delhaisse"] __license__ = "GNU GPLv3" __version__ = "1.0.0" @@ -116,7 +116,7 @@ class GazeboROS(ROS_RBDL): rospy.wait_for_service('/gazebo/reset_simulation') try: self.reset_srv() - except rospy.ServiceException, e: + except rospy.ServiceException as e: print("/gazebo/reset_simulation service call failed") def close(self): @@ -139,7 +139,7 @@ class GazeboROS(ROS_RBDL): rospy.wait_for_service('/gazebo/set_seed') try: rospy.ServiceProxy('/gazebo/set_seed', SetSeedSrv)(seed) - except rospy.ServiceException, e: + except rospy.ServiceException as e: print("/GazeboRosGym/set_seed service call failed") return [seed] @@ -170,7 +170,7 @@ class GazeboROS(ROS_RBDL): rospy.wait_for_service('/gazebo/set_physics_properties') try: self.set_physics_properties_srv(set_physics_request) - except rospy.ServiceException, e: + except rospy.ServiceException as e: print("/gazebo/reset_simulation service call failed") def set_real_time(self): @@ -182,7 +182,7 @@ class GazeboROS(ROS_RBDL): rospy.wait_for_service('/gazebo/pause_physics') try: self.pause_srv() - except rospy.ServiceException, e: + except rospy.ServiceException as e: print("/gazebo/pause_physics service call failed") def unpause(self): @@ -190,7 +190,7 @@ class GazeboROS(ROS_RBDL): rospy.wait_for_service('/gazebo/unpause_physics') try: self.unpause_srv() - except rospy.ServiceException, e: + except rospy.ServiceException as e: print("/gazebo/unpause_physics service call failed") def get_physics_properties(self): @@ -198,7 +198,7 @@ class GazeboROS(ROS_RBDL): rospy.wait_for_service('/gazebo/get_physics_properties') try: srv = self.get_physics_properties_srv() - except rospy.ServiceException, e: + except rospy.ServiceException as e: print("/gazebo/reset_simulation service call failed") return srv @@ -207,7 +207,7 @@ class GazeboROS(ROS_RBDL): rospy.wait_for_service('/gazebo/set_physics_properties') try: self.set_physics_properties_srv() - except rospy.ServiceException, e: + except rospy.ServiceException as e: print("/gazebo/reset_simulation service call failed") def start_logging(self, *args, **kwargs): @@ -231,7 +231,7 @@ class GazeboROS(ROS_RBDL): rospy.wait_for_service('/gazebo/set_physics_properties') try: self.set_physics_properties_srv(set_physics_request) - except rospy.ServiceException, e: + except rospy.ServiceException as e: print("/gazebo/reset_simulation service call failed") def save(self, on_disk=False): @@ -394,7 +394,7 @@ class GazeboROSEnv(gazebo_env.GazeboEnv): rospy.wait_for_service('/GazeboRosGym/set_seed') try: rospy.ServiceProxy('/GazeboRosGym/set_seed', SetSeed)(seed) - except rospy.ServiceException, e: + except rospy.ServiceException as e: print("/GazeboRosGym/set_seed service call failed") return [seed] @@ -405,7 +405,7 @@ class GazeboROSEnv(gazebo_env.GazeboEnv): rospy.wait_for_service('/gazebo/reset_simulation') try: self.reset_srv() - except rospy.ServiceException, e: + except rospy.ServiceException as e: print("/gazebo/reset_simulation service call failed") def pause_physics(self): @@ -415,7 +415,7 @@ class GazeboROSEnv(gazebo_env.GazeboEnv): rospy.wait_for_service('/gazebo/pause_physics') try: self.pause_srv() - except rospy.ServiceException, e: + except rospy.ServiceException as e: print("/gazebo/pause_physics service call failed") def unpause_physics(self): @@ -425,7 +425,7 @@ class GazeboROSEnv(gazebo_env.GazeboEnv): rospy.wait_for_service('/gazebo/unpause_physics') try: self.unpause_srv() - except rospy.ServiceException, e: + except rospy.ServiceException as e: print("/gazebo/unpause_physics service call failed") def configure(self, *args, **kwargs): diff --git a/pyrobolearn/simulators/mujoco.py b/pyrobolearn/simulators/mujoco.py index 9af6583..83fc71b 100644 --- a/pyrobolearn/simulators/mujoco.py +++ b/pyrobolearn/simulators/mujoco.py @@ -92,11 +92,11 @@ class Visual(object): Args: visual_id (int): unique visual id. dtype (str): primitive type {"plane", "sphere", "box", "capsule", "ellipsoid", "cylinder", "mesh"}. - size (float, tuple of float, np.array): size. + size (float, tuple of float, np.array[float]): size. mesh (str): path to mesh. color (tuple of 4 float): RGBA color. Each channel is between 0 and 1. - position (tuple of 3 float, np.array[3]): position. - orientation (tuple of 4 float, np.array[4]): quaternion (x,y,z,w) + position (tuple of 3 float, np.array[float[3]]): position. + orientation (tuple of 4 float, np.array[float[4]]): quaternion (x,y,z,w) """ self.id = visual_id self.dtype = dtype @@ -120,8 +120,8 @@ class Collision(object): dtype (str): primitive type {"plane", "sphere", "box", "capsule", "ellipsoid", "cylinder", "mesh"}. size (float, tuple of float, np.array): size. mesh (str, None): path to the mesh. - position (tuple of 3 float, np.array[3]): position. - orientation (tuple of 4 float, np.array[4]): quaternion (x,y,z,w) + position (tuple of 3 float, np.array[float[3]]): position. + orientation (tuple of 4 float, np.array[float[4]]): quaternion (x,y,z,w) """ self.id = collision_id self.dtype = dtype @@ -554,7 +554,7 @@ class Mujoco(Simulator): self.sim.set_state(state) ###################################### - # loading URDFs, SDFs, MJCFs, meshes # + # Loading URDFs, SDFs, MJCFs, meshes # ###################################### def load_urdf(self, filename, position, orientation, use_fixed_base=0, scale=1.0, *args, **kwargs): @@ -677,8 +677,8 @@ class Mujoco(Simulator): collision_shape_id (int): unique id from createCollisionShape or -1. You can re-use the collision shape for multiple multibodies (instancing) mass (float): mass of the base, in kg (if using SI units) - position (np.array[3]): Cartesian world position of the base - orientation (np.array[4]): Orientation of base as quaternion [x,y,z,w] + position (np.array[float[3]]): Cartesian world position of the base + orientation (np.array[float[4]]): Orientation of base as quaternion [x,y,z,w] Returns: int: non-negative unique id or -1 for failure. @@ -829,7 +829,7 @@ class Mujoco(Simulator): return list(self.bodies.items())[index][0] ############### - # constraints # + # Constraints # ############### def create_constraint(self, parent_body_id, parent_link_id, child_body_id, child_link_id, joint_type, @@ -847,13 +847,13 @@ class Mujoco(Simulator): child_link_id (int): child link index, or -1 for the base joint_type (int): joint type: JOINT_PRISMATIC (=1), JOINT_FIXED (=4), JOINT_POINT2POINT (=5), JOINT_GEAR (=6) - joint_axis (np.array[3]): joint axis, in child link frame - parent_frame_position (np.array[3]): position of the joint frame relative to parent CoM frame. - child_frame_position (np.array[3]): position of the joint frame relative to a given child CoM frame (or - world origin if no child specified) - parent_frame_orientation (np.array[4]): the orientation of the joint frame relative to parent CoM + joint_axis (np.array[float[3]]): joint axis, in child link frame + parent_frame_position (np.array[float[3]]): position of the joint frame relative to parent CoM frame. + child_frame_position (np.array[float[3]]): position of the joint frame relative to a given child CoM frame + (or world origin if no child specified) + parent_frame_orientation (np.array[float[4]]): the orientation of the joint frame relative to parent CoM coordinate frame - child_frame_orientation (np.array[4]): the orientation of the joint frame relative to the child CoM + child_frame_orientation (np.array[float[4]]): the orientation of the joint frame relative to the child CoM coordinate frame (or world origin frame if no child specified) Returns: @@ -950,7 +950,7 @@ class Mujoco(Simulator): pass ########### - # objects # + # Objects # ########### def get_mass(self, body_id): @@ -995,11 +995,11 @@ class Mujoco(Simulator): Args: body_id (int): unique body id. - link_ids (list of int): link ids associated with the given body id. If None, it will take all the links + link_ids (list[int]): link ids associated with the given body id. If None, it will take all the links of the specified body. Returns: - np.array[3]: center of mass position in the Cartesian world coordinates + np.array[float[3]]: center of mass position in the Cartesian world coordinates """ return self.sim.data.subtree_com[body_id] @@ -1009,11 +1009,11 @@ class Mujoco(Simulator): Args: body_id (int): unique body id. - link_ids (list of int): link ids associated with the given body id. If None, it will take all the links + link_ids (list[int]): link ids associated with the given body id. If None, it will take all the links of the specified body. Returns: - np.array[3]: center of mass linear velocity. + np.array[float[3]]: center of mass linear velocity. """ return self.sim.data.subtree_linvel[body_id] @@ -1025,8 +1025,8 @@ class Mujoco(Simulator): body_id (int): object unique id, as returned from `load_urdf`. Returns: - np.array[3]: base position - np.array[4]: base orientation (quaternion [x,y,z,w]) + np.array[float[3]]: base position + np.array[float[4]]: base orientation (quaternion [x,y,z,w]) """ # WARNING: body_xpos is one step late compared to qpos # return self.sim.data.body_xpos[body_id], self._convert_wxyz_to_xyzw(self.sim.data.body_xquat[body_id]) @@ -1046,7 +1046,7 @@ class Mujoco(Simulator): body_id (int): object unique id, as returned from `load_urdf`. Returns: - np.array[3]: base position. + np.array[float[3]]: base position. """ # return self.sim.data.body_xpos[body_id] body = self.bodies[body_id] @@ -1061,7 +1061,7 @@ class Mujoco(Simulator): body_id (int): object unique id, as returned from `load_urdf`. Returns: - np.array[4]: base orientation in the form of a quaternion (x,y,z,w) + np.array[float[4]]: base orientation in the form of a quaternion (x,y,z,w) """ # return self._convert_wxyz_to_xyzw(self.sim.data.body_xquat[body_id]) body = self.bodies[body_id] @@ -1078,8 +1078,8 @@ class Mujoco(Simulator): Args: body_id (int): unique object id. - position (np.array[3]): new base position. - orientation (np.array[4]): new base orientation (expressed as a quaternion [x,y,z,w]) + position (np.array[float[3]]): new base position. + orientation (np.array[float[4]]): new base orientation (expressed as a quaternion [x,y,z,w]) """ body = self.bodies[body_id] q = self.sim.data.qpos @@ -1092,7 +1092,7 @@ class Mujoco(Simulator): Args: body_id (int): unique object id. - position (np.array[3]): new base position. + position (np.array[float[3]]): new base position. """ # self.sim.data.body_xpos[body_id] = position # self.sim.forward() @@ -1106,7 +1106,7 @@ class Mujoco(Simulator): Args: body_id (int): unique object id. - orientation (np.array[4]): new base orientation (expressed as a quaternion [x,y,z,w]) + orientation (np.array[float[4]]): new base orientation (expressed as a quaternion [x,y,z,w]) """ body = self.bodies[body_id] q = self.sim.data.qpos @@ -1120,8 +1120,8 @@ class Mujoco(Simulator): body_id (int): object unique id, as returned from `load_urdf`. Returns: - np.array[3]: linear velocity of the base in Cartesian world space coordinates - np.array[3]: angular velocity of the base in Cartesian world space coordinates + np.array[float[3]]: linear velocity of the base in Cartesian world space coordinates + np.array[float[3]]: angular velocity of the base in Cartesian world space coordinates """ body = self.bodies[body_id] dq = self.sim.data.qvel @@ -1135,7 +1135,7 @@ class Mujoco(Simulator): body_id (int): object unique id, as returned from `load_urdf`. Returns: - np.array[3]: linear velocity of the base in Cartesian world space coordinates + np.array[float[3]]: linear velocity of the base in Cartesian world space coordinates """ body = self.bodies[body_id] dq = self.sim.data.qvel @@ -1149,7 +1149,7 @@ class Mujoco(Simulator): body_id (int): object unique id, as returned from `load_urdf`. Returns: - np.array[3]: angular velocity of the base in Cartesian world space coordinates + np.array[float[3]]: angular velocity of the base in Cartesian world space coordinates """ body = self.bodies[body_id] dq = self.sim.data.qvel @@ -1161,8 +1161,8 @@ class Mujoco(Simulator): Args: body_id (int): unique object id. - linear_velocity (np.array[3]): new linear velocity of the base. - angular_velocity (np.array[3]): new angular velocity of the base. + linear_velocity (np.array[float[3]]): new linear velocity of the base. + angular_velocity (np.array[float[3]]): new angular velocity of the base. """ body = self.bodies[body_id] dq = self.sim.data.qvel @@ -1175,7 +1175,7 @@ class Mujoco(Simulator): Args: body_id (int): unique object id. - linear_velocity (np.array[3]): new linear velocity of the base + linear_velocity (np.array[float[3]]): new linear velocity of the base """ body = self.bodies[body_id] dq = self.sim.data.qvel @@ -1187,7 +1187,7 @@ class Mujoco(Simulator): Args: body_id (int): unique object id. - angular_velocity (np.array[3]): new angular velocity of the base + angular_velocity (np.array[float[3]]): new angular velocity of the base """ body = self.bodies[body_id] dq = self.sim.data.qvel @@ -1201,8 +1201,8 @@ class Mujoco(Simulator): body_id (int): unique object id. Returns: - np.array[3]: linear acceleration [m/s^2] - np.array[3]: angular acceleration [rad/s^2] + np.array[float[3]]: linear acceleration [m/s^2] + np.array[float[3]]: angular acceleration [rad/s^2] """ body = self.bodies[body_id] ddq = self.sim.data.qacc @@ -1215,8 +1215,8 @@ class Mujoco(Simulator): Args: body_id (int): unique body id. link_id (int): unique link id. If -1, it will be the base. - force (np.array[3]): external force to be applied. - position (np.array[3]): position on the link where the force is applied. See `flags` for coordinate + force (np.array[float[3]]): external force to be applied. + position (np.array[float[3]]): position on the link where the force is applied. See `flags` for coordinate systems. If None, it is the center of mass of the body (or the link if specified). frame (int): if frame = 1, then the force / position is described in the link frame. If frame = 2, they are described in the world frame. @@ -1238,7 +1238,7 @@ class Mujoco(Simulator): pass ############################# - # robots (joints and links) # + # Robots (joints and links) # ############################# def num_joints(self, body_id): @@ -1268,7 +1268,7 @@ class Mujoco(Simulator): return len(body.joints) ################# - # visualization # + # Visualization # ################# def create_visual_shape(self, shape_type, radius=0.5, half_extents=(1., 1., 1.), length=1., filename=None, @@ -1282,25 +1282,26 @@ class Mujoco(Simulator): shape_type (int): type of shape; GEOM_SPHERE (=2), GEOM_BOX (=3), GEOM_CAPSULE (=7), GEOM_CYLINDER (=4), GEOM_PLANE (=6), GEOM_MESH (=5), GEOM_ELLIPSOID (=9) radius (float): only for GEOM_SPHERE, GEOM_CAPSULE, GEOM_CYLINDER - half_extents (np.array[3], list/tuple of 3 floats): only for GEOM_BOX, and GEOM_ELLIPSOID + half_extents (np.array[float[3]], list/tuple of 3 floats): only for GEOM_BOX, and GEOM_ELLIPSOID length (float): only for GEOM_CAPSULE, GEOM_CYLINDER (length = height). filename (str): Filename for GEOM_MESH, currently only Wavefront .obj. Will create convex hulls for each object (marked as 'o') in the .obj file. - mesh_scale (np.array[3], list/tuple of 3 floats): scale of mesh (only for GEOM_MESH). - plane_normal (np.array[3], list/tuple of 3 floats): plane normal (only for GEOM_PLANE). + mesh_scale (np.array[float[3]], list/tuple of 3 floats): scale of mesh (only for GEOM_MESH). + plane_normal (np.array[float[3]], list/tuple of 3 floats): plane normal (only for GEOM_PLANE). flags (int): unused / to be decided rgba_color (list/tuple of 4 floats): color components for red, green, blue and alpha, each in range [0..1]. specular_color (list/tuple of 3 floats): specular reflection color, red, green, blue components in range [0..1] - visual_frame_position (np.array[3]): translational offset of the visual shape with respect to the link frame - vertices (list of np.array[3]): Instead of creating a mesh from obj file, you can provide vertices, indices, - uvs and normals - indices (list of int): triangle indices, should be a multiple of 3. + visual_frame_position (np.array[float[3]]): translational offset of the visual shape with respect to the + link frame. + vertices (list of np.array[float[3]]): Instead of creating a mesh from obj file, you can provide vertices, + indices, uvs and normals + indices (list[int]): triangle indices, should be a multiple of 3. uvs (list of np.array[2]): uv texture coordinates for vertices. Use changeVisualShape to choose the texture image. The number of uvs should be equal to number of vertices - normals (list of np.array[3]): vertex normals, number should be equal to number of vertices. - visual_frame_orientation (np.array[4]): rotational offset (quaternion x,y,z,w) of the visual shape with - respect to the link frame + normals (list of np.array[float[3]]): vertex normals, number should be equal to number of vertices. + visual_frame_orientation (np.array[float[4]]): rotational offset (quaternion x,y,z,w) of the visual shape + with respect to the link frame Returns: int: The return value is a non-negative int unique id for the visual shape or -1 if the call failed. @@ -1354,11 +1355,11 @@ class Mujoco(Simulator): int: object unique id. int: link index or -1 for the base int: visual geometry type (TBD) - np.array[3]: dimensions (size, local scale) of the geometry + np.array[float[3]]: dimensions (size, local scale) of the geometry str: path to the triangle mesh, if any. Typically relative to the URDF, SDF or MJCF file location, but could be absolute - np.array[3]: position of local visual frame, relative to link/joint frame - np.array[4]: orientation of local visual frame relative to link/joint frame + np.array[float[3]]: position of local visual frame, relative to link/joint frame + np.array[float[4]]: orientation of local visual frame relative to link/joint frame list of 4 floats: URDF color (if any specified) in Red / Green / Blue / Alpha int: texture unique id of the shape or -1 if None. This field only exists if using VISUAL_SHAPE_DATA_TEXTURE_UNIQUE_IDS (=1) flag. @@ -1429,11 +1430,11 @@ class Mujoco(Simulator): Args: width (int): horizontal image resolution in pixels height (int): vertical image resolution in pixels - view_matrix (np.array[4,4]): 4x4 view matrix, see `compute_view_matrix` - projection_matrix (np.array[4,4]): 4x4 projection matrix, see `compute_projection` - light_direction (np.array[3]): `light_direction` specifies the world position of the light source, + view_matrix (np.array[float[4,4]]): 4x4 view matrix, see `compute_view_matrix` + projection_matrix (np.array[float[4,4]]): 4x4 projection matrix, see `compute_projection` + light_direction (np.array[float[3]]): `light_direction` specifies the world position of the light source, the direction is from the light source position to the origin of the world frame. - light_color (np.array[3]): directional light color in [RED,GREEN,BLUE] in range 0..1 + light_color (np.array[float[3]]): directional light color in [RED,GREEN,BLUE] in range 0..1 light_distance (float): distance of the light along the normalized `light_direction` shadow (bool): True for shadows, False for no shadows light_ambient_coeff (float): light ambient coefficient @@ -1445,9 +1446,9 @@ class Mujoco(Simulator): Returns: int: width image resolution in pixels (horizontal) int: height image resolution in pixels (vertical) - np.int[width, height, 4]: RBGA pixels (each pixel is in the range [0..255] for each channel R, G, B, A) - np.array[width, heigth]: Depth buffer. - np.int[width, height]: Segmentation mask buffer. For each pixels the visible object unique id. + np.array[int[width, height, 4]]: RBGA pixels (each pixel is in the range [0..255] for each channel). + np.array[float[width, height]]: Depth buffer. + np.array[int[width, height]]: Segmentation mask buffer. For each pixels the visible object unique id. """ # based on the arguments, check the camera name camera_name = None @@ -1463,11 +1464,11 @@ class Mujoco(Simulator): Args: width (int): horizontal image resolution in pixels height (int): vertical image resolution in pixels - view_matrix (np.array[4,4]): 4x4 view matrix, see `compute_view_matrix` - projection_matrix (np.array[4,4]): 4x4 projection matrix, see `compute_projection` - light_direction (np.array[3]): `light_direction` specifies the world position of the light source, + view_matrix (np.array[float[4,4]]): 4x4 view matrix, see `compute_view_matrix` + projection_matrix (np.array[float[4,4]]): 4x4 projection matrix, see `compute_projection` + light_direction (np.array[float[3]]): `light_direction` specifies the world position of the light source, the direction is from the light source position to the origin of the world frame. - light_color (np.array[3]): directional light color in [RED,GREEN,BLUE] in range 0..1 + light_color (np.array[float[3]]): directional light color in [RED,GREEN,BLUE] in range 0..1 light_distance (float): distance of the light along the normalized `light_direction` shadow (bool): True for shadows, False for no shadows light_ambient_coeff (float): light ambient coefficient @@ -1477,7 +1478,7 @@ class Mujoco(Simulator): flags (int): flags. Returns: - np.int[width, height, 4]: RBGA pixels (each pixel is in the range [0..255] for each channel R, G, B, A) + np.array[int[width, height, 4]]: RBGA pixels (each pixel is in the range [0..255] for each channel). """ # based on the arguments, check the camera name camera_name = None @@ -1494,11 +1495,11 @@ class Mujoco(Simulator): Args: width (int): horizontal image resolution in pixels height (int): vertical image resolution in pixels - view_matrix (np.array[4,4]): 4x4 view matrix, see `compute_view_matrix` - projection_matrix (np.array[4,4]): 4x4 projection matrix, see `compute_projection` - light_direction (np.array[3]): `light_direction` specifies the world position of the light source, + view_matrix (np.array[float[4,4]]): 4x4 view matrix, see `compute_view_matrix` + projection_matrix (np.array[float[4,4]]): 4x4 projection matrix, see `compute_projection` + light_direction (np.array[float[3]]): `light_direction` specifies the world position of the light source, the direction is from the light source position to the origin of the world frame. - light_color (np.array[3]): directional light color in [RED,GREEN,BLUE] in range 0..1 + light_color (np.array[float[3]]): directional light color in [RED,GREEN,BLUE] in range 0..1 light_distance (float): distance of the light along the normalized `light_direction` shadow (bool): True for shadows, False for no shadows light_ambient_coeff (float): light ambient coefficient @@ -1508,7 +1509,7 @@ class Mujoco(Simulator): flags (int): flags. Returns: - np.array[width, height]: Depth buffer. + np.array[float[width, height]]: Depth buffer. """ # based on the arguments, check the camera name camera_name = None @@ -1531,17 +1532,17 @@ class Mujoco(Simulator): shape_type (int): type of shape; GEOM_SPHERE (=2), GEOM_BOX (=3), GEOM_CAPSULE (=7), GEOM_CYLINDER (=4), GEOM_PLANE (=6), GEOM_MESH (=5), GEOM_ELLIPSOID (=9) radius (float): only for GEOM_SPHERE, GEOM_CAPSULE, GEOM_CYLINDER - half_extents (np.array[3], list/tuple of 3 floats): only for GEOM_BOX. + half_extents (np.array[float[3]], list/tuple of 3 floats): only for GEOM_BOX. height (float): only for GEOM_CAPSULE, GEOM_CYLINDER (length = height). filename (str): Filename for GEOM_MESH, currently only Wavefront .obj. Will create convex hulls for each object (marked as 'o') in the .obj file. - mesh_scale (np.array[3], list/tuple of 3 floats): scale of mesh (only for GEOM_MESH). - plane_normal (np.array[3], list/tuple of 3 floats): plane normal (only for GEOM_PLANE). + mesh_scale (np.array[float[3]], list/tuple of 3 floats): scale of mesh (only for GEOM_MESH). + plane_normal (np.array[float[3]], list/tuple of 3 floats): plane normal (only for GEOM_PLANE). flags (int): unused / to be decided - collision_frame_position (np.array[3]): translational offset of the collision shape with respect to the - link frame - collision_frame_orientation (np.array[4]): rotational offset (quaternion x,y,z,w) of the collision shape - with respect to the link frame + collision_frame_position (np.array[float[3]]): translational offset of the collision shape with respect to + the link frame + collision_frame_orientation (np.array[float[4]]): rotational offset (quaternion x,y,z,w) of the collision + shape with respect to the link frame Returns: int: The return value is a non-negative int unique id for the collision shape or -1 if the call failed. @@ -1595,14 +1596,14 @@ class Mujoco(Simulator): int: object unique id. int: link id. int: geometry type; GEOM_BOX (=3), GEOM_SPHERE (=2), GEOM_CAPSULE (=7), GEOM_MESH (=5), GEOM_PLANE (=6) - np.array[3]: depends on geometry type: + np.array[float[3]]: depends on geometry type: for GEOM_BOX: extents, for GEOM_SPHERE: dimensions[0] = radius, for GEOM_CAPSULE and GEOM_CYLINDER: dimensions[0] = height (length), dimensions[1] = radius. For GEOM_MESH: dimensions is the scaling factor. str: Only for GEOM_MESH: file name (and path) of the collision mesh asset. - np.array[3]: Local position of the collision frame with respect to the center of mass/inertial frame - np.array[4]: Local orientation of the collision frame with respect to the inertial frame + np.array[float[3]]: Local position of the collision frame with respect to the center of mass/inertial frame + np.array[float[4]]: Local orientation of the collision frame with respect to the inertial frame """ pass @@ -1611,16 +1612,16 @@ class Mujoco(Simulator): Performs a single raycast to find the intersection information of the first object hit. Args: - from_position (np.array[3]): start of the ray in world coordinates - to_position (np.array[3]): end of the ray in world coordinates + from_position (np.array[float[3]]): start of the ray in world coordinates + to_position (np.array[float[3]]): end of the ray in world coordinates Returns: list: int: object unique id of the hit object int: link index of the hit object, or -1 if none/parent float: hit fraction along the ray in range [0,1] along the ray. - np.array[3]: hit position in Cartesian world coordinates - np.array[3]: hit normal in Cartesian world coordinates + np.array[float[3]]: hit position in Cartesian world coordinates + np.array[float[3]]: hit normal in Cartesian world coordinates """ vec = to_position - from_position return self.sim.ray(pnt=from_position, vec=vec) # this return the distance and id of the geom diff --git a/pyrobolearn/simulators/raisim.py b/pyrobolearn/simulators/raisim.py index b2128b8..0446fd7 100644 --- a/pyrobolearn/simulators/raisim.py +++ b/pyrobolearn/simulators/raisim.py @@ -3,8 +3,8 @@ This is the main interface that communicates with the RaiSim simulator [1-5]. By defining this interface, it allows to decouple the PyRoboLearn framework from the simulator. It also converts some data types to the ones required -by RaiSim. Because it didn't have a Python wrapper, one has been written using pybind11 [6]. This wrapper ``raisimpy`` -can be found in the following repository: https://github.com/robotlearn/raisimpy +by RaiSim. Because it didn't have a Python wrapper, one has been written using ``pybind11`` [6] and is available at: +https://github.com/robotlearn/raisimpy The signature of each method defined here are inspired by [1,2] but in accordance with the PEP8 style guide [7]. Parts of the documentation for the methods have been copied-pasted from [2-5] for completeness purposes. @@ -23,21 +23,27 @@ References: - [6] pybind11 (documentation): https://pybind11.readthedocs.io/en/stable/ - [7] PEP8: https://www.python.org/dev/peps/pep-0008/ - [8] RaiSim license: https://github.com/leggedrobotics/raisimLib/blob/master/LICENSE.md - - [9] raisimpy: https://github.com/robotlearn/raisimpy + - [9] RaiSimPy - A Python wrapper for Raisim: https://github.com/robotlearn/raisimpy """ +import os +import numpy as np + + # import raisim try: import raisimpy as raisim except ImportError as e: - print(e.__str__() + "\nHINT: you need to install `raisimLib`, `raisimOgre`, and `raisimpy") + print(e.__str__() + "\nHINT: you need to install `raisimLib` and `raisimOgre`, and build the Python wrappers " + "that are located in the `raisim_wrapper` folder.") # import PRL simulator from pyrobolearn.simulators.simulator import Simulator +from pyrobolearn.utils.decorator import keyboard_interrupt __author__ = "Brian Delhaisse" -__copyright__ = "Copyright 2018, PyRoboLearn" -__credits__ = ["RaiSim (ETHz, Hwangbo, Kang, Lee)", "Brian Delhaisse (Python wrappers + PRL)"] +__copyright__ = "Copyright 2019, PyRoboLearn" +__credits__ = ["RaiSim (ETHz, Hwangbo, Kang, Lee)", "Brian Delhaisse (raisimpy + PRL)"] __license__ = "GNU GPLv3" __version__ = "1.0.0" __maintainer__ = "Brian Delhaisse" @@ -48,15 +54,18 @@ __status__ = "Development" class Raisim(Simulator): r"""RaiSim - This is a wrapper around the RaiSim simulator [1,2]. Currently, the simulator is closed-source and is only - available for researchers at RSL and ETH Zurich. + This is a wrapper around ``raisimpy`` [6] which is a Python around the RaiSim simulator [1-5]. Examples: sim = Raisim() References: - [1] "Per-Contact Iteration Method for Solving Contact Dynamics", Hwangbo et al., 2018 - [2] RaiSim: https://leggedrobotics.github.io/SimBenchmark/about/sims.html + - [1] "Per-Contact Iteration Method for Solving Contact Dynamics", Hwangbo et al., 2018 + - [2] RaiSim, a physics engine for robotics and AI research: https://github.com/leggedrobotics/raisimLib + - [3] raisimOgre - Visualizer for raisim: https://github.com/leggedrobotics/raisimOgre + - [4] raisimGym - RL examples using raisim: https://github.com/leggedrobotics/raisimGym + - [5] RaiSim benchmark: https://leggedrobotics.github.io/SimBenchmark/about/sims.html + - [6] RaiSimPy - A Python wrapper for Raisim: https://github.com/robotlearn/raisimpy """ def __init__(self, render=True, **kwargs): @@ -66,11 +75,17 @@ class Raisim(Simulator): self.world = raisim.World() self.sim = self.world # alias - # create visualizer if specified - self.visualizer = None + # define default timestep + self.default_timestep = self.world.get_time_step() # 0.005 + self.dt = self.default_timestep - raise NotImplementedError("The RaiSim simulator is not currently available as it has not been released for " - "the moment") + # create visualizer and render if specified + self.visualizer = None + self._desired_fps = 60 + self.visualization_cnt = 0 + + if self._render: + self._init_visualization() ############## # Properties # @@ -84,18 +99,23 @@ class Raisim(Simulator): @property def gravity(self): """Return the gravity in the simulator.""" - return self.get_gravity() + return self.world.get_gravity() @gravity.setter def gravity(self, gravity): """Set the gravity in the simulator.""" - self.set_gravity(gravity) + self.world.set_gravity(gravity) @property def camera(self): """Return the camera (yaw, pitch, distance, target_position) or None.""" return self._camera + @property + def timestep(self): + """Return the simulator time step.""" + return self.dt + ############# # Operators # ############# @@ -128,11 +148,184 @@ class Raisim(Simulator): memo[self] = sim return sim + ################## + # Static methods # + ################## + + @staticmethod + def in_simulation(): + """Return True if we are running in simulation instead of the real-world.""" + return True + + @staticmethod + def simulate_gas_dynamics(): + """Return True if the simulator can simulate gases.""" + return False + + @staticmethod + def simulate_liquid_dynamics(): + """Return True if the simulator can simulate liquids.""" + return False + + @staticmethod + def simulate_fluid_dynamics(): + """Return True if the simulator can simulate fluids (gases and liquids).""" + return Simulator.simulate_gas_dynamics() and Simulator.simulate_liquid_dynamics() + + @staticmethod + def simulate_soft_bodies(): + """Return True if the simulator can simulate soft bodies.""" + return False + + @staticmethod + def has_middleware_communication_layer(): + """Return True if the simulator has a middleware communication layer (like ROS, YARP, etc).""" + return False + + @staticmethod + def supports_dynamic_loading(): + """Return True if the simulator supports the dynamic loading of models.""" + return True + + @staticmethod + def supports_acceleration(): + """Return True if the simulator provides acceleration (dynamic) information (such as joint accelerations, link + Cartesian accelerations, etc). If not, the `Robot` class will have to implement these using finite + difference.""" + return False + + @staticmethod + def supports_sensors(sensor_type=None): + """Return True if the simulator provides supports for the specified sensor.""" + return False + + @staticmethod + def supports_urdf(): + """Return True if we can use URDFs.""" + return True + + @staticmethod + def supports_light(): + """Return True if we can define and access to the lights in the simulator.""" + return True + + @staticmethod + def supports_depth_image(): + """Return True if we can get depth images from the simulator.""" + return False + + @staticmethod + def supports_segmentation_images(): + """Return True if we can get segmentation images from the simulator.""" + return False + + @staticmethod + def supports_visualization(): + """Return True if there is a graphical user interface (GUI).""" + return True + + @staticmethod + def supports_interactive_gui(): + """Return True if the simulator has an interactive GUI.""" + return True + + @staticmethod + def supports_mousekeyboard_events(): + """Return True if the simulator allows to capture mouse and keyboard events.""" + return True # however this requires some code + + @staticmethod + def supports_visual_objects(): + """Return True if we can simulate objects that do not have collision shapes.""" + return True # however it has to be coded in the wrapper + + @staticmethod + def supports_plugins(): + """Return True if we can use plugins.""" + return False + + @staticmethod + def supports_constraints(constraint_type): + """Return True if we can support the specified constraint type.""" + if constraint_type == 'wire': + return True + return False + + @staticmethod + def supports_realtime(): + """Return True if the simulator supports real-time (meaning we don't need to step manually in the simulator). + Note that if we can step in the simulator, we can use threads to simulate the real-time. So the return value + should always be True.""" + return True + + @staticmethod + def supports_ray_casting(): + """Return True if the simulator supports ray casting.""" + return False + + @staticmethod + def can_step(): + """Return True if we can step manually in the simulator.""" + return True + + @staticmethod + def can_load_heightmap(): + """Return True if the simulator can load a heightmap.""" + return True + ########### # Methods # ########### - # Simulators + def _init_visualization(self): + + def normalize(array): + return np.asarray(array) / np.linalg.norm(array) + + def setup_callback(): + vis = raisim.OgreVis.get() + + # light + light = vis.get_light() + light.set_diffuse_color(1, 1, 1) + light.set_cast_shadows(True) + light.set_direction(normalize([-3., -3., -0.5])) + vis.set_camera_speed(300) + + # load textures + vis.add_resource_directory(vis.get_resource_dir() + "/material/checkerboard") + vis.load_material("checkerboard.material") + + # shadow setting + manager = vis.get_scene_manager() + manager.set_shadow_technique(raisim.ogre.ShadowTechnique.SHADOWTYPE_TEXTURE_ADDITIVE) + manager.set_shadow_texture_settings(2048, 3) + + # scale related settings!! Please adapt it depending on your map size + # beyond this distance, shadow disappears + manager.set_shadow_far_distance(10) + # size of contact points and contact forces + vis.set_contact_visual_object_size(0.03, 0.6) + # speed of camera motion in freelook mode + vis.get_camera_man().set_top_speed(5) + + # these methods must be called before initApp + vis = raisim.OgreVis.get() + vis.set_world(self.world) + vis.set_window_size(1800, 1000) + vis.set_default_callbacks() + vis.set_setup_callback(setup_callback) + vis.set_anti_aliasing(2) + + # init + vis.init_app() + + # set visualizer + self.visualizer = vis + + ############# + # Simulator # + ############# def reset(self, *args, **kwargs): """Reset the simulator.""" @@ -140,19 +333,40 @@ class Raisim(Simulator): def close(self): """Close the simulator.""" - pass + if self.visualizer is not None: + self.visualizer.close_app() + self.visualizer = None def seed(self, seed=None): """Set the given seed in the simulator.""" + # if seed is not None: + # self.world.set_seed(seed) pass + @keyboard_interrupt def step(self, sleep_time=0): """Perform a step in the simulator, and sleep the specified amount of time. Args: sleep_time (float): amount of time to sleep after performing one step in the simulation. """ - pass + # update world/simulator + self.world.integrate() + + # if we need to render + if self._render: # TODO: should we create the visualizer in a thread?? + # if the visualizer is not defined, create one + if self.visualizer is None: + self._init_visualization() + + # update the frame if time to update it + vis_decimation = int(1. / (self._desired_fps * self.dt) + 1.e-10) + if self.visualization_cnt % vis_decimation == 0: + self.visualizer.render_one_frame() + self.visualization_cnt = 0 + + # update visualization counter + self.visualization_cnt += 1 def is_rendering(self): """Return True if the simulator is in the render mode.""" @@ -179,13 +393,22 @@ class Raisim(Simulator): """Hide the GUI.""" self.render(False) + def get_time_step(self): + """Get the time step in the simulator. + + Returns: + float: time step in the simulator + """ + return self.world.get_time_step() + def set_time_step(self, time_step): """Set the time step in the simulator. Args: time_step (float): Each time you call 'step' the time step will proceed with 'time_step'. """ - pass + self.dt = time_step + self.world.set_time_step(time_step) def set_real_time(self, enable=True): """Enable real time in the simulator. @@ -193,7 +416,11 @@ class Raisim(Simulator): Args: enable (bool): If True, it will enable the real-time simulation. If False, it will disable it. """ - pass + self.real_time = True + + def use_real_time(self): + """Return True if the simulator is in real-time mode.""" + return self.real_time def pause(self): """Pause the simulator if in real-time.""" @@ -221,7 +448,7 @@ class Raisim(Simulator): def get_gravity(self): """Return the gravity set in the simulator.""" - pass + return self.world.get_gravity() def set_gravity(self, gravity=(0, 0, -9.81)): """Set the gravity in the simulator with the given acceleration. @@ -229,7 +456,7 @@ class Raisim(Simulator): Args: gravity (list, tuple of 3 floats): acceleration in the x, y, z directions. """ - pass + self.world.set_gravity(gravity) def save(self, filename=None, *args, **kwargs): """Save the state of the simulator. @@ -251,38 +478,9 @@ class Raisim(Simulator): """ pass - def load_plugin(self, plugin_path, name, *args, **kwargs): - """Load a certain plugin in the simulator. - - Args: - plugin_path (str): path, location on disk where to find the plugin - name (str): postfix name of the plugin that is appended to each API - - Returns: - int: unique plugin id. If this id is negative, the plugin is not loaded. Once a plugin is loaded, you can - send commands to the plugin using `execute_plugin_commands` - """ - pass - - def execute_plugin_commands(self, plugin_id, *args, **kwargs): - """Execute the commands on the specified plugin. - - Args: - plugin_id (int): unique plugin id. - *args (list): list of argument values to be interpreted by the plugin. One can be a string, while the - others must be integers or float. - """ - pass - - def unload_plugin(self, plugin_id, *args, **kwargs): - """Unload the specified plugin from the simulator. - - Args: - plugin_id (int): unique plugin id. - """ - pass - - # loading URDFs, SDFs, MJCFs + ###################################### + # Loading URDFs, SDFs, MJCFs, meshes # + ###################################### def load_urdf(self, filename, position, orientation, use_fixed_base=0, scale=1.0, *args, **kwargs): """Load a URDF file in the simulator. @@ -346,47 +544,9 @@ class Raisim(Simulator): """ pass - @staticmethod - def get_available_sdfs(fullpath=False): - """Return the list of available SDFs in the simulator. - - Args: - fullpath (bool): If True, it will return the full path to the SDFs. If False, it will just return the - name of the SDF files (without the extension). - """ - return [] - - @staticmethod - def get_available_urdfs(fullpath=False): - """Return the list of available URDFs in the simulator. - - Args: - fullpath (bool): If True, it will return the full path to the URDFs. If False, it will just return the - name of the URDF files (without the extension). - """ - return [] - - @staticmethod - def get_available_mjcfs(fullpath=False): - """Return the list of available MJCFs in the simulator. - - Args: - fullpath (bool): If True, it will return the full path to the MJCFs. If False, it will just return the - name of the MJCF files (without the extension). - """ - return [] - - @staticmethod - def get_available_objs(fullpath=False): - """Return the list of available OBJs in the simulator. - - Args: - fullpath (bool): If True, it will return the full path to the OBJs. If False, it will just return the - name of the OBJ files (without the extension). - """ - return [] - - # bodies + ########## + # Bodies # + ########## def create_body(self, visual_shape_id=-1, collision_shape_id=-1, mass=0., position=(0., 0., 0.), orientation=(0., 0., 0., 1.), *args, **kwargs): @@ -397,8 +557,8 @@ class Raisim(Simulator): collision_shape_id (int): unique id from createCollisionShape or -1. You can re-use the collision shape for multiple multibodies (instancing) mass (float): mass of the base, in kg (if using SI units) - position (np.float[3]): Cartesian world position of the base - orientation (np.float[4]): Orientation of base as quaternion [x,y,z,w] + position (np.array[float[3]]): Cartesian world position of the base + orientation (np.array[float[4]]): Orientation of base as quaternion [x,y,z,w] Returns: int: non-negative unique id or -1 for failure. @@ -443,7 +603,9 @@ class Raisim(Simulator): """ pass - # constraint + ############### + # Constraints # + ############### def create_constraint(self, parent_body_id, parent_link_id, child_body_id, child_link_id, joint_type, joint_axis, parent_frame_position, child_frame_position, @@ -460,13 +622,13 @@ class Raisim(Simulator): child_link_id (int): child link index, or -1 for the base joint_type (int): joint type: JOINT_PRISMATIC (=1), JOINT_FIXED (=4), JOINT_POINT2POINT (=5), JOINT_GEAR (=6) - joint_axis (np.float[3]): joint axis, in child link frame - parent_frame_position (np.float[3]): position of the joint frame relative to parent CoM frame. - child_frame_position (np.float[3]): position of the joint frame relative to a given child CoM frame (or - world origin if no child specified) - parent_frame_orientation (np.float[4]): the orientation of the joint frame relative to parent CoM + joint_axis (np.array[float[3]]): joint axis, in child link frame + parent_frame_position (np.array[float[3]]): position of the joint frame relative to parent CoM frame. + child_frame_position (np.array[float[3]]): position of the joint frame relative to a given child CoM frame + (or world origin if no child specified) + parent_frame_orientation (np.array[float[4]]): the orientation of the joint frame relative to parent CoM coordinate frame - child_frame_orientation (np.float[4]): the orientation of the joint frame relative to the child CoM + child_frame_orientation (np.array[float[4]]): the orientation of the joint frame relative to the child CoM coordinate frame (or world origin frame if no child specified) Returns: @@ -537,1903 +699,37 @@ class Raisim(Simulator): """ pass - # objects + ########### + # Objects # + ########### - def get_mass(self, body_id): - """ - Return the total mass of the robot (=sum of all mass links). + ############################# + # Robots (joints and links) # + ############################# - Args: - body_id (int): unique object id, as returned from `load_urdf`. + ################# + # Visualization # + ################# - Returns: - float: total mass of the robot [kg] - """ - pass + ############## + # Collisions # + ############## - def get_base_mass(self, body_id): - """Return the base mass of the robot. - Args: - body_id (int): unique object id. - """ - pass +# Tests +if __name__ == '__main__': + from itertools import count - def get_base_name(self, body_id): - """ - Return the base name. + sim = Raisim(render=True) - Args: - body_id (int): unique object id. + print("Gravity: {}".format(sim.get_gravity())) - Returns: - str: base name - """ - pass + # create box - def get_center_of_mass_position(self, body_id, link_ids=None): - """ - Return the center of mass position. + # create visual sphere - Args: - body_id (int): unique body id. - link_ids (list of int): link ids associated with the given body id. If None, it will take all the links - of the specified body. + # load robot - Returns: - np.float[3]: center of mass position in the Cartesian world coordinates - """ - pass - - def get_center_of_mass_velocity(self, body_id, link_ids=None): - """ - Return the center of mass linear velocity. - - Args: - body_id (int): unique body id. - link_ids (list of int): link ids associated with the given body id. If None, it will take all the links - of the specified body. - - Returns: - np.float[3]: center of mass linear velocity. - """ - pass - - def get_base_pose(self, body_id): - """ - Get the current position and orientation of the base (or root link) of the body in Cartesian world coordinates. - - Args: - body_id (int): object unique id, as returned from `load_urdf`. - - Returns: - np.float[3]: base position - np.float[4]: base orientation (quaternion [x,y,z,w]) - """ - pass - - def get_base_position(self, body_id): - """ - Return the base position of the specified body. - - Args: - body_id (int): object unique id, as returned from `load_urdf`. - - Returns: - np.float[3]: base position. - """ - pass - - def get_base_orientation(self, body_id): - """ - Get the base orientation of the specified body. - - Args: - body_id (int): object unique id, as returned from `load_urdf`. - - Returns: - np.float[4]: base orientation in the form of a quaternion (x,y,z,w) - """ - pass - - def reset_base_pose(self, body_id, position, orientation): - """ - Reset the base position and orientation of the specified object id. - - Args: - body_id (int): unique object id. - position (np.float[3]): new base position. - orientation (np.float[4]): new base orientation (expressed as a quaternion [x,y,z,w]) - """ - pass - - def reset_base_position(self, body_id, position): - """ - Reset the base position of the specified body/object id while preserving its orientation. - - Args: - body_id (int): unique object id. - position (np.float[3]): new base position. - """ - pass - - def reset_base_orientation(self, body_id, orientation): - """ - Reset the base orientation of the specified body/object id while preserving its position. - - Args: - body_id (int): unique object id. - orientation (np.float[4]): new base orientation (expressed as a quaternion [x,y,z,w]) - """ - pass - - def get_base_velocity(self, body_id): - """ - Return the base linear and angular velocities. - - Args: - body_id (int): object unique id, as returned from `load_urdf`. - - Returns: - np.float[3]: linear velocity of the base in Cartesian world space coordinates - np.float[3]: angular velocity of the base in Cartesian world space coordinates - """ - pass - - def get_base_linear_velocity(self, body_id): - """ - Return the linear velocity of the base. - - Args: - body_id (int): object unique id, as returned from `load_urdf`. - - Returns: - np.float[3]: linear velocity of the base in Cartesian world space coordinates - """ - pass - - def get_base_angular_velocity(self, body_id): - """ - Return the angular velocity of the base. - - Args: - body_id (int): object unique id, as returned from `load_urdf`. - - Returns: - np.float[3]: angular velocity of the base in Cartesian world space coordinates - """ - pass - - def reset_base_velocity(self, body_id, linear_velocity=None, angular_velocity=None): - """ - Reset the base velocity. - - Args: - body_id (int): unique object id. - linear_velocity (np.float[3]): new linear velocity of the base. - angular_velocity (np.float[3]): new angular velocity of the base. - """ - pass - - def reset_base_linear_velocity(self, body_id, linear_velocity): - """ - Reset the base linear velocity. - - Args: - body_id (int): unique object id. - linear_velocity (np.float[3]): new linear velocity of the base - """ - pass - - def reset_base_angular_velocity(self, body_id, angular_velocity): - """ - Reset the base angular velocity. - - Args: - body_id (int): unique object id. - angular_velocity (np.float[3]): new angular velocity of the base - """ - pass - - def apply_external_force(self, body_id, link_id=-1, force=(0., 0., 0.), position=(0., 0., 0.), frame=1): - """ - Apply the specified external force on the specified position on the body / link. - - Args: - body_id (int): unique body id. - link_id (int): unique link id. If -1, it will be the base. - force (np.float[3]): external force to be applied. - position (np.float[3]): position on the link where the force is applied. See `flags` for coordinate - systems. If None, it is the center of mass of the body (or the link if specified). - frame (int): if frame = 1, then the force / position is described in the link frame. If frame = 2, they - are described in the world frame. - """ - pass - - def apply_external_torque(self, body_id, link_id=-1, torque=(0., 0., 0.), frame=1): - """ - Apply an external torque on a body, or a link of the body. Note that after each simulation step, the external - torques are cleared to 0. - - Args: - body_id (int): unique body id. - link_id (int): link id to apply the torque, if -1 it will apply the torque on the base - torque (float[3]): Cartesian torques to be applied on the body - frame (int): Specify the coordinate system of force/position: either `pybullet.WORLD_FRAME` (=2) for - Cartesian world coordinates or `pybullet.LINK_FRAME` (=1) for local link coordinates. - """ - pass - - # robots (joints and links) - - def num_joints(self, body_id): - """ - Return the total number of joints of the specified body. This is the same as calling `num_links`. - - Args: - body_id (int): unique body id. - - Returns: - int: number of joints with the associated body id. - """ - pass - - def num_actuated_joints(self, body_id): - """ - Return the total number of actuated joints associated with the given body id. - - Args: - body_id (int): unique body id. - - Returns: - int: number of actuated joints of the specified body. - """ - pass - - def num_links(self, body_id): - """ - Return the total number of links of the specified body. This is the same as calling `num_joints`. - - Args: - body_id (int): unique body id. - - Returns: - int: number of links with the associated body id. - """ - return self.num_joints(body_id) - - def get_joint_info(self, body_id, joint_id): - """ - Return information about the given joint about the specified body. - - Note that this method returns a lot of information, so specific methods have been implemented that return - only the desired information. Also, note that we do not convert the data here. - - Args: - body_id (int): unique body id. - joint_id (int): joint id is included in [0..`num_joints(body_id)`]. - - Returns: - dict, list: joint info - """ - pass - - def get_joint_state(self, body_id, joint_id): - """ - Get the joint state. - - Args: - body_id (int): unique body id. - joint_id (int): joint index in range [0..num_joints(body_id)] - - Returns: - float: The position value of this joint. - float: The velocity value of this joint. - np.float[6]: These are the joint reaction forces, if a torque sensor is enabled for this joint it is - [Fx, Fy, Fz, Mx, My, Mz]. Without torque sensor, it is [0, 0, 0, 0, 0, 0]. - float: This is the motor torque applied during the last stepSimulation. Note that this only applies in - VELOCITY_CONTROL and POSITION_CONTROL. If you use TORQUE_CONTROL then the applied joint motor torque - is exactly what you provide, so there is no need to report it separately. - """ - pass - - def get_joint_states(self, body_id, joint_ids): - """ - Get the joint state of the specified joints. - - Args: - body_id (int): unique body id. - joint_ids (list of int): list of joint ids. - - Returns: - list: - float: The position value of this joint. - float: The velocity value of this joint. - np.float[6]: These are the joint reaction forces, if a torque sensor is enabled for this joint it is - [Fx, Fy, Fz, Mx, My, Mz]. Without torque sensor, it is [0, 0, 0, 0, 0, 0]. - float: This is the motor torque applied during the last `step`. Note that this only applies in - VELOCITY_CONTROL and POSITION_CONTROL. If you use TORQUE_CONTROL then the applied joint motor - torque is exactly what you provide, so there is no need to report it separately. - """ - pass - - def reset_joint_state(self, body_id, joint_id, position, velocity=0.): - """ - Reset the state of the joint. It is best only to do this at the start, while not running the simulation: - `reset_joint_state` overrides all physics simulation. - - Args: - body_id (int): unique body id. - joint_id (int): joint index in range [0..num_joints(body_id)] - position (float): the joint position (angle in radians [rad] or position [m]) - velocity (float): the joint velocity (angular [rad/s] or linear velocity [m/s]) - """ - pass - - def enable_joint_force_torque_sensor(self, body_id, joint_ids, enable=True): - """ - You can enable or disable a joint force/torque sensor in each joint. - - Args: - body_id (int): body unique id. - joint_ids (int, int[N]): joint index in range [0..num_joints(body_id)], or list of joint ids. - enable (bool): True to enable, False to disable the force/torque sensor - """ - pass - - def set_joint_motor_control(self, body_id, joint_ids, control_mode=2, positions=None, - velocities=None, forces=None, kp=None, kd=None, max_velocity=None): - """ - Set the joint motor control. - - In position control: - .. math:: error = Kp (x_{des} - x) + Kd (\dot{x}_{des} - \dot{x}) - - In velocity control: - .. math:: error = \dot{x}_{des} - \dot{x} - - Note that the maximum forces and velocities are not automatically used for the different control schemes. - - Args: - body_id (int): body unique id. - joint_ids (int): joint/link id, or list of joint ids. - control_mode (int): POSITION_CONTROL (=2) (which is in fact CONTROL_MODE_POSITION_VELOCITY_PD), - VELOCITY_CONTROL (=0), TORQUE_CONTROL (=1) and PD_CONTROL (=3). - positions (float, np.float[N]): target joint position(s) (used in POSITION_CONTROL). - velocities (float, np.float[N]): target joint velocity(ies). In VELOCITY_CONTROL and POSITION_CONTROL, - the target velocity(ies) is(are) the desired velocity of the joint. Note that the target velocity(ies) - is(are) not the maximum joint velocity(ies). In PD_CONTROL and - POSITION_CONTROL/CONTROL_MODE_POSITION_VELOCITY_PD, the final target velocities are computed using: - `kp*(erp*(desiredPosition-currentPosition)/dt)+currentVelocity+kd*(m_desiredVelocity - currentVelocity)` - forces (float, list of float): in POSITION_CONTROL and VELOCITY_CONTROL, these are the maximum motor - forces used to reach the target values. In TORQUE_CONTROL these are the forces / torques to be applied - each simulation step. - kp (float, list of float): position (stiffness) gain(s) (used in POSITION_CONTROL). - kd (float, list of float): velocity (damping) gain(s) (used in POSITION_CONTROL). - max_velocity (float): in POSITION_CONTROL this limits the velocity to a maximum. - """ - pass - - def get_link_state(self, body_id, link_id, compute_velocity=False, compute_forward_kinematics=False): - """ - Get the state of the associated link. - - Args: - body_id (int): body unique id. - link_id (int): link index. - compute_velocity (bool): If True, the Cartesian world velocity will be computed and returned. - compute_forward_kinematics (bool): if True, the Cartesian world position/orientation will be recomputed - using forward kinematics. - - Returns: - np.float[3]: Cartesian position of CoM - np.float[4]: Cartesian orientation of CoM, in quaternion [x,y,z,w] - np.float[3]: local position offset of inertial frame (center of mass) expressed in the URDF link frame - np.float[4]: local orientation (quaternion [x,y,z,w]) offset of the inertial frame expressed in URDF link - frame - np.float[3]: world position of the URDF link frame - np.float[4]: world orientation of the URDF link frame - np.float[3]: Cartesian world linear velocity. Only returned if `compute_velocity` is True. - np.float[3]: Cartesian world angular velocity. Only returned if `compute_velocity` is True. - """ - pass - - def get_link_states(self, body_id, link_ids, compute_velocity=False, compute_forward_kinematics=False): - """ - Get the state of the associated links. - - Args: - body_id (int): body unique id. - link_ids (list of int): list of link index. - compute_velocity (bool): If True, the Cartesian world velocity will be computed and returned. - compute_forward_kinematics (bool): if True, the Cartesian world position/orientation will be recomputed - using forward kinematics. - - Returns: - list: - np.float[3]: Cartesian position of CoM - np.float[4]: Cartesian orientation of CoM, in quaternion [x,y,z,w] - np.float[3]: local position offset of inertial frame (center of mass) expressed in the URDF link frame - np.float[4]: local orientation (quaternion [x,y,z,w]) offset of the inertial frame expressed in URDF - link frame - np.float[3]: world position of the URDF link frame - np.float[4]: world orientation of the URDF link frame - np.float[3]: Cartesian world linear velocity. Only returned if `compute_velocity` is True. - np.float[3]: Cartesian world angular velocity. Only returned if `compute_velocity` is True. - """ - pass - - def get_link_names(self, body_id, link_ids): - """ - Return the name of the given link(s). - - Args: - body_id (int): unique body id. - link_ids (int, list of int): link id, or list of link ids. - - Returns: - if 1 link: - str: link name - if multiple links: - str[N]: link names - """ - pass - - def get_link_masses(self, body_id, link_ids): - """ - Return the mass of the given link(s). - - Args: - body_id (int): unique body id. - link_ids (int, list of int): link id, or list of link ids. - - Returns: - if 1 link: - float: mass of the given link - else: - float[N]: mass of each link - """ - pass - - def get_link_frames(self, body_id, link_ids): - pass - - def get_link_world_positions(self, body_id, link_ids): - """ - Return the CoM position (in the Cartesian world space coordinates) of the given link(s). - - Args: - body_id (int): unique body id. - link_ids (list of int): list of link indices. - - Returns: - if 1 link: - np.float[3]: the link CoM position in the world space - if multiple links: - np.float[N,3]: CoM position of each link in world space - """ - pass - - def get_link_positions(self, body_id, link_ids): - pass - - def get_link_world_orientations(self, body_id, link_ids): - """ - Return the CoM orientation (in the Cartesian world space) of the given link(s). - - Args: - body_id (int): unique body id. - link_ids (list of int): list of link indices. - - Returns: - if 1 link: - np.float[4]: Cartesian orientation of the link CoM (x,y,z,w) - if multiple links: - np.float[N,4]: CoM orientation of each link (x,y,z,w) - """ - pass - - def get_link_orientations(self, body_id, link_ids): - pass - - def get_link_world_linear_velocities(self, body_id, link_ids): - """ - Return the linear velocity of the link(s) expressed in the Cartesian world space coordinates. - - Args: - body_id (int): unique body id. - link_ids (list of int): list of link indices. - - Returns: - if 1 link: - np.float[3]: linear velocity of the link in the Cartesian world space - if multiple links: - np.float[N,3]: linear velocity of each link - """ - pass - - def get_link_world_angular_velocities(self, body_id, link_ids): - """ - Return the angular velocity of the link(s) in the Cartesian world space coordinates. - - Args: - body_id (int): unique body id. - link_ids (list of int): list of link indices. - - Returns: - if 1 link: - np.float[3]: angular velocity of the link in the Cartesian world space - if multiple links: - np.float[N,3]: angular velocity of each link - """ - pass - - def get_link_world_velocities(self, body_id, link_ids): - """ - Return the linear and angular velocities (expressed in the Cartesian world space coordinates) for the given - link(s). - - Args: - body_id (int): unique body id. - link_ids (list of int): list of link indices. - - Returns: - if 1 link: - np.float[6]: linear and angular velocity of the link in the Cartesian world space - if multiple links: - np.float[N,6]: linear and angular velocity of each link - """ - pass - - def get_link_velocities(self, body_id, link_ids): - pass - - def get_q_indices(self, body_id, joint_ids): - """ - Get the corresponding q index of the given joint(s). - - Args: - body_id (int): unique body id. - joint_ids (int, list of int): a joint id, or list of joint ids. - - Returns: - if 1 joint: - int: q index - if multiple joints: - np.int[N]: q indices - """ - pass - - def get_actuated_joint_ids(self, body_id): - """ - Get the actuated joint ids associated with the given body id. - - Args: - body_id (int): unique body id. - - Returns: - list of int: actuated joint ids. - """ - pass - - def get_joint_names(self, body_id, joint_ids): - """ - Return the name of the given joint(s). - - Args: - body_id (int): unique body id. - joint_ids (int, list of int): a joint id, or list of joint ids. - - Returns: - if 1 joint: - str: name of the joint - if multiple joints: - str[N]: name of each joint - """ - pass - - def get_joint_type_ids(self, body_id, joint_ids): - """ - Get the joint type ids. - - Args: - body_id (int): unique body id. - joint_ids (int, list of int): a joint id, or list of joint ids. - - Returns: - if 1 joint: - int: joint type id. - if multiple joints: list of above - """ - pass - - def get_joint_type_names(self, body_id, joint_ids): - """ - Get joint type names. - - Args: - body_id (int): unique body id. - joint_ids (int, list of int): a joint id, or list of joint ids. - - Returns: - if 1 joint: - str: joint type name. - if multiple joints: list of above - """ - pass - - def get_joint_dampings(self, body_id, joint_ids): - """ - Get the damping coefficient of the given joint(s). - - Args: - body_id (int): unique body id. - joint_ids (int, list of int): a joint id, or list of joint ids. - - Returns: - if 1 joint: - float: damping coefficient of the given joint - if multiple joints: - np.float[N]: damping coefficient for each specified joint - """ - pass - - def get_joint_frictions(self, body_id, joint_ids): - """ - Get the friction coefficient of the given joint(s). - - Args: - body_id (int): unique body id. - joint_ids (int, list of int): a joint id, or list of joint ids. - - Returns: - if 1 joint: - float: friction coefficient of the given joint - if multiple joints: - np.float[N]: friction coefficient for each specified joint - """ - pass - - def get_joint_limits(self, body_id, joint_ids): - """ - Get the joint limits of the given joint(s). - - Args: - body_id (int): unique body id. - joint_ids (int, list of int): a joint id, or list of joint ids. - - Returns: - if 1 joint: - np.float[2]: lower and upper limit - if multiple joints: - np.float[N,2]: lower and upper limit for each specified joint - """ - pass - - def get_joint_max_forces(self, body_id, joint_ids): - """ - Get the maximum force that can be applied on the given joint(s). - - Warning: Note that this is not automatically used in position, velocity, or torque control. - - Args: - body_id (int): unique body id. - joint_ids (int, list of int): a joint id, or list of joint ids. - - Returns: - if 1 joint: - float: maximum force [N] - if multiple joints: - np.float[N]: maximum force for each specified joint [N] - """ - pass - - def get_joint_max_velocities(self, body_id, joint_ids): - """ - Get the maximum velocity that can be applied on the given joint(s). - - Warning: Note that this is not automatically used in position, velocity, or torque control. - - Args: - body_id (int): unique body id. - joint_ids (int, list of int): a joint id, or list of joint ids. - - Returns: - if 1 joint: - float: maximum velocity [rad/s] - if multiple joints: - np.float[N]: maximum velocities for each specified joint [rad/s] - """ - pass - - def get_joint_axes(self, body_id, joint_ids): - """ - Get the joint axis about the given joint(s). - - Args: - body_id (int): unique body id. - joint_ids (int, list of int): a joint id, or list of joint ids. - - Returns: - if 1 joint: - np.float[3]: joint axis - if multiple joint: - np.float[N,3]: list of joint axis - """ - pass - - def set_joint_positions(self, body_id, joint_ids, positions, velocities=None, kps=None, kds=None, forces=None): - """ - Set the position of the given joint(s) (using position control). - - Args: - body_id (int): unique body id. - joint_ids (int, list of int): joint id, or list of joint ids. - positions (float, np.float[N]): desired position, or list of desired positions [rad] - velocities (None, float, np.float[N]): desired velocity, or list of desired velocities [rad/s] - kps (None, float, np.float[N]): position gain(s) - kds (None, float, np.float[N]): velocity gain(s) - forces (None, float, np.float[N]): maximum motor force(s)/torque(s) used to reach the target values. - """ - pass - - def get_joint_positions(self, body_id, joint_ids): - """ - Get the position of the given joint(s). - - Args: - body_id (int): unique body id. - joint_ids (int, list of int): joint id, or list of joint ids. - - Returns: - if 1 joint: - float: joint position [rad] - if multiple joints: - np.float[N]: joint positions [rad] - """ - pass - - def set_joint_velocities(self, body_id, joint_ids, velocities, max_force=None): - """ - Set the velocity of the given joint(s) (using velocity control). - - Args: - body_id (int): unique body id. - joint_ids (int, list of int): joint id, or list of joint ids. - velocities (float, np.float[N]): desired velocity, or list of desired velocities [rad/s] - max_force (None, float, np.float[N]): maximum motor forces/torques - """ - pass - - def get_joint_velocities(self, body_id, joint_ids): - """ - Get the velocity of the given joint(s). - - Args: - body_id (int): unique body id. - joint_ids (int, list of int): joint id, or list of joint ids. - - Returns: - if 1 joint: - float: joint velocity [rad/s] - if multiple joints: - np.float[N]: joint velocities [rad/s] - """ - pass - - def set_joint_accelerations(self, body_id, joint_ids, accelerations, q=None, dq=None): - """ - Set the acceleration of the given joint(s) (using force control). This is achieved by performing inverse - dynamic which given the joint accelerations compute the joint torques to be applied. - - Args: - body_id (int): unique body id. - joint_ids (int, list of int): joint id, or list of joint ids. - accelerations (float, np.float[N]): desired joint acceleration, or list of desired joint accelerations - [rad/s^2] - """ - pass - - def get_joint_accelerations(self, body_id, joint_ids, q=None, dq=None): - """ - Get the acceleration at the given joint(s). This is carried out by first getting the joint torques, then - performing forward dynamics to get the joint accelerations from the joint torques. - - Args: - body_id (int): unique body id. - joint_ids (int, list of int): joint id, or list of joint ids. - q (list of int, None): all the joint positions. If None, it will compute it. - dq (list of int, None): all the joint velocities. If None, it will compute it. - - Returns: - if 1 joint: - float: joint acceleration [rad/s^2] - if multiple joints: - np.float[N]: joint accelerations [rad/s^2] - """ - pass - - def set_joint_torques(self, body_id, joint_ids, torques): - """ - Set the torque/force to the given joint(s) (using force/torque control). - - Args: - body_id (int): unique body id. - joint_ids (int, list of int): joint id, or list of joint ids. - torques (float, list of float): desired torque(s) to apply to the joint(s) [N]. - """ - pass - - def get_joint_torques(self, body_id, joint_ids): - """ - Get the applied torque(s) on the given joint(s). - - Args: - body_id (int): unique body id. - joint_ids (int, list of int): a joint id, or list of joint ids. - - Returns: - if 1 joint: - float: torque [Nm] - if multiple joints: - np.float[N]: torques associated to the given joints [Nm] - """ - pass - - def get_joint_reaction_forces(self, body_id, joint_ids): - """Return the joint reaction forces at the given joint. Note that the torque sensor must be enabled, otherwise - it will always return [0,0,0,0,0,0]. - - Args: - body_id (int): unique body id. - joint_ids (int, int[N]): joint id, or list of joint ids - - Returns: - if 1 joint: - np.float[6]: joint reaction force (fx,fy,fz,mx,my,mz) [N,Nm] - if multiple joints: - np.float[N,6]: joint reaction forces [N, Nm] - """ - pass - - def get_joint_powers(self, body_id, joint_ids): - """Return the applied power at the given joint(s). Power = torque * velocity. - - Args: - body_id (int): unique body id. - joint_ids (int, int[N]): joint id, or list of joint ids - - Returns: - if 1 joint: - float: joint power [W] - if multiple joints: - np.float[N]: power at each joint [W] - """ - pass - - # visualization - - def create_visual_shape(self, shape_type, radius=0.5, half_extents=(1., 1., 1.), length=1., filename=None, - mesh_scale=(1., 1., 1.), plane_normal=(0., 0., 1.), flags=-1, rgba_color=None, - specular_color=None, visual_frame_position=None, vertices=None, indices=None, uvs=None, - normals=None, visual_frame_orientation=None): - """ - Create a visual shape in the simulator. - - Args: - shape_type (int): type of shape; GEOM_SPHERE (=2), GEOM_BOX (=3), GEOM_CAPSULE (=7), GEOM_CYLINDER (=4), - GEOM_PLANE (=6), GEOM_MESH (=5) - radius (float): only for GEOM_SPHERE, GEOM_CAPSULE, GEOM_CYLINDER - half_extents (np.float[3], list/tuple of 3 floats): only for GEOM_BOX. - length (float): only for GEOM_CAPSULE, GEOM_CYLINDER (length = height). - filename (str): Filename for GEOM_MESH, currently only Wavefront .obj. Will create convex hulls for each - object (marked as 'o') in the .obj file. - mesh_scale (np.float[3], list/tuple of 3 floats): scale of mesh (only for GEOM_MESH). - plane_normal (np.float[3], list/tuple of 3 floats): plane normal (only for GEOM_PLANE). - flags (int): unused / to be decided - rgba_color (list/tuple of 4 floats): color components for red, green, blue and alpha, each in range [0..1]. - specular_color (list/tuple of 3 floats): specular reflection color, red, green, blue components in range - [0..1] - visual_frame_position (np.float[3]): translational offset of the visual shape with respect to the link frame - vertices (list of np.float[3]): Instead of creating a mesh from obj file, you can provide vertices, indices, - uvs and normals - indices (list of int): triangle indices, should be a multiple of 3. - uvs (list of np.float[2]): uv texture coordinates for vertices. Use changeVisualShape to choose the - texture image. The number of uvs should be equal to number of vertices - normals (list of np.float[3]): vertex normals, number should be equal to number of vertices. - visual_frame_orientation (np.float[4]): rotational offset (quaternion x,y,z,w) of the visual shape with - respect to the link frame - - Returns: - int: The return value is a non-negative int unique id for the visual shape or -1 if the call failed. - """ - pass - - def get_visual_shape_data(self, object_id, flags=-1): - """ - Get the visual shape data associated with the given object id. It will output a list of visual shape data. - - Args: - object_id (int): object unique id. - flags (int, None): VISUAL_SHAPE_DATA_TEXTURE_UNIQUE_IDS (=1) will also provide `texture_unique_id`. - - Returns: - list: - int: object unique id. - int: link index or -1 for the base - int: visual geometry type (TBD) - np.float[3]: dimensions (size, local scale) of the geometry - str: path to the triangle mesh, if any. Typically relative to the URDF, SDF or MJCF file location, but - could be absolute - np.float[3]: position of local visual frame, relative to link/joint frame - np.float[4]: orientation of local visual frame relative to link/joint frame - list of 4 floats: URDF color (if any specified) in Red / Green / Blue / Alpha - int: texture unique id of the shape or -1 if None. This field only exists if using - VISUAL_SHAPE_DATA_TEXTURE_UNIQUE_IDS (=1) flag. - """ - pass - - def change_visual_shape(self, object_id, link_id, shape_id=None, texture_id=None, rgba_color=None, - specular_color=None): - """ - Allows to change the texture of a shape, the RGBA color and other properties. - - Args: - object_id (int): unique object id. - link_id (int): link id. - shape_id (int): shape id. - texture_id (int): texture id. - rgba_color (float[4]): RGBA color. Each is in the range [0..1]. Alpha has to be 0 (invisible) or 1 - (visible) at the moment. - specular_color (int[3]): specular color components, RED, GREEN and BLUE, can be from 0 to large number - (>100). - """ - pass - - def load_texture(self, filename): - """ - Load a texture from file and return a non-negative texture unique id if the loading succeeds. - This unique id can be used with changeVisualShape. - - Args: - filename (str): path to the file. - - Returns: - int: texture unique id. If non-negative, the texture was loaded successfully. - """ - pass - - def compute_view_matrix(self, eye_position, target_position, up_vector): - """Compute the view matrix. - - The view matrix is the 4x4 matrix that maps the world coordinates into the camera coordinates. Basically, - it applies a rotation and translation such that the world is in front of the camera. That is, instead - of turning the camera to capture what we want in the world, we keep the camera fixed and turn the world. - - Args: - eye_position (np.float[3]): eye position in Cartesian world coordinates - target_position (np.float[3]): position of the target (focus) point in Cartesian world coordinates - up_vector (np.float[3]): up vector of the camera in Cartesian world coordinates - - Returns: - np.float[4,4]: the view matrix - """ - pass - - def compute_view_matrix_from_ypr(self, target_position, distance, yaw, pitch, roll, up_axis_index=2): - """Compute the view matrix from the yaw, pitch, and roll angles. - - The view matrix is the 4x4 matrix that maps the world coordinates into the camera coordinates. Basically, - it applies a rotation and translation such that the world is in front of the camera. That is, instead - of turning the camera to capture what we want in the world, we keep the camera fixed and turn the world. - - Args: - target_position (np.float[3]): target focus point in Cartesian world coordinates - distance (float): distance from eye to focus point - yaw (float): yaw angle in radians left/right around up-axis - pitch (float): pitch in radians up/down. - roll (float): roll in radians around forward vector - up_axis_index (int): either 1 for Y or 2 for Z axis up. - - Returns: - np.float[4,4]: the view matrix - """ - pass - - def compute_projection_matrix(self, left, right, bottom, top, near, far): - """Compute the orthographic projection matrix. - - The projection matrix is the 4x4 matrix that maps from the camera/eye coordinates to clipped coordinates. - It is applied after the view matrix. - - There are 2 projection matrices: - * orthographic projection - * perspective projection - - For the perspective projection, see `computeProjectionMatrixFOV(self)`. - - Args: - left (float): left screen (canvas) coordinate - right (float): right screen (canvas) coordinate - bottom (float): bottom screen (canvas) coordinate - top (float): top screen (canvas) coordinate - near (float): near plane distance - far (float): far plane distance - - Returns: - np.float[4,4]: the perspective projection matrix - """ - pass - - def compute_projection_matrix_fov(self, fov, aspect, near, far): - """Compute the perspective projection matrix using the field of view (FOV). - - Args: - fov (float): field of view - aspect (float): aspect ratio - near (float): near plane distance - far (float): far plane distance - - Returns: - np.float[4,4]: the perspective projection matrix - """ - pass - - def get_camera_image(self, width, height, view_matrix=None, projection_matrix=None, light_direction=None, - light_color=None, light_distance=None, shadow=None, light_ambient_coeff=None, - light_diffuse_coeff=None, light_specular_coeff=None, renderer=None, flags=None): - """ - The `get_camera_image` API will return a RGB image, a depth buffer and a segmentation mask buffer with body - unique ids of visible objects for each pixel. - - Args: - width (int): horizontal image resolution in pixels - height (int): vertical image resolution in pixels - view_matrix (np.float[4,4]): 4x4 view matrix, see `compute_view_matrix` - projection_matrix (np.float[4,4]): 4x4 projection matrix, see `compute_projection` - light_direction (np.float[3]): `light_direction` specifies the world position of the light source, - the direction is from the light source position to the origin of the world frame. - light_color (np.float[3]): directional light color in [RED,GREEN,BLUE] in range 0..1 - light_distance (float): distance of the light along the normalized `light_direction` - shadow (bool): True for shadows, False for no shadows - light_ambient_coeff (float): light ambient coefficient - light_diffuse_coeff (float): light diffuse coefficient - light_specular_coeff (float): light specular coefficient - renderer (int): renderer - flags (int): flags - - Returns: - int: width image resolution in pixels (horizontal) - int: height image resolution in pixels (vertical) - np.int[width, height, 4]: RBGA pixels (each pixel is in the range [0..255] for each channel R, G, B, A) - np.float[width, heigth]: Depth buffer. - np.int[width, height]: Segmentation mask buffer. For each pixels the visible object unique id. - """ - pass - - def get_rgba_image(self, width, height, view_matrix=None, projection_matrix=None, light_direction=None, - light_color=None, light_distance=None, shadow=None, light_ambient_coeff=None, - light_diffuse_coeff=None, light_specular_coeff=None, renderer=None, flags=None): - """ - The `get_rgba_image` API will return a RGBA image. - - Args: - width (int): horizontal image resolution in pixels - height (int): vertical image resolution in pixels - view_matrix (np.float[4,4]): 4x4 view matrix, see `compute_view_matrix` - projection_matrix (np.float[4,4]): 4x4 projection matrix, see `compute_projection` - light_direction (np.float[3]): `light_direction` specifies the world position of the light source, - the direction is from the light source position to the origin of the world frame. - light_color (np.float[3]): directional light color in [RED,GREEN,BLUE] in range 0..1 - light_distance (float): distance of the light along the normalized `light_direction` - shadow (bool): True for shadows, False for no shadows - light_ambient_coeff (float): light ambient coefficient - light_diffuse_coeff (float): light diffuse coefficient - light_specular_coeff (float): light specular coefficient - renderer (int): renderer. - flags (int): flags. - - Returns: - np.int[width, height, 4]: RBGA pixels (each pixel is in the range [0..255] for each channel R, G, B, A) - """ - pass - - def get_depth_image(self, width, height, view_matrix=None, projection_matrix=None, light_direction=None, - light_color=None, light_distance=None, shadow=None, light_ambient_coeff=None, - light_diffuse_coeff=None, light_specular_coeff=None, renderer=None, flags=None): - """ - The `get_depth_image` API will return a depth buffer. - - Args: - width (int): horizontal image resolution in pixels - height (int): vertical image resolution in pixels - view_matrix (np.float[4,4]): 4x4 view matrix, see `compute_view_matrix` - projection_matrix (np.float[4,4]): 4x4 projection matrix, see `compute_projection` - light_direction (np.float[3]): `light_direction` specifies the world position of the light source, - the direction is from the light source position to the origin of the world frame. - light_color (np.float[3]): directional light color in [RED,GREEN,BLUE] in range 0..1 - light_distance (float): distance of the light along the normalized `light_direction` - shadow (bool): True for shadows, False for no shadows - light_ambient_coeff (float): light ambient coefficient - light_diffuse_coeff (float): light diffuse coefficient - light_specular_coeff (float): light specular coefficient - renderer (int): renderer. - flags (int): flags. - - Returns: - np.float[width, heigth]: Depth buffer. - """ - pass - - def get_segmentation_image(self, width, height, view_matrix=None, projection_matrix=None, light_direction=None, - light_color=None, light_distance=None, shadow=None, light_ambient_coeff=None, - light_diffuse_coeff=None, light_specular_coeff=None, renderer=None, flags=None): - """ - The `get_segmentation_image` API will return a segmentation mask buffer with body unique ids of visible objects - for each pixel. - - Args: - width (int): horizontal image resolution in pixels - height (int): vertical image resolution in pixels - view_matrix (np.float[4,4]): 4x4 view matrix, see `compute_view_matrix` - projection_matrix (np.float[4,4]): 4x4 projection matrix, see `compute_projection` - light_direction (np.float[3]): `light_direction` specifies the world position of the light source, - the direction is from the light source position to the origin of the world frame. - light_color (np.float[3]): directional light color in [RED,GREEN,BLUE] in range 0..1 - light_distance (float): distance of the light along the normalized `light_direction` - shadow (bool): True for shadows, False for no shadows - light_ambient_coeff (float): light ambient coefficient - light_diffuse_coeff (float): light diffuse coefficient - light_specular_coeff (float): light specular coefficient - renderer (int): renderer - flags (int): flags - - Returns: - np.int[width, height]: Segmentation mask buffer. For each pixels the visible object unique id. - """ - pass - - # collisions - - def create_collision_shape(self, shape_type, radius=0.5, half_extents=(1., 1., 1.), height=1., filename=None, - mesh_scale=(1., 1., 1.), plane_normal=(0., 0., 1.), flags=-1, - collision_frame_position=None, collision_frame_orientation=None): - """ - Create collision shape in the simulator. - - Args: - shape_type (int): type of shape; GEOM_SPHERE (=2), GEOM_BOX (=3), GEOM_CAPSULE (=7), GEOM_CYLINDER (=4), - GEOM_PLANE (=6), GEOM_MESH (=5) - radius (float): only for GEOM_SPHERE, GEOM_CAPSULE, GEOM_CYLINDER - half_extents (np.float[3], list/tuple of 3 floats): only for GEOM_BOX. - height (float): only for GEOM_CAPSULE, GEOM_CYLINDER (length = height). - filename (str): Filename for GEOM_MESH, currently only Wavefront .obj. Will create convex hulls for each - object (marked as 'o') in the .obj file. - mesh_scale (np.float[3], list/tuple of 3 floats): scale of mesh (only for GEOM_MESH). - plane_normal (np.float[3], list/tuple of 3 floats): plane normal (only for GEOM_PLANE). - flags (int): unused / to be decided - collision_frame_position (np.float[3]): translational offset of the collision shape with respect to the - link frame - collision_frame_orientation (np.float[4]): rotational offset (quaternion x,y,z,w) of the collision shape - with respect to the link frame - - Returns: - int: The return value is a non-negative int unique id for the collision shape or -1 if the call failed. - """ - pass - - def get_collision_shape_data(self, object_id, link_id=-1): - """ - Get the collision shape data associated with the specified object id and link id. - - Args: - object_id (int): object unique id. - link_id (int): link index or -1 for the base. - - Returns: - int: object unique id. - int: link id. - int: geometry type; GEOM_BOX (=3), GEOM_SPHERE (=2), GEOM_CAPSULE (=7), GEOM_MESH (=5), GEOM_PLANE (=6) - np.float[3]: depends on geometry type: - for GEOM_BOX: extents, - for GEOM_SPHERE: dimensions[0] = radius, - for GEOM_CAPSULE and GEOM_CYLINDER: dimensions[0] = height (length), dimensions[1] = radius. - For GEOM_MESH: dimensions is the scaling factor. - str: Only for GEOM_MESH: file name (and path) of the collision mesh asset. - np.float[3]: Local position of the collision frame with respect to the center of mass/inertial frame - np.float[4]: Local orientation of the collision frame with respect to the inertial frame - """ - pass - - def get_overlapping_objects(self, aabb_min, aabb_max): - """ - This query will return all the unique ids of objects that have Axis Aligned Bounding Box (AABB) overlap with - a given axis aligned bounding box. Note that the query is conservative and may return additional objects that - don't have actual AABB overlap. This happens because the acceleration structures have some heuristic that - enlarges the AABBs a bit (extra margin and extruded along the velocity vector). - - Args: - aabb_min (np.float[3]): minimum coordinates of the aabb - aabb_max (np.float[3]): maximum coordinates of the aabb - - Returns: - list of int: list of object unique ids. - """ - pass - - def get_aabb(self, body_id, link_id=-1): - """ - You can query the axis aligned bounding box (in world space) given an object unique id, and optionally a link - index. (when you don't pass the link index, or use -1, you get the AABB of the base). - - Args: - body_id (int): object unique id as returned by creation methods - link_id (int): link index in range [0..`getNumJoints(..)] - - Returns: - np.float[3]: minimum coordinates of the axis aligned bounding box - np.float[3]: maximum coordinates of the axis aligned bounding box - """ - pass - - def get_contact_points(self, body1, body2=None, link1_id=None, link2_id=None): - """ - Returns the contact points computed during the most recent call to `step`. - - Args: - body1 (int): only report contact points that involve body A - body2 (int, None): only report contact points that involve body B. Important: you need to have a valid - body A if you provide body B - link1_id (int, None): only report contact points that involve link index of body A - link2_id (int, None): only report contact points that involve link index of body B - - Returns: - list: - int: contact flag (reserved) - int: body unique id of body A - int: body unique id of body B - int: link index of body A, -1 for base - int: link index of body B, -1 for base - np.float[3]: contact position on A, in Cartesian world coordinates - np.float[3]: contact position on B, in Cartesian world coordinates - np.float[3]: contact normal on B, pointing towards A - float: contact distance, positive for separation, negative for penetration - float: normal force applied during the last `step` - float: lateral friction force in the first lateral friction direction (see next returned value) - np.float[3]: first lateral friction direction - float: lateral friction force in the second lateral friction direction (see next returned value) - np.float[3]: second lateral friction direction - """ - pass - - def get_closest_points(self, body1, body2, distance, link1_id=None, link2_id=None): - """ - Computes the closest points, independent from `step`. This also lets you compute closest points of objects - with an arbitrary separating distance. In this query there will be no normal forces reported. - - Args: - body1 (int): only report contact points that involve body A - body2 (int): only report contact points that involve body B. Important: you need to have a valid body A - if you provide body B - distance (float): If the distance between objects exceeds this maximum distance, no points may be returned. - link1_id (int): only report contact points that involve link index of body A - link2_id (int): only report contact points that involve link index of body B - - Returns: - list: - int: contact flag (reserved) - int: body unique id of body A - int: body unique id of body B - int: link index of body A, -1 for base - int: link index of body B, -1 for base - np.float[3]: contact position on A, in Cartesian world coordinates - np.float[3]: contact position on B, in Cartesian world coordinates - np.float[3]: contact normal on B, pointing towards A - float: contact distance, positive for separation, negative for penetration - float: normal force applied during the last `step`. Always equal to 0. - float: lateral friction force in the first lateral friction direction (see next returned value) - np.float[3]: first lateral friction direction - float: lateral friction force in the second lateral friction direction (see next returned value) - np.float[3]: second lateral friction direction - """ - pass - - def ray_test(self, from_position, to_position): - """ - Performs a single raycast to find the intersection information of the first object hit. - - Args: - from_position (np.float[3]): start of the ray in world coordinates - to_position (np.float[3]): end of the ray in world coordinates - - Returns: - list: - int: object unique id of the hit object - int: link index of the hit object, or -1 if none/parent - float: hit fraction along the ray in range [0,1] along the ray. - np.float[3]: hit position in Cartesian world coordinates - np.float[3]: hit normal in Cartesian world coordinates - """ - pass - - def ray_test_batch(self, from_positions, to_positions, parent_object_id=None, parent_link_id=None): - """Perform a batch of raycasts to find the intersection information of the first objects hit. - - This is similar to the ray_test, but allows you to provide an array of rays, for faster execution. The size of - 'rayFromPositions' needs to be equal to the size of 'rayToPositions'. You can one ray result per ray, even if - there is no intersection: you need to use the objectUniqueId field to check if the ray has hit anything: if - the objectUniqueId is -1, there is no hit. In that case, the 'hit fraction' is 1. - - Args: - from_positions (np.array[N,3]): list of start points for each ray, in world coordinates - to_positions (np.array[N,3]): list of end points for each ray in world coordinates - parent_object_id (int): ray from/to is in local space of a parent object - parent_link_id (int): ray from/to is in local space of a parent object - - Returns: - list: - int: object unique id of the hit object - int: link index of the hit object, or -1 if none/parent - float: hit fraction along the ray in range [0,1] along the ray. - np.float[3]: hit position in Cartesian world coordinates - np.float[3]: hit normal in Cartesian world coordinates - """ - pass - - def set_collision_filter_group_mask(self, body_id, link_id, filter_group, filter_mask): - """ - Enable/disable collision detection between groups of objects. Each body is part of a group. It collides with - other bodies if their group matches the mask, and vise versa. The following check is performed using the group - and mask of the two bodies involved. It depends on the collision filter mode. - - Args: - body_id (int): unique id of the body to be configured - link_id (int): link index of the body to be configured - filter_group (int): bitwise group of the filter - filter_mask (int): bitwise mask of the filter - """ - pass - - def set_collision_filter_pair(self, body1, body2, link1=-1, link2=-1, enable=True): - """ - Enable/disable collision between two bodies/links. - - Args: - body1 (int): unique id of body A to be filtered - body2 (int): unique id of body B to be filtered, A==B implies self-collision - link1 (int): link index of body A - link2 (int): link index of body B - enable (bool): True to enable collision, False to disable collision - """ - pass - - # kinematics and dynamics - - def get_dynamics_info(self, body_id, link_id=-1): - """ - Get dynamic information about the mass, center of mass, friction and other properties of the base and links. - - Args: - body_id (int): body/object unique id. - link_id (int): link/joint index or -1 for the base. - - Returns: - float: mass in kg - float: lateral friction coefficient - np.float[3]: local inertia diagonal. Note that links and base are centered around the center of mass and - aligned with the principal axes of inertia. - np.float[3]: position of inertial frame in local coordinates of the joint frame - np.float[4]: orientation of inertial frame in local coordinates of joint frame - float: coefficient of restitution - float: rolling friction coefficient orthogonal to contact normal - float: spinning friction coefficient around contact normal - float: damping of contact constraints. -1 if not available. - float: stiffness of contact constraints. -1 if not available. - """ - pass - - def change_dynamics(self, body_id, link_id=-1, mass=None, lateral_friction=None, spinning_friction=None, - rolling_friction=None, restitution=None, linear_damping=None, angular_damping=None, - contact_stiffness=None, contact_damping=None, friction_anchor=None, - local_inertia_diagonal=None, joint_damping=None): - """ - Change dynamic properties of the given body (or link) such as mass, friction and restitution coefficients, etc. - - Args: - body_id (int): object unique id, as returned by `load_urdf`, etc. - link_id (int): link index or -1 for the base. - mass (float): change the mass of the link (or base for link index -1) - lateral_friction (float): lateral (linear) contact friction - spinning_friction (float): torsional friction around the contact normal - rolling_friction (float): torsional friction orthogonal to contact normal - restitution (float): bouncyness of contact. Keep it a bit less than 1. - linear_damping (float): linear damping of the link (0.04 by default) - angular_damping (float): angular damping of the link (0.04 by default) - contact_stiffness (float): stiffness of the contact constraints, used together with `contact_damping` - contact_damping (float): damping of the contact constraints for this body/link. Used together with - `contact_stiffness`. This overrides the value if it was specified in the URDF file in the contact - section. - friction_anchor (int): enable or disable a friction anchor: positional friction correction (disabled by - default, unless set in the URDF contact section) - local_inertia_diagonal (np.float[3]): diagonal elements of the inertia tensor. Note that the base and - links are centered around the center of mass and aligned with the principal axes of inertia so there - are no off-diagonal elements in the inertia tensor. - joint_damping (float): joint damping coefficient applied at each joint. This coefficient is read from URDF - joint damping field. Keep the value close to 0. - `joint_damping_force = -damping_coefficient * joint_velocity`. - """ - pass - - def calculate_jacobian(self, body_id, link_id, local_position, q, dq, des_ddq): - r""" - Return the full geometric Jacobian matrix :math:`J(q) = [J_{lin}(q), J_{ang}(q)]^T`, such that: - - .. math:: v = [\dot{p}, \omega]^T = J(q) \dot{q} - - where :math:`\dot{p}` is the Cartesian linear velocity of the link, and :math:`\omega` is its angular velocity. - - Warnings: if we have a floating base then the Jacobian will also include columns corresponding to the root - link DoFs (at the beginning). If it is a fixed base, it will only have columns associated with the joints. - - Args: - body_id (int): unique body id. - link_id (int): link id. - local_position (np.float[3]): the point on the specified link to compute the Jacobian (in link local - coordinates around its center of mass). If None, it will use the CoM position (in the link frame). - q (np.float[N]): joint positions of size N, where N is the number of DoFs. - dq (np.float[N]): joint velocities of size N, where N is the number of DoFs. - des_ddq (np.float[N]): desired joint accelerations of size N. - - Returns: - np.float[6,N], np.float[6,(6+N)]: full geometric (linear and angular) Jacobian matrix. The number of - columns depends if the base is fixed or floating. - """ - pass - - def calculate_mass_matrix(self, body_id, q): - r""" - Return the mass/inertia matrix :math:`H(q)`, which is used in the rigid-body equation of motion (EoM) in joint - space given by (see [1]): - - .. math:: \tau = H(q)\ddot{q} + C(q,\dot{q}) - - where :math:`\tau` is the vector of applied torques, :math:`H(q)` is the inertia matrix, and - :math:`C(q,\dot{q}) \dot{q}` is the vector accounting for Coriolis, centrifugal forces, gravity, and any - other forces acting on the system except the applied torques :math:`\tau`. - - Warnings: If the base is floating, it will return a [6+N,6+N] inertia matrix, where N is the number of actuated - joints. If the base is fixed, it will return a [N,N] inertia matrix - - Args: - body_id (int): body unique id. - q (np.float[N]): joint positions of size N, where N is the total number of DoFs. - - Returns: - np.float[N,N], np.float[6+N,6+N]: inertia matrix - """ - pass - - def calculate_inverse_kinematics(self, body_id, link_id, position, orientation=None, lower_limits=None, - upper_limits=None, joint_ranges=None, rest_poses=None, joint_dampings=None, - solver=None, q_curr=None, max_iters=None, threshold=None): - """ - Compute the FULL Inverse kinematics; it will return a position for all the actuated joints. - - "You can compute the joint angles that makes the end-effector reach a given target position in Cartesian world - space. Internally, Bullet uses an improved version of Samuel Buss Inverse Kinematics library. At the moment - only the Damped Least Squares method with or without Null Space control is exposed, with a single end-effector - target. Optionally you can also specify the target orientation of the end effector. In addition, there is an - option to use the null-space to specify joint limits and rest poses. This optional null-space support requires - all 4 lists (lower_limits, upper_limits, joint_ranges, rest_poses), otherwise regular IK will be used." [1] - - Args: - body_id (int): body unique id, as returned by `load_urdf`, etc. - link_id (int): end effector link index. - position (np.float[3]): target position of the end effector (its link coordinate, not center of mass - coordinate!). By default this is in Cartesian world space, unless you provide `q_curr` joint angles. - orientation (np.float[4]): target orientation in Cartesian world space, quaternion [x,y,w,z]. If not - specified, pure position IK will be used. - lower_limits (np.float[N], list of N floats): lower joint limits. Optional null-space IK. - upper_limits (np.float[N], list of N floats): upper joint limits. Optional null-space IK. - joint_ranges (np.float[N], list of N floats): range of value of each joint. - rest_poses (np.float[N], list of N floats): joint rest poses. Favor an IK solution closer to a given rest - pose. - joint_dampings (np.float[N], list of N floats): joint damping factors. Allow to tune the IK solution using - joint damping factors. - solver (int): p.IK_DLS (=0) or p.IK_SDLS (=1), Damped Least Squares or Selective Damped Least Squares, as - described in the paper by Samuel Buss "Selectively Damped Least Squares for Inverse Kinematics". - q_curr (np.float[N]): list of joint positions. By default PyBullet uses the joint positions of the body. - If provided, the target_position and targetOrientation is in local space! - max_iters (int): maximum number of iterations. Refine the IK solution until the distance between target - and actual end effector position is below this threshold, or the `max_iters` is reached. - threshold (float): residual threshold. Refine the IK solution until the distance between target and actual - end effector position is below this threshold, or the `max_iters` is reached. - - Returns: - np.float[N]: joint positions (for each actuated joint). - """ - pass - - def calculate_inverse_dynamics(self, body_id, q, dq, des_ddq): - r""" - Starting from the specified joint positions :math:`q` and velocities :math:`\dot{q}`, it computes the joint - torques :math:`\tau` required to reach the desired joint accelerations :math:`\ddot{q}_{des}`. That is, - :math:`\tau = ID(model, q, \dot{q}, \ddot{q}_{des})`. - - Specifically, it uses the rigid-body equation of motion in joint space given by (see [1]): - - .. math:: \tau = H(q)\ddot{q} + C(q,\dot{q}) - - where :math:`\tau` is the vector of applied torques, :math:`H(q)` is the inertia matrix, and - :math:`C(q,\dot{q}) \dot{q}` is the vector accounting for Coriolis, centrifugal forces, gravity, and any - other forces acting on the system except the applied torques :math:`\tau`. - - Normally, a more popular form of this equation of motion (in joint space) is given by: - - .. math:: H(q) \ddot{q} + S(q,\dot{q}) \dot{q} + g(q) = \tau + J^T(q) F - - which is the same as the first one with :math:`C = S\dot{q} + g(q) - J^T(q) F`. However, this last formulation - is useful to understand what happens when we set some variables to 0. - Assuming that there are no forces acting on the system, and giving desired joint accelerations of 0, this - method will return :math:`\tau = S(q,\dot{q}) \dot{q} + g(q)`. If in addition joint velocities are also 0, - it will return :math:`\tau = g(q)` which can for instance be useful for gravity compensation. - - For forward dynamics, which computes the joint accelerations given the joint positions, velocities, and - torques (that is, :math:`\ddot{q} = FD(model, q, \dot{q}, \tau)`, this can be computed using - :math:`\ddot{q} = H^{-1} (\tau - C)` (see also `computeFullFD`). For more information about different - control schemes (position, force, impedance control and others), or about the formulation of the equation - of motion in task/operational space (instead of joint space), check the references [1-4]. - - Args: - body_id (int): body unique id. - q (np.float[N]): joint positions - dq (np.float[N]): joint velocities - des_ddq (np.float[N]): desired joint accelerations - - Returns: - np.float[N]: joint torques computed using the rigid-body equation of motion - - References: - [1] "Rigid Body Dynamics Algorithms", Featherstone, 2008, chap1.1 - [2] "Robotics: Modelling, Planning and Control", Siciliano et al., 2010 - [3] "Springer Handbook of Robotics", Siciliano et al., 2008 - [4] Lecture on "Impedance Control" by Prof. De Luca, Universita di Roma, - http://www.diag.uniroma1.it/~deluca/rob2_en/15_ImpedanceControl.pdf - """ - pass - - def calculate_forward_dynamics(self, body_id, q, dq, torques): - r""" - Given the specified joint positions :math:`q` and velocities :math:`\dot{q}`, and joint torques :math:`\tau`, - it computes the joint accelerations :math:`\ddot{q}`. That is, :math:`\ddot{q} = FD(model, q, \dot{q}, \tau)`. - - Specifically, it uses the rigid-body equation of motion in joint space given by (see [1]): - - .. math:: \ddot{q} = H(q)^{-1} (\tau - C(q,\dot{q})) - - where :math:`\tau` is the vector of applied torques, :math:`H(q)` is the inertia matrix, and - :math:`C(q,\dot{q}) \dot{q}` is the vector accounting for Coriolis, centrifugal forces, gravity, and any - other forces acting on the system except the applied torques :math:`\tau`. - - Normally, a more popular form of this equation of motion (in joint space) is given by: - - .. math:: H(q) \ddot{q} + S(q,\dot{q}) \dot{q} + g(q) = \tau + J^T(q) F - - which is the same as the first one with :math:`C = S\dot{q} + g(q) - J^T(q) F`. However, this last formulation - is useful to understand what happens when we set some variables to 0. - Assuming that there are no forces acting on the system, and giving desired joint torques of 0, this - method will return :math:`\ddot{q} = - H(q)^{-1} (S(q,\dot{q}) \dot{q} + g(q))`. If in addition - the joint velocities are also 0, it will return :math:`\ddot{q} = - H(q)^{-1} g(q)` which are - the accelerations due to gravity. - - For inverse dynamics, which computes the joint torques given the joint positions, velocities, and - accelerations (that is, :math:`\tau = ID(model, q, \dot{q}, \ddot{q})`, this can be computed using - :math:`\tau = H(q)\ddot{q} + C(q,\dot{q})`. For more information about different - control schemes (position, force, impedance control and others), or about the formulation of the equation - of motion in task/operational space (instead of joint space), check the references [1-4]. - - Args: - body_id (int): unique body id. - q (np.float[N]): joint positions - dq (np.float[N]): joint velocities - torques (np.float[N]): desired joint torques - - Returns: - np.float[N]: joint accelerations computed using the rigid-body equation of motion - - References: - [1] "Rigid Body Dynamics Algorithms", Featherstone, 2008, chap1.1 - [2] "Robotics: Modelling, Planning and Control", Siciliano et al., 2010 - [3] "Springer Handbook of Robotics", Siciliano et al., 2008 - [4] Lecture on "Impedance Control" by Prof. De Luca, Universita di Roma, - http://www.diag.uniroma1.it/~deluca/rob2_en/15_ImpedanceControl.pdf - """ - pass - - # debug - - def add_user_debug_line(self, from_pos, to_pos, rgb_color=None, width=None, lifetime=None, parent_object_id=None, - parent_link_id=None, line_id=None): - """Add a user debug line in the simulator. - - You can add a 3d line specified by a 3d starting point (from) and end point (to), a color [red,green,blue], - a line width and a duration in seconds. - - Args: - from_pos (np.float[3]): starting point of the line in Cartesian world coordinates - to_pos (np.float[3]): end point of the line in Cartesian world coordinates - rgb_color (np.float[3]): RGB color (each channel in range [0,1]) - width (float): line width (limited by OpenGL implementation). - lifetime (float): use 0 for permanent line, or positive time in seconds (afterwards the line with be - removed automatically) - parent_object_id (int): draw line in local coordinates of a parent object. - parent_link_id (int): draw line in local coordinates of a parent link. - line_id (int): replace an existing line item (to avoid flickering of remove/add). - - Returns: - int: unique user debug line id. - """ - pass - - def add_user_debug_text(self, text, position, rgb_color=None, size=None, lifetime=None, orientation=None, - parent_object_id=None, parent_link_id=None, text_id=None): - """ - Add 3D text at a specific location using a color and size. - - Args: - text (str): text. - position (np.float[3]): 3d position of the text in Cartesian world coordinates. - rgb_color (list/tuple of 3 floats): RGB color; each component in range [0..1] - size (float): text size - lifetime (float): use 0 for permanent text, or positive time in seconds (afterwards the text with be - removed automatically) - orientation (np.float[4]): By default, debug text will always face the camera, automatically rotation. - By specifying a text orientation (quaternion), the orientation will be fixed in world space or local - space (when parent is specified). Note that a different implementation/shader is used for camera - facing text, with different appearance: camera facing text uses bitmap fonts, text with specified - orientation uses TrueType font. - parent_object_id (int): draw text in local coordinates of a parent object. - parent_link_id (int): draw text in local coordinates of a parent link. - text_id (int): replace an existing text item (to avoid flickering of remove/add). - - Returns: - int: unique user debug text id. - """ - pass - - def add_user_debug_parameter(self, name, min_range, max_range, start_value): - """ - Add custom sliders to tune parameters. - - Args: - name (str): name of the parameter. - min_range (float): minimum value. - max_range (float): maximum value. - start_value (float): starting value. - - Returns: - int: unique user debug parameter id. - """ - pass - - def read_user_debug_parameter(self, parameter_id): - """ - Read the value of the parameter / slider. - - Args: - parameter_id: unique user debug parameter id. - - Returns: - float: reading of the parameter. - """ - pass - - def remove_user_debug_item(self, item_id): - """ - Remove the specified user debug item (line, text, parameter) from the simulator. - - Args: - item_id (int): unique id of the debug item to be removed (line, text etc) - """ - pass - - def remove_all_user_debug_items(self): - """ - Remove all user debug items from the simulator. - """ - pass - - def set_debug_object_color(self, object_id, link_id, rgb_color=(1, 0, 0)): - """ - Override the color of a specific object and link. - - Args: - object_id (int): unique object id. - link_id (int): link id. - rgb_color (float[3]): RGB debug color. - """ - pass - - def add_user_data(self, object_id, key, value): - """ - Add user data (at the moment text strings) attached to any link of a body. You can also override a previous - given value. You can add multiple user data to the same body/link. - - Args: - object_id (int): unique object/link id. - key (str): key string. - value (str): value string. - - Returns: - int: user data id. - """ - pass - - def num_user_data(self, object_id): - """ - Return the number of user data associated with the specified object/link id. - - Args: - object_id (int): unique object/link id. - - Returns: - int: the number of user data - """ - pass - - def get_user_data(self, user_data_id): - """ - Get the specified user data value. - - Args: - user_data_id (int): unique user data id. - - Returns: - str: value string. - """ - pass - - def get_user_data_id(self, object_id, key): - """ - Get the specified user data id. - - Args: - object_id (int): unique object/link id. - key (str): key string. - - Returns: - int: user data id. - """ - pass - - def get_user_data_info(self, object_id, index): - """ - Get the user data info associated with the given object and index. - - Args: - object_id (int): unique object id. - index (int): index (should be between [0, self.num_user_data(object_id)]). - - Returns: - int: user data id. - str: key. - int: body id. - int: link index - int: visual shape index. - """ - pass - - def remove_user_data(self, user_data_id): - """ - Remove the specified user data. - - Args: - user_data_id (int): user data id. - """ - pass - - def sync_user_data(self): - """ - Synchronize the user data. - """ - pass - - def configure_debug_visualizer(self, flag, enable): - """Configure the debug visualizer camera. - - Configure some settings of the built-in OpenGL visualizer, such as enabling or disabling wireframe, - shadows and GUI rendering. - - Args: - flag (int): The feature to enable or disable, such as - COV_ENABLE_WIREFRAME (=3): show/hide the collision wireframe - COV_ENABLE_SHADOWS (=2): show/hide shadows - COV_ENABLE_GUI (=1): enable/disable the GUI - COV_ENABLE_VR_PICKING (=5): enable/disable VR picking - COV_ENABLE_VR_TELEPORTING (=4): enable/disable VR teleporting - COV_ENABLE_RENDERING (=7): enable/disable rendering - COV_ENABLE_TINY_RENDERER (=12): enable/disable tiny renderer - COV_ENABLE_VR_RENDER_CONTROLLERS (=6): render VR controllers - COV_ENABLE_KEYBOARD_SHORTCUTS (=9): enable/disable keyboard shortcuts - COV_ENABLE_MOUSE_PICKING (=10): enable/disable mouse picking - COV_ENABLE_Y_AXIS_UP (Z is default world up axis) (=11): enable/disable Y axis up - COV_ENABLE_RGB_BUFFER_PREVIEW (=13): enable/disable RGB buffer preview - COV_ENABLE_DEPTH_BUFFER_PREVIEW (=14): enable/disable Depth buffer preview - COV_ENABLE_SEGMENTATION_MARK_PREVIEW (=15): enable/disable segmentation mark preview - enable (bool): False (disable) or True (enable) - """ - pass - - def get_debug_visualizer(self): - """Get information about the debug visualizer camera. - - Returns: - float: width of the visualizer camera - float: height of the visualizer camera - np.float[4,4]: view matrix [4,4] - np.float[4,4]: perspective projection matrix [4,4] - np.float[3]: camera up vector expressed in the Cartesian world space - np.float[3]: forward axis of the camera expressed in the Cartesian world space - np.float[3]: This is a horizontal vector that can be used to generate rays (for mouse picking or creating - a simple ray tracer for example) - np.float[3]: This is a vertical vector that can be used to generate rays (for mouse picking or creating a - simple ray tracer for example) - float: yaw angle (in radians) of the camera, in Cartesian local space coordinates - float: pitch angle (in radians) of the camera, in Cartesian local space coordinates - float: distance between the camera and the camera target - np.float[3]: target of the camera, in Cartesian world space coordinates - """ - pass - - def reset_debug_visualizer(self, distance, yaw, pitch, target_position): - """Reset the debug visualizer camera. - - Reset the 3D OpenGL debug visualizer camera distance (between eye and camera target position), camera yaw and - pitch and camera target position - - Args: - distance (float): distance from eye to camera target position - yaw (float): camera yaw angle (in radians) left/right - pitch (float): camera pitch angle (in radians) up/down - target_position (np.float[3]): target focus point of the camera - """ - pass - - # events (mouse, keyboard) - - def get_keyboard_events(self): - """Get the key events. - - Returns: - dict: {keyId: keyState} - * `keyID` is an integer (ascii code) representing the key. Some special keys like shift, arrows, - and others are are defined in pybullet such as `B3G_SHIFT`, `B3G_LEFT_ARROW`, `B3G_UP_ARROW`,... - * `keyState` is an integer. 3 if the button has been pressed, 1 if the key is down, 2 if the key has - been triggered. - """ - pass - - def get_mouse_events(self): - """Get the mouse events. - - Returns: - list of mouse events: - eventType (int): 1 if the mouse is moving, 2 if a button has been pressed or released - mousePosX (float): x-coordinates of the mouse pointer - mousePosY (float): y-coordinates of the mouse pointer - buttonIdx (int): button index for left/middle/right mouse button. It is -1 if nothing, - 0 if left button, 1 if scroll wheel (pressed), 2 if right button - buttonState (int): 0 if nothing, 3 if the button has been pressed, 4 is the button has been released, - 1 if the key is down (never observed), 2 if the key has been triggered (never - observed). - """ - pass - - def get_mouse_and_keyboard_events(self): - """Get the mouse and key events. - - Returns: - list: list of mouse events - dict: dictionary of key events - """ - pass + # perform step + for t in count(): + sim.step() diff --git a/pyrobolearn/simulators/simulator.py b/pyrobolearn/simulators/simulator.py index 655abb7..88fc199 100644 --- a/pyrobolearn/simulators/simulator.py +++ b/pyrobolearn/simulators/simulator.py @@ -325,6 +325,63 @@ class Simulator(object): """Return True if we can define and access to the lights in the simulator.""" return False + @staticmethod + def supports_depth_image(): + """Return True if we can get depth images from the simulator.""" + return False + + @staticmethod + def supports_segmentation_images(): + """Return True if we can get segmentation images from the simulator.""" + return False + + @staticmethod + def supports_visualization(): + """Return True if there is a graphical user interface (GUI).""" + return False + + @staticmethod + def supports_interactive_gui(): + """Return True if the simulator has an interactive GUI.""" + return False + + @staticmethod + def supports_mousekeyboard_events(): + """Return True if the simulator allows to capture mouse and keyboard events.""" + return False + + @staticmethod + def supports_visual_objects(): + """Return True if we can simulate objects that do not have collision shapes.""" + return False + + @staticmethod + def supports_plugins(): + """Return True if we can use plugins.""" + return False + + @staticmethod + def supports_constraints(constraint_type): + """Return True if we can support the specified constraint type.""" + return False + + @staticmethod + def supports_realtime(): + """Return True if the simulator supports real-time (meaning we don't need to step manually in the simulator). + Note that if we can step in the simulator, we can use threads to simulate the real-time. So the return value + should always be True.""" + return True + + @staticmethod + def supports_ray_casting(): + """Return True if the simulator supports ray casting.""" + return False + + @staticmethod + def can_step(): + """Return True if we can step manually in the simulator.""" + return False + @staticmethod def can_load_heightmap(): """Return True if the simulator can load a heightmap.""" @@ -611,8 +668,8 @@ class Simulator(object): collision_shape_id (int): unique id from createCollisionShape or -1. You can re-use the collision shape for multiple multibodies (instancing) mass (float): mass of the base, in kg (if using SI units) - position (np.array[3]): Cartesian world position of the base - orientation (np.array[4]): Orientation of base as quaternion [x,y,z,w] + position (np.array[float[3]]): Cartesian world position of the base + orientation (np.array[float[4]]): Orientation of base as quaternion [x,y,z,w] Returns: int: non-negative unique id or -1 for failure. @@ -674,13 +731,13 @@ class Simulator(object): child_link_id (int): child link index, or -1 for the base joint_type (int): joint type: JOINT_PRISMATIC (=1), JOINT_FIXED (=4), JOINT_POINT2POINT (=5), JOINT_GEAR (=6) - joint_axis (np.array[3]): joint axis, in child link frame - parent_frame_position (np.array[3]): position of the joint frame relative to parent CoM frame. - child_frame_position (np.array[3]): position of the joint frame relative to a given child CoM frame (or - world origin if no child specified) - parent_frame_orientation (np.array[4]): the orientation of the joint frame relative to parent CoM + joint_axis (np.array[float[3]]): joint axis, in child link frame + parent_frame_position (np.array[float[3]]): position of the joint frame relative to parent CoM frame. + child_frame_position (np.array[float[3]]): position of the joint frame relative to a given child CoM frame + (or world origin if no child specified) + parent_frame_orientation (np.array[float[4]]): the orientation of the joint frame relative to parent CoM coordinate frame - child_frame_orientation (np.array[4]): the orientation of the joint frame relative to the child CoM + child_frame_orientation (np.array[float[4]]): the orientation of the joint frame relative to the child CoM coordinate frame (or world origin frame if no child specified) Returns: @@ -791,11 +848,11 @@ class Simulator(object): Args: body_id (int): unique body id. - link_ids (list of int): link ids associated with the given body id. If None, it will take all the links + link_ids (list[int]): link ids associated with the given body id. If None, it will take all the links of the specified body. Returns: - np.array[3]: center of mass position in the Cartesian world coordinates + np.array[float[3]]: center of mass position in the Cartesian world coordinates """ pass @@ -805,11 +862,11 @@ class Simulator(object): Args: body_id (int): unique body id. - link_ids (list of int): link ids associated with the given body id. If None, it will take all the links + link_ids (list[int]): link ids associated with the given body id. If None, it will take all the links of the specified body. Returns: - np.array[3]: center of mass linear velocity. + np.array[float[3]]: center of mass linear velocity. """ pass @@ -821,8 +878,8 @@ class Simulator(object): body_id (int): object unique id, as returned from `load_urdf`. Returns: - np.array[3]: base position - np.array[4]: base orientation (quaternion [x,y,z,w]) + np.array[float[3]]: base position + np.array[float[4]]: base orientation (quaternion [x,y,z,w]) """ pass @@ -834,7 +891,7 @@ class Simulator(object): body_id (int): object unique id, as returned from `load_urdf`. Returns: - np.array[3]: base position. + np.array[float[3]]: base position. """ pass @@ -846,7 +903,7 @@ class Simulator(object): body_id (int): object unique id, as returned from `load_urdf`. Returns: - np.array[4]: base orientation in the form of a quaternion (x,y,z,w) + np.array[float[4]]: base orientation in the form of a quaternion (x,y,z,w) """ pass @@ -856,8 +913,8 @@ class Simulator(object): Args: body_id (int): unique object id. - position (np.array[3]): new base position. - orientation (np.array[4]): new base orientation (expressed as a quaternion [x,y,z,w]) + position (np.array[float[3]]): new base position. + orientation (np.array[float[4]]): new base orientation (expressed as a quaternion [x,y,z,w]) """ pass @@ -867,7 +924,7 @@ class Simulator(object): Args: body_id (int): unique object id. - position (np.array[3]): new base position. + position (np.array[float[3]]): new base position. """ pass @@ -877,7 +934,7 @@ class Simulator(object): Args: body_id (int): unique object id. - orientation (np.array[4]): new base orientation (expressed as a quaternion [x,y,z,w]) + orientation (np.array[float[4]]): new base orientation (expressed as a quaternion [x,y,z,w]) """ pass @@ -889,8 +946,8 @@ class Simulator(object): body_id (int): object unique id, as returned from `load_urdf`. Returns: - np.array[3]: linear velocity of the base in Cartesian world space coordinates - np.array[3]: angular velocity of the base in Cartesian world space coordinates + np.array[float[3]]: linear velocity of the base in Cartesian world space coordinates + np.array[float[3]]: angular velocity of the base in Cartesian world space coordinates """ pass @@ -902,7 +959,7 @@ class Simulator(object): body_id (int): object unique id, as returned from `load_urdf`. Returns: - np.array[3]: linear velocity of the base in Cartesian world space coordinates + np.array[float[3]]: linear velocity of the base in Cartesian world space coordinates """ pass @@ -914,7 +971,7 @@ class Simulator(object): body_id (int): object unique id, as returned from `load_urdf`. Returns: - np.array[3]: angular velocity of the base in Cartesian world space coordinates + np.array[float[3]]: angular velocity of the base in Cartesian world space coordinates """ pass @@ -924,8 +981,8 @@ class Simulator(object): Args: body_id (int): unique object id. - linear_velocity (np.array[3]): new linear velocity of the base. - angular_velocity (np.array[3]): new angular velocity of the base. + linear_velocity (np.array[float[3]]): new linear velocity of the base. + angular_velocity (np.array[float[3]]): new angular velocity of the base. """ pass @@ -935,7 +992,7 @@ class Simulator(object): Args: body_id (int): unique object id. - linear_velocity (np.array[3]): new linear velocity of the base + linear_velocity (np.array[float[3]]): new linear velocity of the base """ pass @@ -945,7 +1002,7 @@ class Simulator(object): Args: body_id (int): unique object id. - angular_velocity (np.array[3]): new angular velocity of the base + angular_velocity (np.array[float[3]]): new angular velocity of the base """ pass @@ -957,8 +1014,8 @@ class Simulator(object): body_id (int): unique object id. Returns: - np.array[3]: linear acceleration [m/s^2] - np.array[3]: angular acceleration [rad/s^2] + np.array[float[3]]: linear acceleration [m/s^2] + np.array[float[3]]: angular acceleration [rad/s^2] """ pass @@ -969,8 +1026,8 @@ class Simulator(object): Args: body_id (int): unique body id. link_id (int): unique link id. If -1, it will be the base. - force (np.array[3]): external force to be applied. - position (np.array[3]): position on the link where the force is applied. See `flags` for coordinate + force (np.array[float[3]]): external force to be applied. + position (np.array[float[3]]): position on the link where the force is applied. See `flags` for coordinate systems. If None, it is the center of mass of the body (or the link if specified). frame (int): if frame = 1, then the force / position is described in the link frame. If frame = 2, they are described in the world frame. @@ -1056,7 +1113,7 @@ class Simulator(object): Returns: float: The position value of this joint. float: The velocity value of this joint. - np.array[6]: These are the joint reaction forces, if a torque sensor is enabled for this joint it is + np.array[float[6]]: These are the joint reaction forces, if a torque sensor is enabled for this joint it is [Fx, Fy, Fz, Mx, My, Mz]. Without torque sensor, it is [0, 0, 0, 0, 0, 0]. float: This is the motor torque applied during the last stepSimulation. Note that this only applies in VELOCITY_CONTROL and POSITION_CONTROL. If you use TORQUE_CONTROL then the applied joint motor torque @@ -1070,14 +1127,14 @@ class Simulator(object): Args: body_id (int): unique body id. - joint_ids (list of int): list of joint ids. + joint_ids (list[int]): list of joint ids. Returns: list: float: The position value of this joint. float: The velocity value of this joint. - np.array[6]: These are the joint reaction forces, if a torque sensor is enabled for this joint it is - [Fx, Fy, Fz, Mx, My, Mz]. Without torque sensor, it is [0, 0, 0, 0, 0, 0]. + np.array[float[6]]: These are the joint reaction forces, if a torque sensor is enabled for this joint + it is [Fx, Fy, Fz, Mx, My, Mz]. Without torque sensor, it is [0, 0, 0, 0, 0, 0]. float: This is the motor torque applied during the last `step`. Note that this only applies in VELOCITY_CONTROL and POSITION_CONTROL. If you use TORQUE_CONTROL then the applied joint motor torque is exactly what you provide, so there is no need to report it separately. @@ -1126,17 +1183,17 @@ class Simulator(object): joint_ids (int): joint/link id, or list of joint ids. control_mode (int): POSITION_CONTROL (=2) (which is in fact CONTROL_MODE_POSITION_VELOCITY_PD), VELOCITY_CONTROL (=0), TORQUE_CONTROL (=1) and PD_CONTROL (=3). - positions (float, np.array[N]): target joint position(s) (used in POSITION_CONTROL). - velocities (float, np.array[N]): target joint velocity(ies). In VELOCITY_CONTROL and POSITION_CONTROL, - the target velocity(ies) is(are) the desired velocity of the joint. Note that the target velocity(ies) - is(are) not the maximum joint velocity(ies). In PD_CONTROL and + positions (float, np.array[float[N]]): target joint position(s) (used in POSITION_CONTROL). + velocities (float, np.array[float[N]]): target joint velocity(ies). In VELOCITY_CONTROL and + POSITION_CONTROL, the target velocity(ies) is(are) the desired velocity of the joint. Note that the + target velocity(ies) is(are) not the maximum joint velocity(ies). In PD_CONTROL and POSITION_CONTROL/CONTROL_MODE_POSITION_VELOCITY_PD, the final target velocities are computed using: `kp*(erp*(desiredPosition-currentPosition)/dt)+currentVelocity+kd*(m_desiredVelocity - currentVelocity)` - forces (float, list of float): in POSITION_CONTROL and VELOCITY_CONTROL, these are the maximum motor + forces (float, list[float]): in POSITION_CONTROL and VELOCITY_CONTROL, these are the maximum motor forces used to reach the target values. In TORQUE_CONTROL these are the forces / torques to be applied each simulation step. - kp (float, list of float): position (stiffness) gain(s) (used in POSITION_CONTROL). - kd (float, list of float): velocity (damping) gain(s) (used in POSITION_CONTROL). + kp (float, list[float]): position (stiffness) gain(s) (used in POSITION_CONTROL). + kd (float, list[float]): velocity (damping) gain(s) (used in POSITION_CONTROL). max_velocity (float): in POSITION_CONTROL this limits the velocity to a maximum. """ pass @@ -1153,15 +1210,16 @@ class Simulator(object): using forward kinematics. Returns: - np.array[3]: Cartesian world position of CoM - np.array[4]: Cartesian world orientation of CoM, in quaternion [x,y,z,w] - np.array[3]: local position offset of inertial frame (center of mass) expressed in the URDF link frame - np.array[4]: local orientation (quaternion [x,y,z,w]) offset of the inertial frame expressed in URDF link + np.array[float[3]]: Cartesian world position of CoM + np.array[float[4]]: Cartesian world orientation of CoM, in quaternion [x,y,z,w] + np.array[float[3]]: local position offset of inertial frame (center of mass) expressed in the URDF link frame - np.array[3]: world position of the URDF link frame - np.array[4]: world orientation of the URDF link frame - np.array[3]: Cartesian world linear velocity. Only returned if `compute_velocity` is True. - np.array[3]: Cartesian world angular velocity. Only returned if `compute_velocity` is True. + np.array[float[4]]: local orientation (quaternion [x,y,z,w]) offset of the inertial frame expressed in + URDF link frame + np.array[float[3]]: world position of the URDF link frame + np.array[float[4]]: world orientation of the URDF link frame + np.array[float[3]]: Cartesian world linear velocity. Only returned if `compute_velocity` is True. + np.array[float[3]]: Cartesian world angular velocity. Only returned if `compute_velocity` is True. """ pass @@ -1171,22 +1229,23 @@ class Simulator(object): Args: body_id (int): body unique id. - link_ids (list of int): list of link index. + link_ids (list[int]): list of link index. compute_velocity (bool): If True, the Cartesian world velocity will be computed and returned. compute_forward_kinematics (bool): if True, the Cartesian world position/orientation will be recomputed using forward kinematics. Returns: list: - np.array[3]: Cartesian position of CoM - np.array[4]: Cartesian orientation of CoM, in quaternion [x,y,z,w] - np.array[3]: local position offset of inertial frame (center of mass) expressed in the URDF link frame - np.array[4]: local orientation (quaternion [x,y,z,w]) offset of the inertial frame expressed in URDF + np.array[float[3]]: Cartesian position of CoM + np.array[float[4]]: Cartesian orientation of CoM, in quaternion [x,y,z,w] + np.array[float[3]]: local position offset of inertial frame (center of mass) expressed in the URDF link frame - np.array[3]: world position of the URDF link frame - np.array[4]: world orientation of the URDF link frame - np.array[3]: Cartesian world linear velocity. Only returned if `compute_velocity` is True. - np.array[3]: Cartesian world angular velocity. Only returned if `compute_velocity` is True. + np.array[float[4]]: local orientation (quaternion [x,y,z,w]) offset of the inertial frame expressed + in URDF link frame + np.array[float[3]]: world position of the URDF link frame + np.array[float[4]]: world orientation of the URDF link frame + np.array[float[3]]: Cartesian world linear velocity. Only returned if `compute_velocity` is True. + np.array[float[3]]: Cartesian world angular velocity. Only returned if `compute_velocity` is True. """ pass @@ -1196,7 +1255,7 @@ class Simulator(object): Args: body_id (int): unique body id. - link_ids (int, list of int): link id, or list of link ids. + link_ids (int, list[int]): link id, or list of link ids. Returns: if 1 link: @@ -1212,7 +1271,7 @@ class Simulator(object): Args: body_id (int): unique body id. - link_ids (int, list of int): link id, or list of link ids. + link_ids (int, list[int]): link id, or list of link ids. Returns: if 1 link: @@ -1232,11 +1291,11 @@ class Simulator(object): Returns: if 1 link: - np.array[3]: the link frame position in the world space - np.array[4]: Cartesian orientation of the link frame [x,y,z,w] + np.array[float[3]]: the link frame position in the world space + np.array[float[4]]: Cartesian orientation of the link frame [x,y,z,w] if multiple links: - np.array[N,3]: link frame position of each link in world space - np.array[N,4]: orientation of each link frame [x,y,z,w] + np.array[float[N,3]]: link frame position of each link in world space + np.array[float[N,4]]: orientation of each link frame [x,y,z,w] """ pass @@ -1246,13 +1305,13 @@ class Simulator(object): Args: body_id (int): unique body id. - link_ids (list of int): list of link indices. + link_ids (list[int]): list of link indices. Returns: if 1 link: - np.array[3]: the link CoM position in the world space + np.array[float[3]]: the link CoM position in the world space if multiple links: - np.array[N,3]: CoM position of each link in world space + np.array[float[N,3]]: CoM position of each link in world space """ pass @@ -1265,13 +1324,13 @@ class Simulator(object): Args: body_id (int): unique body id. - link_ids (list of int): list of link indices. + link_ids (list[int]): list of link indices. Returns: if 1 link: - np.array[4]: Cartesian orientation of the link CoM (x,y,z,w) + np.array[float[4]]: Cartesian orientation of the link CoM (x,y,z,w) if multiple links: - np.array[N,4]: CoM orientation of each link (x,y,z,w) + np.array[float[N,4]]: CoM orientation of each link (x,y,z,w) """ pass @@ -1284,13 +1343,13 @@ class Simulator(object): Args: body_id (int): unique body id. - link_ids (list of int): list of link indices. + link_ids (list[int]): list of link indices. Returns: if 1 link: - np.array[3]: linear velocity of the link in the Cartesian world space + np.array[float[3]]: linear velocity of the link in the Cartesian world space if multiple links: - np.array[N,3]: linear velocity of each link + np.array[float[N,3]]: linear velocity of each link """ pass @@ -1300,13 +1359,13 @@ class Simulator(object): Args: body_id (int): unique body id. - link_ids (list of int): list of link indices. + link_ids (list[int]): list of link indices. Returns: if 1 link: - np.array[3]: angular velocity of the link in the Cartesian world space + np.array[float[3]]: angular velocity of the link in the Cartesian world space if multiple links: - np.array[N,3]: angular velocity of each link + np.array[float[N,3]]: angular velocity of each link """ pass @@ -1317,13 +1376,13 @@ class Simulator(object): Args: body_id (int): unique body id. - link_ids (list of int): list of link indices. + link_ids (list[int]): list of link indices. Returns: if 1 link: - np.array[6]: linear and angular velocity of the link in the Cartesian world space + np.array[float[6]]: linear and angular velocity of the link in the Cartesian world space if multiple links: - np.array[N,6]: linear and angular velocity of each link + np.array[float[N,6]]: linear and angular velocity of each link """ pass @@ -1337,13 +1396,13 @@ class Simulator(object): Args: body_id (int): unique body id. - link_ids (list of int): list of link indices. + link_ids (list[int]): list of link indices. Returns: if 1 link: - np.array[6]: linear and angular acceleration of the link in the Cartesian world space + np.array[float[6]]: linear and angular acceleration of the link in the Cartesian world space if multiple links: - np.array[N,6]: linear and angular acceleration of each link + np.array[float[N,6]]: linear and angular acceleration of each link """ pass @@ -1353,13 +1412,13 @@ class Simulator(object): Args: body_id (int): unique body id. - joint_ids (int, list of int): a joint id, or list of joint ids. + joint_ids (int, list[int]): a joint id, or list of joint ids. Returns: if 1 joint: int: q index if multiple joints: - np.int[N]: q indices + list[int]: q indices """ pass @@ -1371,7 +1430,7 @@ class Simulator(object): body_id (int): unique body id. Returns: - list of int: actuated joint ids. + list[int]: actuated joint ids. """ pass @@ -1381,7 +1440,7 @@ class Simulator(object): Args: body_id (int): unique body id. - joint_ids (int, list of int): a joint id, or list of joint ids. + joint_ids (int, list[int]): a joint id, or list of joint ids. Returns: if 1 joint: @@ -1397,7 +1456,7 @@ class Simulator(object): Args: body_id (int): unique body id. - joint_ids (int, list of int): a joint id, or list of joint ids. + joint_ids (int, list[int]): a joint id, or list of joint ids. Returns: if 1 joint: @@ -1412,7 +1471,7 @@ class Simulator(object): Args: body_id (int): unique body id. - joint_ids (int, list of int): a joint id, or list of joint ids. + joint_ids (int, list[int]): a joint id, or list of joint ids. Returns: if 1 joint: @@ -1427,13 +1486,13 @@ class Simulator(object): Args: body_id (int): unique body id. - joint_ids (int, list of int): a joint id, or list of joint ids. + joint_ids (int, list[int]): a joint id, or list of joint ids. Returns: if 1 joint: float: damping coefficient of the given joint if multiple joints: - np.array[N]: damping coefficient for each specified joint + np.array[float[N]]: damping coefficient for each specified joint """ pass @@ -1443,13 +1502,13 @@ class Simulator(object): Args: body_id (int): unique body id. - joint_ids (int, list of int): a joint id, or list of joint ids. + joint_ids (int, list[int]): a joint id, or list of joint ids. Returns: if 1 joint: float: friction coefficient of the given joint if multiple joints: - np.array[N]: friction coefficient for each specified joint + np.array[float[N]]: friction coefficient for each specified joint """ pass @@ -1459,11 +1518,11 @@ class Simulator(object): Args: body_id (int): unique body id. - joint_ids (int, list of int): a joint id, or list of joint ids. + joint_ids (int, list[int]): a joint id, or list of joint ids. Returns: if 1 joint: - np.array[2]: lower and upper limit + np.array[float[2]]]: lower and upper limit if multiple joints: np.array[N,2]: lower and upper limit for each specified joint """ @@ -1477,13 +1536,13 @@ class Simulator(object): Args: body_id (int): unique body id. - joint_ids (int, list of int): a joint id, or list of joint ids. + joint_ids (int, list[int]): a joint id, or list of joint ids. Returns: if 1 joint: float: maximum force [N] if multiple joints: - np.array[N]: maximum force for each specified joint [N] + np.array[float[N]]: maximum force for each specified joint [N] """ pass @@ -1495,13 +1554,13 @@ class Simulator(object): Args: body_id (int): unique body id. - joint_ids (int, list of int): a joint id, or list of joint ids. + joint_ids (int, list[int]): a joint id, or list of joint ids. Returns: if 1 joint: float: maximum velocity [rad/s] if multiple joints: - np.array[N]: maximum velocities for each specified joint [rad/s] + np.array[float[N]]: maximum velocities for each specified joint [rad/s] """ pass @@ -1511,13 +1570,13 @@ class Simulator(object): Args: body_id (int): unique body id. - joint_ids (int, list of int): a joint id, or list of joint ids. + joint_ids (int, list[int]): a joint id, or list of joint ids. Returns: if 1 joint: - np.array[3]: joint axis + np.array[float[3]]: joint axis if multiple joint: - np.array[N,3]: list of joint axis + np.array[float[N,3]]: list of joint axis """ pass @@ -1527,12 +1586,12 @@ class Simulator(object): Args: body_id (int): unique body id. - joint_ids (int, list of int): joint id, or list of joint ids. - positions (float, np.array[N]): desired position, or list of desired positions [rad] - velocities (None, float, np.array[N]): desired velocity, or list of desired velocities [rad/s] - kps (None, float, np.array[N]): position gain(s) - kds (None, float, np.array[N]): velocity gain(s) - forces (None, float, np.array[N]): maximum motor force(s)/torque(s) used to reach the target values. + joint_ids (int, list[int]): joint id, or list of joint ids. + positions (float, np.array[float[N]]): desired position, or list of desired positions [rad] + velocities (None, float, np.array[float[N]]): desired velocity, or list of desired velocities [rad/s] + kps (None, float, np.array[float[N]]): position gain(s) + kds (None, float, np.array[float[N]]): velocity gain(s) + forces (None, float, np.array[float[N]]): maximum motor force(s)/torque(s) used to reach the target values. """ pass @@ -1542,13 +1601,13 @@ class Simulator(object): Args: body_id (int): unique body id. - joint_ids (int, list of int): joint id, or list of joint ids. + joint_ids (int, list[int]): joint id, or list of joint ids. Returns: if 1 joint: float: joint position [rad] if multiple joints: - np.array[N]: joint positions [rad] + np.array[float[N]]: joint positions [rad] """ pass @@ -1558,9 +1617,9 @@ class Simulator(object): Args: body_id (int): unique body id. - joint_ids (int, list of int): joint id, or list of joint ids. - velocities (float, np.array[N]): desired velocity, or list of desired velocities [rad/s] - max_force (None, float, np.array[N]): maximum motor forces/torques + joint_ids (int, list[int]): joint id, or list of joint ids. + velocities (float, np.array[float[N]]): desired velocity, or list of desired velocities [rad/s] + max_force (None, float, np.array[float[N]]): maximum motor forces/torques """ pass @@ -1570,13 +1629,13 @@ class Simulator(object): Args: body_id (int): unique body id. - joint_ids (int, list of int): joint id, or list of joint ids. + joint_ids (int, list[int]): joint id, or list of joint ids. Returns: if 1 joint: float: joint velocity [rad/s] if multiple joints: - np.array[N]: joint velocities [rad/s] + np.array[float[N]]: joint velocities [rad/s] """ pass @@ -1587,9 +1646,9 @@ class Simulator(object): Args: body_id (int): unique body id. - joint_ids (int, list of int): joint id, or list of joint ids. - accelerations (float, np.array[N]): desired joint acceleration, or list of desired joint accelerations - [rad/s^2] + joint_ids (int, list[int]): joint id, or list of joint ids. + accelerations (float, np.array[float[N]]): desired joint acceleration, or list of desired joint + accelerations [rad/s^2] """ pass @@ -1599,13 +1658,13 @@ class Simulator(object): Args: body_id (int): unique body id. - joint_ids (int, list of int): joint id, or list of joint ids. + joint_ids (int, list[int]): joint id, or list of joint ids. Returns: if 1 joint: float: joint acceleration [rad/s^2] if multiple joints: - np.array[N]: joint accelerations [rad/s^2] + np.array[float[N]]: joint accelerations [rad/s^2] """ pass @@ -1615,8 +1674,8 @@ class Simulator(object): Args: body_id (int): unique body id. - joint_ids (int, list of int): joint id, or list of joint ids. - torques (float, list of float): desired torque(s) to apply to the joint(s) [N]. + joint_ids (int, list[int]): joint id, or list of joint ids. + torques (float, list[float], np.array[float]): desired torque(s) to apply to the joint(s) [N]. """ pass @@ -1626,13 +1685,13 @@ class Simulator(object): Args: body_id (int): unique body id. - joint_ids (int, list of int): a joint id, or list of joint ids. + joint_ids (int, list[int]): a joint id, or list of joint ids. Returns: if 1 joint: float: torque [Nm] if multiple joints: - np.array[N]: torques associated to the given joints [Nm] + np.array[float[N]]: torques associated to the given joints [Nm] """ pass @@ -1646,9 +1705,9 @@ class Simulator(object): Returns: if 1 joint: - np.array[6]: joint reaction force (fx,fy,fz,mx,my,mz) [N,Nm] + np.array[float[6]]: joint reaction force (fx,fy,fz,mx,my,mz) [N,Nm] if multiple joints: - np.array[N,6]: joint reaction forces [N, Nm] + np.array[float[N,6]]: joint reaction forces [N, Nm] """ pass @@ -1663,7 +1722,7 @@ class Simulator(object): if 1 joint: float: joint power [W] if multiple joints: - np.array[N]: power at each joint [W] + np.array[float[N]]: power at each joint [W] """ pass @@ -1680,25 +1739,26 @@ class Simulator(object): shape_type (int): type of shape; GEOM_SPHERE (=2), GEOM_BOX (=3), GEOM_CAPSULE (=7), GEOM_CYLINDER (=4), GEOM_PLANE (=6), GEOM_MESH (=5) radius (float): only for GEOM_SPHERE, GEOM_CAPSULE, GEOM_CYLINDER - half_extents (np.array[3], list/tuple of 3 floats): only for GEOM_BOX. + half_extents (np.array[float[3]], list/tuple of 3 floats): only for GEOM_BOX. length (float): only for GEOM_CAPSULE, GEOM_CYLINDER (length = height). filename (str): Filename for GEOM_MESH, currently only Wavefront .obj. Will create convex hulls for each object (marked as 'o') in the .obj file. - mesh_scale (np.array[3], list/tuple of 3 floats): scale of mesh (only for GEOM_MESH). - plane_normal (np.array[3], list/tuple of 3 floats): plane normal (only for GEOM_PLANE). + mesh_scale (np.array[float[3]], list/tuple of 3 floats): scale of mesh (only for GEOM_MESH). + plane_normal (np.array[float[3]], list/tuple of 3 floats): plane normal (only for GEOM_PLANE). flags (int): unused / to be decided rgba_color (list/tuple of 4 floats): color components for red, green, blue and alpha, each in range [0..1]. specular_color (list/tuple of 3 floats): specular reflection color, red, green, blue components in range [0..1] - visual_frame_position (np.array[3]): translational offset of the visual shape with respect to the link frame - vertices (list of np.array[3]): Instead of creating a mesh from obj file, you can provide vertices, indices, - uvs and normals - indices (list of int): triangle indices, should be a multiple of 3. + visual_frame_position (np.array[float[3]]): translational offset of the visual shape with respect to the + link frame + vertices (list[np.array[float[3]]]): Instead of creating a mesh from obj file, you can provide vertices, + indices, uvs and normals + indices (list[int]): triangle indices, should be a multiple of 3. uvs (list of np.array[2]): uv texture coordinates for vertices. Use changeVisualShape to choose the texture image. The number of uvs should be equal to number of vertices - normals (list of np.array[3]): vertex normals, number should be equal to number of vertices. - visual_frame_orientation (np.array[4]): rotational offset (quaternion x,y,z,w) of the visual shape with - respect to the link frame + normals (list[np.array[float[3]]]): vertex normals, number should be equal to number of vertices. + visual_frame_orientation (np.array[float[4]]): rotational offset (quaternion x,y,z,w) of the visual shape + with respect to the link frame Returns: int: The return value is a non-negative int unique id for the visual shape or -1 if the call failed. @@ -1718,11 +1778,11 @@ class Simulator(object): int: object unique id. int: link index or -1 for the base int: visual geometry type (TBD) - np.array[3]: dimensions (size, local scale) of the geometry + np.array[float[3]]: dimensions (size, local scale) of the geometry str: path to the triangle mesh, if any. Typically relative to the URDF, SDF or MJCF file location, but could be absolute - np.array[3]: position of local visual frame, relative to link/joint frame - np.array[4]: orientation of local visual frame relative to link/joint frame + np.array[float[3]]: position of local visual frame, relative to link/joint frame + np.array[float[4]]: orientation of local visual frame relative to link/joint frame list of 4 floats: URDF color (if any specified) in Red / Green / Blue / Alpha int: texture unique id of the shape or -1 if None. This field only exists if using VISUAL_SHAPE_DATA_TEXTURE_UNIQUE_IDS (=1) flag. @@ -1767,12 +1827,12 @@ class Simulator(object): of turning the camera to capture what we want in the world, we keep the camera fixed and turn the world. Args: - eye_position (np.array[3]): eye position in Cartesian world coordinates - target_position (np.array[3]): position of the target (focus) point in Cartesian world coordinates - up_vector (np.array[3]): up vector of the camera in Cartesian world coordinates + eye_position (np.array[float[3]]): eye position in Cartesian world coordinates + target_position (np.array[float[3]]): position of the target (focus) point in Cartesian world coordinates + up_vector (np.array[float[3]]): up vector of the camera in Cartesian world coordinates Returns: - np.array[4,4]: the view matrix + np.array[float[4,4]]: the view matrix """ pass @@ -1784,7 +1844,7 @@ class Simulator(object): of turning the camera to capture what we want in the world, we keep the camera fixed and turn the world. Args: - target_position (np.array[3]): target focus point in Cartesian world coordinates + target_position (np.array[float[3]]): target focus point in Cartesian world coordinates distance (float): distance from eye to focus point yaw (float): yaw angle in radians left/right around up-axis pitch (float): pitch in radians up/down. @@ -1792,7 +1852,7 @@ class Simulator(object): up_axis_index (int): either 1 for Y or 2 for Z axis up. Returns: - np.array[4,4]: the view matrix + np.array[float[4,4]]: the view matrix """ pass @@ -1817,7 +1877,7 @@ class Simulator(object): far (float): far plane distance Returns: - np.array[4,4]: the perspective projection matrix + np.array[float[4,4]]: the perspective projection matrix """ pass @@ -1831,7 +1891,7 @@ class Simulator(object): far (float): far plane distance Returns: - np.array[4,4]: the perspective projection matrix + np.array[float[4,4]]: the perspective projection matrix """ pass @@ -1845,11 +1905,11 @@ class Simulator(object): Args: width (int): horizontal image resolution in pixels height (int): vertical image resolution in pixels - view_matrix (np.array[4,4]): 4x4 view matrix, see `compute_view_matrix` - projection_matrix (np.array[4,4]): 4x4 projection matrix, see `compute_projection` - light_direction (np.array[3]): `light_direction` specifies the world position of the light source, + view_matrix (np.array[float[4,4]]): 4x4 view matrix, see `compute_view_matrix` + projection_matrix (np.array[float[4,4]]): 4x4 projection matrix, see `compute_projection` + light_direction (np.array[float[3]]): `light_direction` specifies the world position of the light source, the direction is from the light source position to the origin of the world frame. - light_color (np.array[3]): directional light color in [RED,GREEN,BLUE] in range 0..1 + light_color (np.array[float[3]]): directional light color in [RED,GREEN,BLUE] in range 0..1 light_distance (float): distance of the light along the normalized `light_direction` shadow (bool): True for shadows, False for no shadows light_ambient_coeff (float): light ambient coefficient @@ -1861,9 +1921,9 @@ class Simulator(object): Returns: int: width image resolution in pixels (horizontal) int: height image resolution in pixels (vertical) - np.int[width, height, 4]: RBGA pixels (each pixel is in the range [0..255] for each channel R, G, B, A) - np.array[width, height]: Depth buffer. - np.int[width, height]: Segmentation mask buffer. For each pixels the visible object unique id. + np.array[int[width, height, 4]]: RBGA pixels (each pixel is in the range [0..255] for each channel) + np.array[float[width, height]]: Depth buffer. + np.array[int[width, height]]: Segmentation mask buffer. For each pixels the visible object unique id. """ pass @@ -1876,11 +1936,11 @@ class Simulator(object): Args: width (int): horizontal image resolution in pixels height (int): vertical image resolution in pixels - view_matrix (np.array[4,4]): 4x4 view matrix, see `compute_view_matrix` - projection_matrix (np.array[4,4]): 4x4 projection matrix, see `compute_projection` - light_direction (np.array[3]): `light_direction` specifies the world position of the light source, + view_matrix (np.array[float[4,4]]): 4x4 view matrix, see `compute_view_matrix` + projection_matrix (np.array[float[4,4]]): 4x4 projection matrix, see `compute_projection` + light_direction (np.array[float[3]]): `light_direction` specifies the world position of the light source, the direction is from the light source position to the origin of the world frame. - light_color (np.array[3]): directional light color in [RED,GREEN,BLUE] in range 0..1 + light_color (np.array[float[3]]): directional light color in [RED,GREEN,BLUE] in range 0..1 light_distance (float): distance of the light along the normalized `light_direction` shadow (bool): True for shadows, False for no shadows light_ambient_coeff (float): light ambient coefficient @@ -1890,7 +1950,7 @@ class Simulator(object): flags (int): flags. Returns: - np.int[width, height, 4]: RBGA pixels (each pixel is in the range [0..255] for each channel R, G, B, A) + np.array[int[width, height, 4]]: RBGA pixels (each pixel is in the range [0..255] for each channel) """ pass @@ -1903,11 +1963,11 @@ class Simulator(object): Args: width (int): horizontal image resolution in pixels height (int): vertical image resolution in pixels - view_matrix (np.array[4,4]): 4x4 view matrix, see `compute_view_matrix` - projection_matrix (np.array[4,4]): 4x4 projection matrix, see `compute_projection` - light_direction (np.array[3]): `light_direction` specifies the world position of the light source, + view_matrix (np.array[float[4,4]]): 4x4 view matrix, see `compute_view_matrix` + projection_matrix (np.array[float[4,4]]): 4x4 projection matrix, see `compute_projection` + light_direction (np.array[float[3]]): `light_direction` specifies the world position of the light source, the direction is from the light source position to the origin of the world frame. - light_color (np.array[3]): directional light color in [RED,GREEN,BLUE] in range 0..1 + light_color (np.array[float[3]]): directional light color in [RED,GREEN,BLUE] in range 0..1 light_distance (float): distance of the light along the normalized `light_direction` shadow (bool): True for shadows, False for no shadows light_ambient_coeff (float): light ambient coefficient @@ -1917,7 +1977,7 @@ class Simulator(object): flags (int): flags. Returns: - np.array[width, height]: Depth buffer. + np.array[float[width, height]]: Depth buffer. """ pass @@ -1931,11 +1991,11 @@ class Simulator(object): Args: width (int): horizontal image resolution in pixels height (int): vertical image resolution in pixels - view_matrix (np.array[4,4]): 4x4 view matrix, see `compute_view_matrix` - projection_matrix (np.array[4,4]): 4x4 projection matrix, see `compute_projection` - light_direction (np.array[3]): `light_direction` specifies the world position of the light source, + view_matrix (np.array[float[4,4]]): 4x4 view matrix, see `compute_view_matrix` + projection_matrix (np.array[float[4,4]]): 4x4 projection matrix, see `compute_projection` + light_direction (np.array[float[3]]): `light_direction` specifies the world position of the light source, the direction is from the light source position to the origin of the world frame. - light_color (np.array[3]): directional light color in [RED,GREEN,BLUE] in range 0..1 + light_color (np.array[float[3]]): directional light color in [RED,GREEN,BLUE] in range 0..1 light_distance (float): distance of the light along the normalized `light_direction` shadow (bool): True for shadows, False for no shadows light_ambient_coeff (float): light ambient coefficient @@ -1945,7 +2005,7 @@ class Simulator(object): flags (int): flags Returns: - np.int[width, height]: Segmentation mask buffer. For each pixels the visible object unique id. + np.array[int[width, height]]: Segmentation mask buffer. For each pixels the visible object unique id. """ pass @@ -1961,17 +2021,17 @@ class Simulator(object): shape_type (int): type of shape; GEOM_SPHERE (=2), GEOM_BOX (=3), GEOM_CAPSULE (=7), GEOM_CYLINDER (=4), GEOM_PLANE (=6), GEOM_MESH (=5) radius (float): only for GEOM_SPHERE, GEOM_CAPSULE, GEOM_CYLINDER - half_extents (np.array[3], list/tuple of 3 floats): only for GEOM_BOX. + half_extents (np.array[float[3]], list/tuple of 3 floats): only for GEOM_BOX. height (float): only for GEOM_CAPSULE, GEOM_CYLINDER (length = height). filename (str): Filename for GEOM_MESH, currently only Wavefront .obj. Will create convex hulls for each object (marked as 'o') in the .obj file. - mesh_scale (np.array[3], list/tuple of 3 floats): scale of mesh (only for GEOM_MESH). - plane_normal (np.array[3], list/tuple of 3 floats): plane normal (only for GEOM_PLANE). + mesh_scale (np.array[float[3]], list/tuple of 3 floats): scale of mesh (only for GEOM_MESH). + plane_normal (np.array[float[3]], list/tuple of 3 floats): plane normal (only for GEOM_PLANE). flags (int): unused / to be decided - collision_frame_position (np.array[3]): translational offset of the collision shape with respect to the - link frame - collision_frame_orientation (np.array[4]): rotational offset (quaternion x,y,z,w) of the collision shape - with respect to the link frame + collision_frame_position (np.array[float[3]]): translational offset of the collision shape with respect + to the link frame + collision_frame_orientation (np.array[float[4]]): rotational offset (quaternion x,y,z,w) of the collision + shape with respect to the link frame Returns: int: The return value is a non-negative int unique id for the collision shape or -1 if the call failed. @@ -1990,14 +2050,14 @@ class Simulator(object): int: object unique id. int: link id. int: geometry type; GEOM_BOX (=3), GEOM_SPHERE (=2), GEOM_CAPSULE (=7), GEOM_MESH (=5), GEOM_PLANE (=6) - np.array[3]: depends on geometry type: + np.array[float[3]]: depends on geometry type: for GEOM_BOX: extents, for GEOM_SPHERE: dimensions[0] = radius, for GEOM_CAPSULE and GEOM_CYLINDER: dimensions[0] = height (length), dimensions[1] = radius. For GEOM_MESH: dimensions is the scaling factor. str: Only for GEOM_MESH: file name (and path) of the collision mesh asset. - np.array[3]: Local position of the collision frame with respect to the center of mass/inertial frame - np.array[4]: Local orientation of the collision frame with respect to the inertial frame + np.array[float[3]]: Local position of the collision frame with respect to the center of mass/inertial frame + np.array[float[4]]: Local orientation of the collision frame with respect to the inertial frame """ pass @@ -2009,11 +2069,11 @@ class Simulator(object): enlarges the AABBs a bit (extra margin and extruded along the velocity vector). Args: - aabb_min (np.array[3]): minimum coordinates of the aabb - aabb_max (np.array[3]): maximum coordinates of the aabb + aabb_min (np.array[float[3]]): minimum coordinates of the aabb + aabb_max (np.array[float[3]]): maximum coordinates of the aabb Returns: - list of int: list of object unique ids. + list[int]: list of object unique ids. """ pass @@ -2027,8 +2087,8 @@ class Simulator(object): link_id (int): link index in range [0..`getNumJoints(..)] Returns: - np.array[3]: minimum coordinates of the axis aligned bounding box - np.array[3]: maximum coordinates of the axis aligned bounding box + np.array[float[3]]: minimum coordinates of the axis aligned bounding box + np.array[float[3]]: maximum coordinates of the axis aligned bounding box """ pass @@ -2050,15 +2110,15 @@ class Simulator(object): int: body unique id of body B int: link index of body A, -1 for base int: link index of body B, -1 for base - np.array[3]: contact position on A, in Cartesian world coordinates - np.array[3]: contact position on B, in Cartesian world coordinates - np.array[3]: contact normal on B, pointing towards A + np.array[float[3]]: contact position on A, in Cartesian world coordinates + np.array[float[3]]: contact position on B, in Cartesian world coordinates + np.array[float[3]]: contact normal on B, pointing towards A float: contact distance, positive for separation, negative for penetration float: normal force applied during the last `step` float: lateral friction force in the first lateral friction direction (see next returned value) - np.array[3]: first lateral friction direction + np.array[float[3]]: first lateral friction direction float: lateral friction force in the second lateral friction direction (see next returned value) - np.array[3]: second lateral friction direction + np.array[float[3]]: second lateral friction direction """ pass @@ -2082,15 +2142,15 @@ class Simulator(object): int: body unique id of body B int: link index of body A, -1 for base int: link index of body B, -1 for base - np.array[3]: contact position on A, in Cartesian world coordinates - np.array[3]: contact position on B, in Cartesian world coordinates - np.array[3]: contact normal on B, pointing towards A + np.array[float[3]]: contact position on A, in Cartesian world coordinates + np.array[float[3]]: contact position on B, in Cartesian world coordinates + np.array[float[3]]: contact normal on B, pointing towards A float: contact distance, positive for separation, negative for penetration float: normal force applied during the last `step`. Always equal to 0. float: lateral friction force in the first lateral friction direction (see next returned value) - np.array[3]: first lateral friction direction + np.array[float[3]]: first lateral friction direction float: lateral friction force in the second lateral friction direction (see next returned value) - np.array[3]: second lateral friction direction + np.array[float[3]]: second lateral friction direction """ pass @@ -2099,16 +2159,16 @@ class Simulator(object): Performs a single raycast to find the intersection information of the first object hit. Args: - from_position (np.array[3]): start of the ray in world coordinates - to_position (np.array[3]): end of the ray in world coordinates + from_position (np.array[float[3]]): start of the ray in world coordinates + to_position (np.array[float[3]]): end of the ray in world coordinates Returns: list: int: object unique id of the hit object int: link index of the hit object, or -1 if none/parent float: hit fraction along the ray in range [0,1] along the ray. - np.array[3]: hit position in Cartesian world coordinates - np.array[3]: hit normal in Cartesian world coordinates + np.array[float[3]]: hit position in Cartesian world coordinates + np.array[float[3]]: hit normal in Cartesian world coordinates """ pass @@ -2121,8 +2181,8 @@ class Simulator(object): the objectUniqueId is -1, there is no hit. In that case, the 'hit fraction' is 1. Args: - from_positions (np.array[N,3]): list of start points for each ray, in world coordinates - to_positions (np.array[N,3]): list of end points for each ray in world coordinates + from_positions (np.array[float[N,3]]): list of start points for each ray, in world coordinates + to_positions (np.array[float[N,3]]): list of end points for each ray in world coordinates parent_object_id (int): ray from/to is in local space of a parent object parent_link_id (int): ray from/to is in local space of a parent object @@ -2131,8 +2191,8 @@ class Simulator(object): int: object unique id of the hit object int: link index of the hit object, or -1 if none/parent float: hit fraction along the ray in range [0,1] along the ray. - np.array[3]: hit position in Cartesian world coordinates - np.array[3]: hit normal in Cartesian world coordinates + np.array[float[3]]: hit position in Cartesian world coordinates + np.array[float[3]]: hit normal in Cartesian world coordinates """ pass @@ -2176,10 +2236,10 @@ class Simulator(object): Returns: float: mass in kg float: lateral friction coefficient - np.array[3]: local inertia diagonal. Note that links and base are centered around the center of mass and - aligned with the principal axes of inertia. - np.array[3]: position of inertial frame in local coordinates of the joint frame - np.array[4]: orientation of inertial frame in local coordinates of joint frame + np.array[float[3]]: local inertia diagonal. Note that links and base are centered around the center of + mass and aligned with the principal axes of inertia. + np.array[float[3]]: position of inertial frame in local coordinates of the joint frame + np.array[float[4]]: orientation of inertial frame in local coordinates of joint frame float: coefficient of restitution float: rolling friction coefficient orthogonal to contact normal float: spinning friction coefficient around contact normal @@ -2211,9 +2271,9 @@ class Simulator(object): section. friction_anchor (int): enable or disable a friction anchor: positional friction correction (disabled by default, unless set in the URDF contact section) - local_inertia_diagonal (np.array[3]): diagonal elements of the inertia tensor. Note that the base and - links are centered around the center of mass and aligned with the principal axes of inertia so there - are no off-diagonal elements in the inertia tensor. + local_inertia_diagonal (np.array[float[3]]): diagonal elements of the inertia tensor. Note that the base + and links are centered around the center of mass and aligned with the principal axes of inertia so + there are no off-diagonal elements in the inertia tensor. joint_damping (float): joint damping coefficient applied at each joint. This coefficient is read from URDF joint damping field. Keep the value close to 0. `joint_damping_force = -damping_coefficient * joint_velocity`. @@ -2234,15 +2294,15 @@ class Simulator(object): Args: body_id (int): unique body id. link_id (int): link id. - local_position (np.array[3]): the point on the specified link to compute the Jacobian (in link local + local_position (np.array[float[3]]): the point on the specified link to compute the Jacobian (in link local coordinates around its center of mass). If None, it will use the CoM position (in the link frame). - q (np.array[N]): joint positions of size N, where N is the number of DoFs. - dq (np.array[N]): joint velocities of size N, where N is the number of DoFs. - des_ddq (np.array[N]): desired joint accelerations of size N. + q (np.array[float[N]]): joint positions of size N, where N is the number of DoFs. + dq (np.array[float[N]]): joint velocities of size N, where N is the number of DoFs. + des_ddq (np.array[float[N]]): desired joint accelerations of size N. Returns: - np.array[6,N], np.array[6,(6+N)]: full geometric (linear and angular) Jacobian matrix. The number of - columns depends if the base is fixed or floating. + np.array[float[6,N]], np.array[float[6,6+N]]: full geometric (linear and angular) Jacobian matrix. The + number of columns depends if the base is fixed or floating. """ pass @@ -2262,10 +2322,10 @@ class Simulator(object): Args: body_id (int): body unique id. - q (np.array[N]): joint positions of size N, where N is the total number of DoFs. + q (np.array[float[N]]): joint positions of size N, where N is the total number of DoFs. Returns: - np.array[N,N], np.array[6+N,6+N]: inertia matrix + np.array[float[N,N]], np.array[float[6+N,6+N]]: inertia matrix """ pass @@ -2285,28 +2345,28 @@ class Simulator(object): Args: body_id (int): body unique id, as returned by `load_urdf`, etc. link_id (int): end effector link index. - position (np.array[3]): target position of the end effector (its link coordinate, not center of mass + position (np.array[float[3]]): target position of the end effector (its link coordinate, not center of mass coordinate!). By default this is in Cartesian world space, unless you provide `q_curr` joint angles. - orientation (np.array[4]): target orientation in Cartesian world space, quaternion [x,y,w,z]. If not + orientation (np.array[float[4]]): target orientation in Cartesian world space, quaternion [x,y,w,z]. If not specified, pure position IK will be used. - lower_limits (np.array[N], list of N floats): lower joint limits. Optional null-space IK. - upper_limits (np.array[N], list of N floats): upper joint limits. Optional null-space IK. - joint_ranges (np.array[N], list of N floats): range of value of each joint. - rest_poses (np.array[N], list of N floats): joint rest poses. Favor an IK solution closer to a given rest - pose. - joint_dampings (np.array[N], list of N floats): joint damping factors. Allow to tune the IK solution using - joint damping factors. + lower_limits (np.array[float[N]], list of N floats): lower joint limits. Optional null-space IK. + upper_limits (np.array[float[N]], list of N floats): upper joint limits. Optional null-space IK. + joint_ranges (np.array[float[N]], list of N floats): range of value of each joint. + rest_poses (np.array[float[N]], list of N floats): joint rest poses. Favor an IK solution closer to a + given rest pose. + joint_dampings (np.array[float[N]], list of N floats): joint damping factors. Allow to tune the IK solution + using joint damping factors. solver (int): p.IK_DLS (=0) or p.IK_SDLS (=1), Damped Least Squares or Selective Damped Least Squares, as described in the paper by Samuel Buss "Selectively Damped Least Squares for Inverse Kinematics". - q_curr (np.array[N]): list of joint positions. By default PyBullet uses the joint positions of the body. - If provided, the target_position and targetOrientation is in local space! + q_curr (np.array[float[N]]): list of joint positions. By default PyBullet uses the joint positions of the + body. If provided, the target_position and targetOrientation is in local space! max_iters (int): maximum number of iterations. Refine the IK solution until the distance between target and actual end effector position is below this threshold, or the `max_iters` is reached. threshold (float): residual threshold. Refine the IK solution until the distance between target and actual end effector position is below this threshold, or the `max_iters` is reached. Returns: - np.array[N]: joint positions (for each actuated joint). + np.array[float[N]]: joint positions (for each actuated joint). """ pass @@ -2342,12 +2402,12 @@ class Simulator(object): Args: body_id (int): body unique id. - q (np.array[N]): joint positions - dq (np.array[N]): joint velocities - des_ddq (np.array[N]): desired joint accelerations + q (np.array[float[N]]): joint positions + dq (np.array[float[N]]): joint velocities + des_ddq (np.array[float[N]]): desired joint accelerations Returns: - np.array[N]: joint torques computed using the rigid-body equation of motion + np.array[float[N]]: joint torques computed using the rigid-body equation of motion References: - [1] "Rigid Body Dynamics Algorithms", Featherstone, 2008, chap1.1 @@ -2390,12 +2450,12 @@ class Simulator(object): Args: body_id (int): unique body id. - q (np.array[N]): joint positions - dq (np.array[N]): joint velocities - torques (np.array[N]): desired joint torques + q (np.array[float[N]]): joint positions + dq (np.array[float[N]]): joint velocities + torques (np.array[float[N]]): desired joint torques Returns: - np.array[N]: joint accelerations computed using the rigid-body equation of motion + np.array[float[N]]: joint accelerations computed using the rigid-body equation of motion References: - [1] "Rigid Body Dynamics Algorithms", Featherstone, 2008, chap1.1 @@ -2416,9 +2476,9 @@ class Simulator(object): a line width and a duration in seconds. Args: - from_pos (np.array[3]): starting point of the line in Cartesian world coordinates - to_pos (np.array[3]): end point of the line in Cartesian world coordinates - rgb_color (np.array[3]): RGB color (each channel in range [0,1]) + from_pos (np.array[float[3]]): starting point of the line in Cartesian world coordinates + to_pos (np.array[float[3]]): end point of the line in Cartesian world coordinates + rgb_color (np.array[float[3]]): RGB color (each channel in range [0,1]) width (float): line width (limited by OpenGL implementation). lifetime (float): use 0 for permanent line, or positive time in seconds (afterwards the line with be removed automatically) @@ -2438,16 +2498,16 @@ class Simulator(object): Args: text (str): text. - position (np.array[3]): 3d position of the text in Cartesian world coordinates. + position (np.array[float[3]]): 3d position of the text in Cartesian world coordinates. rgb_color (list/tuple of 3 floats): RGB color; each component in range [0..1] size (float): text size lifetime (float): use 0 for permanent text, or positive time in seconds (afterwards the text with be removed automatically) - orientation (np.array[4]): By default, debug text will always face the camera, automatically rotation. - By specifying a text orientation (quaternion), the orientation will be fixed in world space or local - space (when parent is specified). Note that a different implementation/shader is used for camera - facing text, with different appearance: camera facing text uses bitmap fonts, text with specified - orientation uses TrueType font. + orientation (np.array[float[4]]): By default, debug text will always face the camera, automatically + rotation. By specifying a text orientation (quaternion), the orientation will be fixed in world space + or local space (when parent is specified). Note that a different implementation/shader is used for + camera facing text, with different appearance: camera facing text uses bitmap fonts, text with + specified orientation uses TrueType font. parent_object_id (int): draw text in local coordinates of a parent object. parent_link_id (int): draw text in local coordinates of a parent link. text_id (int): replace an existing text item (to avoid flickering of remove/add). @@ -2626,18 +2686,18 @@ class Simulator(object): Returns: float: width of the visualizer camera float: height of the visualizer camera - np.array[4,4]: view matrix [4,4] - np.array[4,4]: perspective projection matrix [4,4] - np.array[3]: camera up vector expressed in the Cartesian world space - np.array[3]: forward axis of the camera expressed in the Cartesian world space - np.array[3]: This is a horizontal vector that can be used to generate rays (for mouse picking or creating - a simple ray tracer for example) - np.array[3]: This is a vertical vector that can be used to generate rays (for mouse picking or creating a - simple ray tracer for example) + np.array[float[4,4]],4]: view matrix [4,4] + np.array[float[4,4]],4]: perspective projection matrix [4,4] + np.array[float[3]]: camera up vector expressed in the Cartesian world space + np.array[float[3]]: forward axis of the camera expressed in the Cartesian world space + np.array[float[3]]: This is a horizontal vector that can be used to generate rays (for mouse picking or + creating a simple ray tracer for example) + np.array[float[3]]: This is a vertical vector that can be used to generate rays (for mouse picking or + creating a simple ray tracer for example) float: yaw angle (in radians) of the camera, in Cartesian local space coordinates float: pitch angle (in radians) of the camera, in Cartesian local space coordinates float: distance between the camera and the camera target - np.array[3]: target of the camera, in Cartesian world space coordinates + np.array[float[3]]: target of the camera, in Cartesian world space coordinates """ pass @@ -2651,7 +2711,7 @@ class Simulator(object): distance (float): distance from eye to camera target position yaw (float): camera yaw angle (in radians) left/right pitch (float): camera pitch angle (in radians) up/down - target_position (np.array[3]): target focus point of the camera + target_position (np.array[float[3]]): target focus point of the camera """ pass diff --git a/pyrobolearn/utils/decorator.py b/pyrobolearn/utils/decorator.py index 8ba6bc8..b77f12b 100644 --- a/pyrobolearn/utils/decorator.py +++ b/pyrobolearn/utils/decorator.py @@ -2,13 +2,14 @@ """Define the various decorators used in this framework. """ +import sys import numpy import torch __author__ = "Brian Delhaisse" __copyright__ = "Copyright 2018, PyRoboLearn" __credits__ = ["Brian Delhaisse"] -__license__ = "GNU GPLv3" +__license__ = "MIT" __version__ = "1.0.0" __maintainer__ = "Brian Delhaisse" __email__ = "briandelhaisse@gmail.com" @@ -34,3 +35,15 @@ def convert_numpy(f): return x return wrapper + + +def keyboard_interrupt(func): + """Decorator to be used on a method to check if there was a keyboard interrupt error that was raised.""" + def wrap(self, *args, **kwargs): + try: + return func(self, *args, **kwargs) + except KeyboardInterrupt: + del self # this will delete/close the class + # self.close() + sys.exit(0) + return wrap diff --git a/pyrobolearn/utils/parsers/robots/data_structures.py b/pyrobolearn/utils/parsers/robots/data_structures.py index 1aadbce..0f379ad 100644 --- a/pyrobolearn/utils/parsers/robots/data_structures.py +++ b/pyrobolearn/utils/parsers/robots/data_structures.py @@ -227,13 +227,13 @@ class Light(object): name (str): unique name for the light. dtype (str): type of light, select between {'point', 'directional', 'spot'} cast_shadows (bool): if True, it will cast shadows. - diffuse (tuple of 4 float, np.array[4]): diffuse light (RGBA) color. - specular (tuple of 4 float, np.array[4]): specular light (RGBA) color. + diffuse (tuple of 4 float, np.array[float[4]]): diffuse light (RGBA) color. + specular (tuple of 4 float, np.array[float[4]]): specular light (RGBA) color. attenuation: light attenuation - direction (np.array[3]): direction of the light if dtype='directional' or dtype='spot'. + direction (np.array[float[3]]): direction of the light if dtype='directional' or dtype='spot'. spot: spot light parameters - position (tuple/list of 3 float, np.array[3]): position of the light in the world. - orientation (np.array[3], str): orientation of the light expressed as roll-pitch-yaw angles. + position (tuple/list of 3 float, np.array[float[3]]): position of the light in the world. + orientation (np.array[float[3]], str): orientation of the light expressed as roll-pitch-yaw angles. active (bool): if True, the light is on. """ self.name = name @@ -699,7 +699,7 @@ class Inertia(object): """Aligned inertia. Returns: - np.array[3]: principal moments of the inertia. + np.array[float[3]]: principal moments of the inertia. References: - [1] https://en.wikipedia.org/wiki/Moment_of_inertia#Inertia_matrix_in_different_reference_frames @@ -710,8 +710,8 @@ class Inertia(object): @property def principal_inertia(self): - """Return the principal moments of the inertia (np.array[3]), and the direction of the principal axes of the - body (np.array[3,3]).""" + """Return the principal moments of the inertia (np.array[float[3]]), and the direction of the principal axes of the + body (np.array[float[3,3]]).""" inertia = self.full_inertia evals, evecs = np.linalg.eigh(inertia) return evals, evecs @@ -812,8 +812,8 @@ class Inertial(object): mass (float): mass value (in kg) inertia (str, list / tuple of 3/6/9 float, np.ndarray[3/6/9], np.ndarray[3,3]): inertia matrix represented in the body frame. - position (np.array[3], str): position of the center of mass. - orientation (np.array[3], str): rotation expressed as roll-pitch-yaw angles. + position (np.array[float[3]], str): position of the center of mass. + orientation (np.array[float[3]], str): rotation expressed as roll-pitch-yaw angles. """ self.mass = mass self.inertia = inertia @@ -864,8 +864,8 @@ class Inertial(object): @property def principal_inertia(self): - """Return the principal moments of the inertia (np.array[3]), and the direction of the principal axes of the - body (np.array[3,3]).""" + """Return the principal moments of the inertia (np.array[float[3]]), and the direction of the principal axes + of the body (np.array[float[3,3]]).""" evals, evecs = self.inertia.principal_inertia return evals, self.rot.dot(evecs) @@ -874,7 +874,7 @@ class Inertial(object): """Aligned inertia. Returns: - np.array[3]: principal moments of the inertia. + np.array[float[3]]: principal moments of the inertia. References: - [1] https://en.wikipedia.org/wiki/Moment_of_inertia#Inertia_matrix_in_different_reference_frames diff --git a/pyrobolearn/utils/parsers/robots/urdf_parser.py b/pyrobolearn/utils/parsers/robots/urdf_parser.py index 93ddf18..8aafd7d 100644 --- a/pyrobolearn/utils/parsers/robots/urdf_parser.py +++ b/pyrobolearn/utils/parsers/robots/urdf_parser.py @@ -390,7 +390,7 @@ class URDFParser(RobotParser): # if visual.material is not None: material = visual.material - material_tag = ET.SubElement(visual, 'material', attrib={'name': material.name}) + material_tag = ET.SubElement(visual_tag, 'material', attrib={'name': material.name}) if material.color is not None: ET.SubElement(material_tag, 'color', attrib={'rgba': str(np.asarray(material.rgba))[1:-1]}) if material.texture is not None: diff --git a/pyrobolearn/utils/transformation.py b/pyrobolearn/utils/transformation.py index a3f9793..b190344 100644 --- a/pyrobolearn/utils/transformation.py +++ b/pyrobolearn/utils/transformation.py @@ -33,11 +33,11 @@ def min_angle_difference(q1, q2): always between [-pi, pi]. Args: - q1 (float, np.array[N]): first angle(s) - q2 (float, np.array[N]): second angle(s) + q1 (float, np.array[float[N]]): first angle(s) + q2 (float, np.array[float[N]]): second angle(s) Returns: - float, np.array[N]: minimum angle difference(s) + float, np.array[float[N]]: minimum angle difference(s) """ diff = np.maximum(q1, q2) - np.minimum(q1, q2) if diff > np.pi: @@ -57,12 +57,12 @@ def get_homogeneous_transform(position, orientation): where :math:`R` is the 3x3 rotation matrix, :math:`p` is the 3x1 position vector. Args: - position (np.array[3]): position vector - orientation (np.array[4], np.array[3,3], np.array[3]): orientation (expressed as a quaternion [x,y,z,w], - 3x3 rotation matrix, or roll-pitch-yaw angles). + position (np.array[float[3]]): position vector + orientation (np.array[float[4]], np.array[float[3,3]], np.array[float[3]]): orientation (expressed as a + quaternion [x,y,z,w], 3x3 rotation matrix, or roll-pitch-yaw angles). Returns: - np.array[4,4]: homogeneous matrix + np.array[float[4,4]]: homogeneous matrix """ if isinstance(orientation, quaternion.quaternion): R = quaternion.as_rotation_matrix(orientation) @@ -86,10 +86,10 @@ def homogeneous_to_pose(matrix): Return a pose (7D vector: position + quaternion) from a homogeneous matrix. Args: - matrix (np.array[4,4]): homogeneous matrix + matrix (np.array[float[4,4]]): homogeneous matrix Returns: - np.array[7]: pose (position + quaternion [x,y,z,w]) + np.array[float[7]]: pose (position + quaternion [x,y,z,w]) """ position = matrix[:3, -1] quaternion = get_quaternion_from_matrix(matrix[:3, :3]) @@ -101,10 +101,10 @@ def pose_to_homogeneous(pose): Return a homogeneous matrix from a pose (7D vector: concatenation of position and quaternion). Args: - pose (np.array[7]): concatenation of position and orientation (expressed as a quaternion [x,y,z,w]) + pose (np.array[float[7]]): concatenation of position and orientation (expressed as a quaternion [x,y,z,w]) Returns: - np.array[4,4]: homogeneous matrix + np.array[float[4,4]]: homogeneous matrix """ pose = np.array(pose).flatten() position, orientation = pose[:3], pose[-4:] @@ -117,15 +117,16 @@ def get_quaternion(orientation, convert_to_quat=False, convention='xyzw'): angles, or an axis-angle). Args: - orientation (np.array[4], np.array[3,3], np.array[3], tuple of float and np.array[3]): orientation (expressed - as a quaternion [x,y,z,w], 3x3 rotation matrix, roll-pitch-yaw angles, or axis-angle). + orientation (np.array[float[4]], np.array[float[3,3]], np.array[float[3]], tuple of float and + np.array[float[3]]): orientation (expressed as a quaternion [x,y,z,w], 3x3 rotation matrix, + roll-pitch-yaw angles, or axis-angle). convert_to_quat (bool): If True, it will return an instance of `quaternion.quaternion`. Otherwise, it will return a numpy array. convention (str): convention to be adopted when representing the quaternion. You can choose between 'xyzw' or 'wxyz'. Returns: - np.array[4], quaternion.quaternion: quaternion. + np.array[float[4]], quaternion.quaternion: quaternion. """ if isinstance(orientation, quaternion.quaternion): # quaternion return orientation @@ -157,11 +158,12 @@ def get_rotation_matrix(orientation): angles, or an axis-angle). Args: - orientation (np.array[4], np.array[3,3], np.array[3], tuple of float and np.array[3]): orientation (expressed - as a quaternion [x,y,z,w], 3x3 rotation matrix, roll-pitch-yaw angles, or axis-angle). + orientation (np.array[float[4]], np.array[float[3,3]], np.array[float[3]], tuple of float and + np.array[float[3]]): orientation (expressed as a quaternion [x,y,z,w], 3x3 rotation matrix, roll-pitch-yaw + angles, or axis-angle). Returns: - np.array[3,3]: rotation matrix. + np.array[float[3,3]]: rotation matrix. """ if isinstance(orientation, quaternion.quaternion): # quaternion return get_matrix_from_quaternion(orientation) @@ -188,11 +190,11 @@ def get_matrix_from_axis_angle(axis, angle): """Return the rotation matrix from the specified axis and angle. Args: - axis (np.float[3], list of 3 float): 3d axis vector. + axis (np.array[float[3]], list[float[3]]): 3d axis vector. angle (float): angle. Returns: - np.float[3,3]: rotation matrix. + np.array[float[3,3]]: rotation matrix. """ x, y, z = axis a = angle @@ -208,11 +210,11 @@ def get_symbolic_matrix_from_axis_angle(axis, angle): """Return the symbolic rotation matrix from the specified axis and angle. Args: - axis (np.float[3], list of 3 float, list of 3 sympy.Symbol): 3d axis vector. + axis (np.array[float[3]], list[float[3]], list[sympy.Symbol[3]]): 3d axis vector. angle (float, sympy.Symbol): angle. Returns: - np.float[3,3]: rotation matrix. + np.array[float[3,3]]: rotation matrix. """ x, y, z = axis a = angle @@ -228,11 +230,11 @@ def get_axis_angle_from_matrix(R): """Return the associated axis and angle from the specified rotation matrix. Args: - R (np.float[3,3]): 3-by-3 rotation matrix. + R (np.array[float[3,3]]): 3-by-3 rotation matrix. Returns: float: angle. - np.float[3]: 3d axis vector. + np.array[float[3]]: 3d axis vector. """ angle = np.arccos((R[0, 0] + R[1, 1] + R[2, 2] - 1) / 2.) axis = 1. / (2. * np.sin(angle)) * np.array([R[2, 1] - R[1, 2], R[0, 2] - R[2, 0], R[1, 0] - R[0, 1]]) @@ -243,11 +245,11 @@ def get_symbolic_axis_angle_from_matrix(R): """Return the symbolic axis and angle from the specified rotation matrix. Args: - R (np.array of sympy.Symbol): 3-by-3 rotation matrix. + R (np.array[sympy.Symbol[3,3]]): 3-by-3 rotation matrix. Returns: sympy.Symbol: angle. - np.array of 3 sympy.Symbol: 3d axis vector. + np.array[sympy.Symbol[3]]: 3d axis vector. """ angle = sympy.acos((R[0, 0] + R[1, 1] + R[2, 2] - 1) / 2.) axis = 1. / (2. * sympy.sin(angle)) * np.array([R[2, 1] - R[1, 2], R[0, 2] - R[2, 0], R[1, 0] - R[0, 1]]) @@ -258,14 +260,14 @@ def get_quaternion_from_axis_angle(axis, angle, convert_to_quat=False, conventio """Get the quaternion associated from the axis/angle representation. Args: - axis (np.float[3]): 3d axis vector. + axis (np.array[float[3]]): 3d axis vector. angle (float): angle. convert_to_quat (bool): If True, it will return an instance of `quaternion.quaternion`. convention (str): convention to be adopted when representing the quaternion. You can choose between 'xyzw' or 'wxyz'. Returns: - np.array[4], quaternion.quaternion: quaternion. + np.array[float[4]], quaternion.quaternion: quaternion. """ w = np.cos(angle / 2.) x, y, z = np.sin(angle / 2.) * axis @@ -284,13 +286,13 @@ def get_symbolic_quaternion_from_axis_angle(axis, angle, convention='xyzw'): """Get the symbolic quaternion associated from the axis/angle representation. Args: - axis (np.float[3], np.array of 3 sympy.Symbol): 3d axis vector. + axis (np.array[float[3]], np.array[sympy.Symbol[3]]): 3d axis vector. angle (float, sympy.Symbol): angle. convention (str): convention to be adopted when representing the quaternion. You can choose between 'xyzw' or 'wxyz'. Returns: - np.array[4]: symbolic quaternion. + np.array[float[4]]: symbolic quaternion. """ w = sympy.cos(angle / 2.) x, y, z = sympy.sin(angle / 2.) * axis @@ -306,10 +308,10 @@ def get_rpy_from_matrix(R): """Get the Roll-Pitch-Yaw angle values from the given rotation matrix. Args: - R (np.float[3,3]): 3-by-3 rotation matrix. + R (np.array[float[3,3]]): 3-by-3 rotation matrix. Returns: - np.float[3]: roll-pitch-yaw angle values. + np.array[float[3]]: roll-pitch-yaw angle values. """ # r = np.arctan2(R[1, 0], R[0, 0]) # p = np.arctan2(-R[2, 0], np.sqrt(R[2, 1]**2 + R[2, 2]**2)) @@ -326,10 +328,10 @@ def get_symbolic_rpy_from_matrix(R): """Get the symbolic Roll-Pitch-Yaw angles from the given rotation matrix. Args: - R (np.float[3,3], np.array of sympy.Symbol): symbolic 3-by-3 rotation matrix. + R (np.array[float[3,3]], np.array[sympy.Symbol[3,3]]): symbolic 3-by-3 rotation matrix. Returns: - np.array of 3 sympy.Symbol: symbolic roll-pitch-yaw angles. + np.array[sympy.Symbol[3]]: symbolic roll-pitch-yaw angles. """ # r = sympy.atan2(R[1, 0], R[0, 0]) # p = sympy.atan2(-R[2, 0], sympy.sqrt(R[2, 1] ** 2 + R[2, 2] ** 2)) @@ -346,10 +348,10 @@ def get_matrix_from_rpy(rpy): """Get rotation matrix from the given Roll-Pitch-Yaw angles. Args: - rpy (np.float[3]): roll-pitch-yaw angles + rpy (np.array[float[3]]): roll-pitch-yaw angles Returns: - np.float[3,3]: rotation matrix. + np.array[float[3,3]]: rotation matrix. """ cr, cp, cy = [np.cos(i) for i in rpy] sr, sp, sy = [np.sin(i) for i in rpy] @@ -364,10 +366,10 @@ def get_symbolic_matrix_from_rpy(rpy): Get the symbolic rotation matrix from the given Roll-Pitch-Yaw angles. Args: - rpy (np.float[3], np.array of 3 sympy.Symbol): roll-pitch-yaw angles. + rpy (np.array[float[3]], np.array[sympy.Symbol[3]]): roll-pitch-yaw angles. Returns: - 3-by-3 np.array of sympy.Symbol: symbolic rotation matrix + np.array[sympy.Symbol[3,3]]: symbolic rotation matrix """ cr, cp, cy = [sympy.cos(i) for i in rpy] sr, sp, sy = [sympy.sin(i) for i in rpy] @@ -382,13 +384,13 @@ def get_quaternion_from_matrix(R, convert_to_quat=False, convention='xyzw'): Get the quaternion from the given rotation matrix. Args: - R (np.float[3,3]): rotation matrix. + R (np.array[float[3,3]]): rotation matrix. convert_to_quat (bool): If True, it will return an instance of `quaternion.quaternion`. convention (str): convention to be adopted when representing the quaternion. You can choose between 'xyzw' or 'wxyz'. Returns: - np.array[4], quaternion.quaternion: quaternion + np.array[float[4]], quaternion.quaternion: quaternion """ w = 1./2 * np.sqrt(R[0, 0] + R[1, 1] + R[2, 2] + 1) x, y, z = 1./2 * np.array([np.sign(R[2, 1] - R[1, 2]) * np.sqrt(R[0, 0] - R[1, 1] - R[2, 2] + 1), @@ -410,12 +412,12 @@ def get_symbolic_quaternion_from_matrix(R, convention='xyzw'): Get the symbolic quaternion from the given rotation matrix. Args: - R (3-by-3 np.array of sympy.Symbol, np.float[3,3]): (symbolic) rotation matrix + R (np.array[sympy.Symbol[3,3]], np.array[float[3,3]]): (symbolic) rotation matrix convention (str): convention to be adopted when representing the quaternion. You can choose between 'xyzw' or 'wxyz'. Returns: - np.array of 4 sympy.Symbol: symbolic quaternion. + np.array[sympy.Symbol[4]]: symbolic quaternion. """ w = 1. / 2 * sympy.sqrt(R[0, 0] + R[1, 1] + R[2, 2] + 1) x, y, z = 1. / 2 * np.array([sympy.sign(R[2, 1] - R[1, 2]) * sympy.sqrt(R[0, 0] - R[1, 1] - R[2, 2] + 1), @@ -434,12 +436,12 @@ def get_matrix_from_quaternion(q, convention='xyzw'): Get rotation matrix from the given quaternion. Args: - q (np.array[4], quaternion.quaternion): quaternion + q (np.array[float[4]], quaternion.quaternion): quaternion convention (str): convention to be adopted when representing the quaternion. You can choose between 'xyzw' or 'wxyz'. Returns: - np.float[3,3]: rotation matrix. + np.array[float[3,3]]: rotation matrix. """ if isinstance(q, quaternion.quaternion): x, y, z, w = q.x, q.y, q.z, q.w @@ -463,12 +465,12 @@ def get_symbolic_matrix_from_quaternion(q, convention='xyzw'): Get symbolic rotation matrix from the given quaternion. Args: - q (np.array of 4 sympy.Symbol, np.array[4]): (symbolic) quaternion. + q (np.array[sympy.Symbol[4]], np.array[float[4]]): (symbolic) quaternion. convention (str): convention to be adopted when representing the quaternion. You can choose between 'xyzw' or 'wxyz'. Returns: - 3-by-3 np.array of sympy.Symbol: symbolic rotation matrix. + np.array[sympy.Symbol[3,3]]: symbolic rotation matrix. """ return get_matrix_from_quaternion(q, convention=convention) @@ -478,12 +480,12 @@ def get_rpy_from_quaternion(q, convention='xyzw'): Get the Roll-Pitch-Yaw angle(s) from the given quaternion(s). Args: - q (np.array[4], np.array[N,4], (list of) quaternion.quaternion): quaternion(s) + q (np.array[float[4]], np.array[float[N,4]], (list of) quaternion.quaternion): quaternion(s) convention: convention to be adopted when representing the quaternion. You can choose between 'xyzw' or 'wxyz'. Returns: - np.float[3], np.float[N,3]: roll-pitch-yaw angles. + np.array[float[3]], np.array[float[N,3]]: roll-pitch-yaw angles. """ multiple_quaternions = True if isinstance(q, quaternion.quaternion) or (isinstance(q, np.ndarray) and len(q.shape) == 1): @@ -518,12 +520,12 @@ def get_symbolic_rpy_from_quaternion(q, convention='xyzw'): Get the symbolic Roll-Pitch-Yaw angle from the given quaternion. Args: - q (np.array[4], np.array of 4 sympy.Symbol): quaternion + q (np.array[float[4]], np.array[sympy.Symbol[4]]): quaternion convention: convention to be adopted when representing the quaternion. You can choose between 'xyzw' or 'wxyz'. Returns: - np.array of 3 sympy.Symbol: symbolic roll-pitch-yaw angles. + np.array[sympy.Symbol[3]]: symbolic roll-pitch-yaw angles. """ if isinstance(q, quaternion.quaternion): x, y, z, w = q.x, q.y, q.z, q.w @@ -549,13 +551,13 @@ def get_quaternion_from_rpy(rpy, convert_to_quat=False, convention='xyzw'): Get quaternion from Roll-Pitch-Yaw angle. Args: - rpy (np.float[3], np.float[N,3]): roll-pitch-yaw angles + rpy (np.array[float[3]], np.array[float[N,3]]): roll-pitch-yaw angles convert_to_quat (bool): If True, it will return an instance of `quaternion.quaternion`. convention (str): convention to be adopted when representing the quaternion. You can choose between 'xyzw' or 'wxyz'. Returns: - np.array[4], quaternion.quaternion: quaternion + np.array[float[4]], quaternion.quaternion: quaternion """ rpy = np.asarray(rpy) multiple_rpy = True @@ -593,12 +595,12 @@ def get_symbolic_quaternion_from_rpy(rpy, convention='xyzw'): Get symbolic quaternion from Roll-Pitch-Yaw angle. Args: - rpy (np.float[3], np.array of 3 sympy.Symbol): (symbolic) roll-pitch-yaw angles + rpy (np.array[float[3]], np.array[sympy.Symbol[3]]): (symbolic) roll-pitch-yaw angles convention (str): convention to be adopted when representing the quaternion. You can choose between 'xyzw' or 'wxyz'. Returns: - np.array of 4 sympy.Symbol: symbolic quaternion + np.array[sympy.Symbol[4]]: symbolic quaternion """ r, p, y = rpy cr, sr = sympy.cos(r/2.), sympy.sin(r/2.) @@ -636,10 +638,10 @@ def skew_matrix(vector): returns the skew-symmetric matrix from the given vector. Args: - vector (np.array[3]): 3D vector + vector (np.array[float[3]]): 3D vector Returns: - np.array[3,3]: skew-symmetric matrix + np.array[float[3,3]]: skew-symmetric matrix References: - [1] Wikipedia: https://en.wikipedia.org/wiki/Skew-symmetric_matrix#Cross_product @@ -662,10 +664,10 @@ def vector_from_skew_matrix(matrix): Warnings: this function does not check if the given matrix is skew-symmetric. Args: - matrix (np.array[3,3]): skew-symmetric matrix + matrix (np.array[float[3,3]]): skew-symmetric matrix Returns: - np.array[3]: vector which produced the skew-symmetric matrix + np.array[float[3]]: vector which produced the skew-symmetric matrix References: - [1] Wikipedia: https://en.wikipedia.org/wiki/Skew-symmetric_matrix#Cross_product @@ -688,7 +690,7 @@ def rotation_matrix_x(angle): angle (float): angle in radians Returns: - np.array[3,3]: rotation matrix around the x-axis + np.array[float[3,3]]: rotation matrix around the x-axis """ c, s = np.cos(angle), np.sin(angle) return np.array([[1., 0., 0.], @@ -704,7 +706,7 @@ def rotation_matrix_y(angle): angle (float): angle in radians Returns: - np.array[3,3]: rotation matrix around the y-axis + np.array[float[3,3]]: rotation matrix around the y-axis """ c, s = np.cos(angle), np.sin(angle) return np.array([[c, 0., s], @@ -720,7 +722,7 @@ def rotation_matrix_z(angle): angle (float): angle in radians Returns: - np.array[3,3]: rotation matrix around the z-axis + np.array[float[3,3]]: rotation matrix around the z-axis """ c, s = np.cos(angle), np.sin(angle) return np.array([[c, -s, 0.], @@ -735,11 +737,11 @@ def get_spatial_transformation_matrix(rotation, position): .. math:: ^1X_2^T = Args: - rotation (np.array[3,3]): rotation matrix - position (np.array[3]): position of body + rotation (np.array[float[3,3]]): rotation matrix + position (np.array[float[3]]): position of body Returns: - np.array[6,6]: spatial transformation matrix + np.array[float[6,6]]: spatial transformation matrix """ pass @@ -764,13 +766,13 @@ def get_rotated_point_from_quaternion(q, p, convention='xyzw'): the 3D position of the point :math:`p` and its scalar part is 0. Args: - q (np.array[4], quaternion.quaternion): quaternion (it doesn't have to be a unit quaternion) - p (np.array[3]): 3d point in space. + q (np.array[float[4]], quaternion.quaternion): quaternion (it doesn't have to be a unit quaternion) + p (np.array[float[3]]): 3d point in space. convention (str): convention to be adopted when representing the quaternion. You can choose between 'xyzw' or 'wxyz'. Returns: - np.array[3]: rotated 3 point. + np.array[float[3]]: rotated 3 point. """ # TODO: fix this! p_quat = np.array([p[0], p[1], p[2], 0]) @@ -787,12 +789,12 @@ def get_quaternion_conjugate(q, convention='xyzw'): If the quaternion is a unit quaternion, the conjugate is equal to the inverse of that quaternion. Args: - q (np.array[4], quaternion.quaternion): quaternion (it doesn't have to be a unit quaternion) + q (np.array[float[4]], quaternion.quaternion): quaternion (it doesn't have to be a unit quaternion) convention (str): convention to be adopted when representing the quaternion. You can choose between 'xyzw' or 'wxyz'. Returns: - np.array[4], quaternion.quaternion: quaternion inverse. + np.array[float[4]], quaternion.quaternion: quaternion inverse. """ if isinstance(q, quaternion.quaternion): return q.inverse() @@ -814,7 +816,7 @@ def get_quaternion_norm(q): Return the norm of a quaternion: :math:`|q| = \sqrt(x^2 + y^2 + z^2 + w^2)` Args: - q (np.array[4], quaternion.quaternion): quaternion (it doesn't have to be a unit quaternion) + q (np.array[float[4]], quaternion.quaternion): quaternion (it doesn't have to be a unit quaternion) Returns: float: norm of a quaternion @@ -830,10 +832,10 @@ def normalize_quaternion(q): Return the normalized quaternion; the quaternion divided by its norm. Args: - q (np.array[4], quaternion.quaternion): quaternion (it doesn't have to be a unit quaternion) + q (np.array[float[4]], quaternion.quaternion): quaternion (it doesn't have to be a unit quaternion) Returns: - np.array[4], quaternion.quaternion: normalized quaternion. + np.array[float[4]], quaternion.quaternion: normalized quaternion. """ return q / get_quaternion_norm(q) @@ -851,12 +853,12 @@ def get_quaternion_inverse(q, convention='xyzw'): where :math:`\bar{q}` is the conjugate of the quaternion :math:`q`. Args: - q (np.array[4], quaternion.quaternion): quaternion. + q (np.array[float[4]], quaternion.quaternion): quaternion. convention (str): convention to be adopted when representing the quaternion. You can choose between 'xyzw' or 'wxyz'. Returns: - np.array[4], quaternion.quaternion: quaternion inverse. + np.array[float[4]], quaternion.quaternion: quaternion inverse. """ if isinstance(q, quaternion.quaternion): return q.inverse() @@ -880,13 +882,13 @@ def get_quaternion_product(q1, q2, convention='xyzw'): :math:`q_1 * q_2`. Args: - q1 (np.array[4], quaternion.quaternion): first quaternion - q2 (np.array[4], quaternion.quaternion): second quaternion + q1 (np.array[float[4]], quaternion.quaternion): first quaternion + q2 (np.array[float[4]], quaternion.quaternion): second quaternion convention (str): convention to be adopted when representing the quaternion. You can choose between 'xyzw' or 'wxyz'. Returns: - np.array[4], quaternion.quaternion: resulting quaternion. + np.array[float[4]], quaternion.quaternion: resulting quaternion. """ if type(q1) != type(q2): raise TypeError("Expecting q1 and q2 to be of the same type") @@ -932,11 +934,11 @@ def quaternion_error(quat_des, quat_cur): Only the vector part is returned which can be used in PD control. Args: - quat_des (np.array[4]): desired quaternion [x,y,z,w] - quat_cur (np.array[4]): current quaternion [x,y,z,w] + quat_des (np.array[float[4]]): desired quaternion [x,y,z,w] + quat_cur (np.array[float[4]]): current quaternion [x,y,z,w] Returns: - np.array[3]: vector error between the current and desired quaternion + np.array[float[3]]: vector error between the current and desired quaternion """ diff = quat_cur[-1] * quat_des[:3] - quat_des[-1] * quat_cur[:3] - skew_matrix(quat_des[:3]).dot(quat_cur[:3]) return diff @@ -960,10 +962,10 @@ def logarithm_map(q): part and :math:`\pmb{v} \in \mathbb{R}^3` the vector part. Args: - q (float[4]): quaternion + q (np.array[float[4]]): quaternion Returns: - float[3]: resulting 3d vector + np.array[float[3]]: resulting 3d vector """ q = quat_converter.convert_to(q) s, v = q.w, np.array([q.x, q.y, q.z]) @@ -995,10 +997,10 @@ def exponential_map(r): its vector part. Args: - r (float[3]): 3d vector + r (np.array[float[3]]): 3d vector Returns: - float[4]: quaternion + np.array[float[4]]: quaternion """ if np.allclose(r, np.zeros(3)): return quaternion.quaternion(1, 0, 0, 0) @@ -1025,7 +1027,7 @@ def angular_velocity_from_quaternion(q1, q2): q2: second (current) quaternion Returns: - float[3]: angular velocity (angular error in :math:`R^3`) + np.array[float[3]]: angular velocity (angular error in :math:`R^3`) """ q1 = quat_converter.convert_to(q1) q2 = quat_converter.convert_to(q2) @@ -1081,8 +1083,8 @@ def trajectory_tracking_error(p_des, p_curr, q_des, q_curr, gamma=1.): function for more info). Args: - p_des (np.array[3]): desired position - p_curr (np.array[3]): current position + p_des (np.array[float[3]]): desired position + p_curr (np.array[float[3]]): current position q_des: desired orientation (quaternion) q_curr: current orientation (quaternion) @@ -1106,7 +1108,7 @@ def quaternion_derivative(rate, q): quaternion and :math:`*` is the quaternion product operator. Args: - rate (np.array[3]): angular velocity at time t. + rate (np.array[float[3]]): angular velocity at time t. q: unit quaternion at time t. Returns: @@ -1130,7 +1132,7 @@ def quaternion_integrate(rate, q, dt=0): operator. Args: - rate (np.array[3]): angular velocity at time t. + rate (np.array[float[3]]): angular velocity at time t. q: unit quaternion at time t. dt (float): time difference to move forward in the future. @@ -1148,14 +1150,14 @@ def slerp(q0, qf, t, t0=0., tf=1.): Interpolate between two quaternions using Spherical Linear intERPolation (SLERP). Args: - q0 (np.array[4], quaternion.quaternion): initial quaternion. - qf (np.array[4], quaternion.quaternion): final quaternion. - t (float, list of float, np.array): the times to which the quaternions should be interpolated. + q0 (np.array[float[4]], quaternion.quaternion): initial quaternion. + qf (np.array[float[4]], quaternion.quaternion): final quaternion. + t (float, list[float], np.array[float]): the times to which the quaternions should be interpolated. t0 (float): initial time corresponding to the initial quaternion. tf (float): final time corresponding to the final quaternion. Returns: - np.array, quaternion, np.array of quaternion: one or multiple interpolated quaternions + np.array, quaternion, np.array[quaternion]: one or multiple interpolated quaternions References: - [1] "Understanding Quaternions", https://www.3dgep.com/understanding-quaternions @@ -1200,13 +1202,13 @@ def squad(quaternions, times, t): conditions are violated." Args: - quaternions (list of np.array[4], list of quaternion.quaternion): A time-series of rotors (unit quaternions) - to be interpolated - times (np.array, list of float): the times corresponding to the quaternions. - t (np.array, list of float): the times to which the quaternions should be interpolated. + quaternions (list[np.array[float[4]]], list[quaternion.quaternion]): A time-series of rotors (unit + quaternions) to be interpolated + times (np.array[float], list[float]): the times corresponding to the quaternions. + t (np.array[float], list[float]): the times to which the quaternions should be interpolated. Returns: - np.array, np.array of quaternion: interpolated quaternions + np.array, np.array[quaternion]: interpolated quaternions References: - [1] "Understanding Quaternions", https://www.3dgep.com/understanding-quaternions diff --git a/pyrobolearn/worlds/meshes/README.rst b/pyrobolearn/worlds/meshes/README.rst new file mode 100644 index 0000000..c0179b0 --- /dev/null +++ b/pyrobolearn/worlds/meshes/README.rst @@ -0,0 +1,142 @@ +3D objects and Meshes +===================== + +Creating worlds and environments that contains various 3d objects is important for many robotic tasks. However, it can +be quite hard to find these objects. In this ``README`` file, I will go over the basic tools you need, where you can +find 3D models for free, which ones you can redistribute without any legal problems, and which Python libraries you +can use to get useful information from those meshes and how to import/export them in different format. + +Note that in this repository, you already have access to many free and open-source 3D models. You can check them in +the various subfolders in this ``meshes`` folder. + + +Licenses +~~~~~~~~ + +First, let's talk about the legal aspect. + +In order to redistribute 3D models (if you are not the author), you have to make sure that these models are licensed +under: + +- the Creative Commons (CC) License: https://creativecommons.org/licenses/ + - an example is the `CC BY 4.0 `_ license +- the Free Art License: https://artlibre.org/licence/lal/en/ + +Other licenses allow you to use them for personal projects but do not allow you to redistribute them, unless you have +the specific authorization from the authors. This is the case for: + +- the Personal Use License, as it can be found on websites such as Free3D: https://free3d.com/ +- the General Model License, as it can be found on websites such as 3D Warehouse: + https://legacy-3dwarehouse.sketchup.com/tos.html#license + +Note that the Royalty Free License (which can be found here: https://free3d.com/royalty-free-license ) does not allow +you to redistribute downloaded models (see section 7.c). Note that purchased models (more than 0$) can not be +redistributed as well. Anyway, always check the corresponding license. If a 3D model does not have a license, +you have to ask the original author(s) for permission. + +**Note**: the license of each 3D mesh used in PRL is inside the corresponding folder. + + +Tools +~~~~~ + +Now, let's talk about tools that are useful to visualize, edit, manipulate, and convert 3D models. +I personally know two free and open-source tools that can be used on Linux and could interest users: + +- `Meshlab `_: "an open source system for processing and editing 3D triangular meshes. It + provides a set of tools for editing, cleaning, healing, inspecting, rendering, texturing and converting meshes. It + offers features for processing raw data produced by 3D digitization tools/devices and for preparing models for 3D + printing". +- `Blender `_: "a free and open source 3D creation suite. It supports the entirety of the + 3D pipeline—modeling, rigging, animation, simulation, rendering, compositing and motion tracking, even video editing + and game creation". + +There is a certain learning curve to learn how to use these tools (especially Blender) but once you master them they +can become very handy and powerful tools. + +Note that you can also use Blender in Python (>=3.3, not 2.* since Blender 2.5). + +The following formats are supported (and thus can be converted between them): + +- Meshlab: 3ds, ply, stl, obj (with corresponding mtl), off, wrl, dxf, dae, ctm, xyz, gts, json, m, u3d, idtf, x3m +- Blender: 3ds, fbx, bvh, ply, obj, x3d/wrl, stl, svg + +If you need to split or export specific parts of a 3D model, use Blender. In Blender, you can select an object with a +right-click, multiple objects with 'shift + right click', all of them with 'a'. You can delete the selected objects +with 'x'. You can export the selected objects by going to 'File > Export' and then select 'Selection Only' on the +left panel (you should also set 'Path Mode' to 'Copy' to export the textures). If you need to transform the object +(by translating, rotating, or rescaling it), you can bring the transform panel by selecting the object and typing 'n'. +If you need to rescale the entire scene, you can select all the objects by typing 'a', then 's' (for scale), and +directly write the scaling factor, "0.01" for instance. To rotate, type 'r' and to translate type 'g'. +To move the camera, you can use the scroll wheel to zoom, and if you press on it, you can rotate it. If you need to +recenter the object, press 'ctrl + shift + alt + c' and click on 'origin to geometry'. You can press 'ctrl + z' to +undo something. You can also separate objects if necessary, please check the following tutorial on Youtube: +https://www.youtube.com/watch?v=U3J-oYFdyqQ + + +Websites +~~~~~~~~ + +Here are few websites that provide 3D free models. + +- Under a CC or Free Art License + - Sweet Home 3D: http://www.sweethome3d.com/freeModels.jsp + - Blend swap: https://www.blendswap.com/ + - Sketchfab (check the license of the model to be sure): https://sketchfab.com/3d-models?features=downloadable + - Gazebo models: https://bitbucket.org/osrf/gazebo_models/src/default/ and + http://data.nvision2.eecs.yorku.ca/3DGEMS/ + - Bullet models: https://github.com/bulletphysics/bullet3/tree/master/data + +- Under a Personal Use or Royalty Free License + - Free3D: https://free3d.com/3d-models/ + - Sketchfab: https://sketchfab.com/features/download + - CGTrader: https://www.cgtrader.com/free-3d-models + - TurboSquid: https://www.turbosquid.com/Search/3D-Models/free + - GrabCAD: https://grabcad.com/library + - 3D warehouse: https://3dwarehouse.sketchup.com/?hl=en + + +Use 3D models with a Simulator +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +- Bullet: it only accepts to load ``OBJ`` files. You can also load collada (``DAE``) and ``STL`` files through a URDF/SDF. +- MuJoCo: it only accepts to load ``STL`` files. Note that ``STL`` does not contain any texture information (compared + to others like ``OBJ`` and ``DAE``). + + +Create a URDF/SDF file +~~~~~~~~~~~~~~~~~~~~~~ + +Loaded models in the simulator might not have the correct collision shape, mass, inertia, or other physical properties. +You can set them in a `URDF (Unified Robot Description Format) `_, `SDF `_, +or `XML MuJoCo` files. + + +- Tutorials on URDF: + - `URDF Tutorials `_ + - `Create a URDF for an Industrial Robot `_ +- Tutorials on SDF: + - `Make a model (from Gazebo) `_ + - `SDF Tutorials `_ + +In order to set correct inertia values (if you don't have access to CAD models), please have a look at the following +tutorials: + +- `Adding Physical and Collision Properties to a URDF Model `_ +- `Inertial parameters of triangle meshes `_ + +Based on the 2 above tutorials, you will understand how to compute inertia matrices based on the mass and the volume +of the mesh (if uniform density) computed using MeshLab, for instance. + + +Python libraries +~~~~~~~~~~~~~~~~ + +In Python (2.* or 3.*), you can: + +- get useful information from a mesh (such as the center of mass, volume, moment of inertia, and others), using the `trimesh `_ library. +- load and export in different formats, using the `pyassimp `_ library (which is a Python wrapper around the `assimp `_ library). +- In Python 3, you can use the blender python library: `bpy `_. + + +That's all folks! \ No newline at end of file diff --git a/pyrobolearn/worlds/world.py b/pyrobolearn/worlds/world.py index 0dc2982..f27dc19 100644 --- a/pyrobolearn/worlds/world.py +++ b/pyrobolearn/worlds/world.py @@ -67,7 +67,7 @@ class World(object): Args: simulator (Simulator): simulator instance. - gravity (tuple/list of 3 float, np.array[3]): gravity vector. + gravity (tuple/list of 3 float, np.array[float[3]]): gravity vector. """ # set simulator self.simulator = simulator @@ -125,7 +125,7 @@ class World(object): """Set the gravity vector in the world. Args: - gravity (np.array[3]): 3d gravity vector. + gravity (np.array[float[3]]): 3d gravity vector. """ self.simulator.gravity = gravity @@ -585,7 +585,7 @@ class World(object): unique id. Returns: - list of int, list of Body: list of unique ids or bodies + list[int], list[Body]: list of unique ids or bodies """ bodies = self.sim.load_sdf(filename, scaling=scaling) self.ids[tuple(bodies)] = [self.__get_method_and_parameters(frame=inspect.currentframe())] @@ -609,7 +609,7 @@ class World(object): unique id. Returns: - list of int, list of Body: list of bodies + list[int], list[Body]: list of bodies """ bodies = self.sim.load_mjcf(filename, scaling=scaling) self.ids[tuple(bodies)] = [self.__get_method_and_parameters(frame=inspect.currentframe())] @@ -627,12 +627,12 @@ class World(object): """Create a body in the simulator. Args: - position (np.array[3]): Cartesian world position of the base + position (np.array[float[3]]): Cartesian world position of the base visual_shape_id (int): unique id from createVisualShape or -1. You can reuse the visual shape (instancing) collision_shape_id (int): unique id from createCollisionShape or -1. You can re-use the collision shape for multiple multibodies (instancing) mass (float): mass of the base, in kg (if using SI units) - orientation (np.array[4]): Orientation of base as quaternion [x,y,z,w] + orientation (np.array[float[4]]): Orientation of base as quaternion [x,y,z,w] return_body (bool): if True, it will return an instance of the `Body`, otherwise, it will return the unique id. @@ -711,9 +711,9 @@ class World(object): Args: body_id (int): body id to apply the force on link_id (int): link id to apply the force, if -1 it will apply the force on the base - force (np.array[3]): Cartesian forces to be applied on the body - position (np.array[3]): position on the link where the force is applied. If None, it is the center of mass - of the object (or the link if specified) + force (np.array[float[3]]): Cartesian forces to be applied on the body + position (np.array[float[3]]): position on the link where the force is applied. If None, it is the center + of mass of the object (or the link if specified) frame (int): allows to specify the coordinate system of force/position. sim.LINK_FRAME (=1) for local link frame, and sim.WORLD_FRAME (=2) for world frame. By default, it is the world frame. """ @@ -752,7 +752,7 @@ class World(object): body_id (int): body id Returns: - np.array[3]: position of the body (expressed in the world Cartesian frame) + np.array[float[3]]: position of the body (expressed in the world Cartesian frame) """ return self.sim.get_base_pose(body_id)[0] @@ -764,7 +764,7 @@ class World(object): body_id (int): body id Returns: - np.array[4]: orientation of the body (expressed as a quaternion [x,y,z,w]). + np.array[float[4]]: orientation of the body (expressed as a quaternion [x,y,z,w]). """ return self.sim.get_base_pose(body_id)[1] @@ -789,7 +789,7 @@ class World(object): body_id (int): body id Returns: - np.array[3]: linear velocity of the body + np.array[float[3]]: linear velocity of the body """ return self.sim.get_base_velocity(body_id)[0] @@ -801,7 +801,7 @@ class World(object): body_id (int): body id Returns: - np.array[3]: angular velocity of the body + np.array[float[3]]: angular velocity of the body """ return self.sim.get_base_velocity(body_id)[1] @@ -881,8 +881,8 @@ class World(object): link_id (int): optional link id Returns: - np.array[3]: coordinates in world space of the min corner of the AABB - np.array[3]: coordinates in world space of the max corner of the AABB + np.array[float[3]]: coordinates in world space of the min corner of the AABB + np.array[float[3]]: coordinates in world space of the max corner of the AABB """ aabb_min, aabb_max = self.sim.get_aabb(body_id, link_id) return aabb_min, aabb_max @@ -944,15 +944,15 @@ class World(object): int: body unique id of body B int: link index of body A, -1 for base int: link index of body B, -1 for base - np.array[3]: contact position on A, in Cartesian world coordinates - np.array[3]: contact position on B, in Cartesian world coordinates - np.array[3]: contact normal on B, pointing towards A + np.array[float[3]]: contact position on A, in Cartesian world coordinates + np.array[float[3]]: contact position on B, in Cartesian world coordinates + np.array[float[3]]: contact normal on B, pointing towards A float: contact distance, positive for separation, negative for penetration float: normal force applied during the last `step`. Always equal to 0. float: lateral friction force in the first lateral friction direction (see next returned value) - np.array[3]: first lateral friction direction + np.array[float[3]]: first lateral friction direction float: lateral friction force in the second lateral friction direction (see next returned value) - np.array[3]: second lateral friction direction + np.array[float[3]]: second lateral friction direction """ if isinstance(body, Body): body = body.id @@ -988,13 +988,13 @@ class World(object): along the given joint axis with respect to the parent body's link. If the JOINT_POINT2POINT is set (which should really be called spherical), the child body's link will be able to rotate along the 3 axis while maintaining the given position relative to the parent body's link. - joint_axis (np.array[3]): joint axis, in child link frame - parent_frame_position (np.array[3]): position of the joint frame relative to parent CoM frame. - child_frame_position (np.array[3]): position of the joint frame relative to a given child CoM frame (or - world origin if no child specified) - parent_frame_orientation (np.array[4]): the orientation of the joint frame relative to parent CoM + joint_axis (np.array[float[3]]): joint axis, in child link frame + parent_frame_position (np.array[float[3]]): position of the joint frame relative to parent CoM frame. + child_frame_position (np.array[float[3]]): position of the joint frame relative to a given child CoM frame + (or world origin if no child specified) + parent_frame_orientation (np.array[float[4]]): the orientation of the joint frame relative to parent CoM coordinate frame (expressed as a quaternion [x,y,z,w]) - child_frame_orientation (np.array[4]): the orientation of the joint frame relative to the child CoM + child_frame_orientation (np.array[float[4]]): the orientation of the joint frame relative to the child CoM coordinate frame, or world origin frame if no child specified (expressed as a quaternion [x,y,z,w]) Returns: @@ -1039,13 +1039,13 @@ class World(object): body2 (int, Body): body unique id, or a Body instance. link1 (int, None): link id. By default, it will be the base (=-1). link2 (int, None): link id. By default, it will be the base (=-1). - joint_axis (np.array[3]): joint axis, in child link frame - parent_frame_position (np.array[3]): position of the joint frame relative to parent CoM frame. - child_frame_position (np.array[3]): position of the joint frame relative to a given child CoM frame (or - world origin if no child specified) - parent_frame_orientation (np.array[4]): the orientation of the joint frame relative to parent CoM + joint_axis (np.array[float[3]]): joint axis, in child link frame + parent_frame_position (np.array[float[3]]): position of the joint frame relative to parent CoM frame. + child_frame_position (np.array[float[3]]): position of the joint frame relative to a given child CoM frame + (or world origin if no child specified) + parent_frame_orientation (np.array[float[4]]): the orientation of the joint frame relative to parent CoM coordinate frame (expressed as a quaternion [x,y,z,w]) - child_frame_orientation (np.array[4]): the orientation of the joint frame relative to the child CoM + child_frame_orientation (np.array[float[4]]): the orientation of the joint frame relative to the child CoM coordinate frame, or world origin frame if no child specified (expressed as a quaternion [x,y,z,w]) Returns: @@ -2007,7 +2007,7 @@ class World(object): **kwargs: dictionary of arguments to be given to :attr:`body` if this last one is callable. Returns: - list of int, list of Body: list of unique ids for each body, or list of bodies + list[int], list[Body]: list of unique ids for each body, or list of bodies """ # check size if size < 1: @@ -2087,9 +2087,9 @@ class World(object): Returns: float: mass in kg float: lateral friction coefficient - np.array[3]: local inertia diagonal - np.array[3]: position of inertial frame in local coordinates of joint frame - np.array[4]: orientation of inertial frame in local coordinates of joint frame + np.array[float[3]]: local inertia diagonal + np.array[float[3]]: position of inertial frame in local coordinates of joint frame + np.array[float[4]]: orientation of inertial frame in local coordinates of joint frame float: restitution coefficient (if 0, the object does not bounce) float: rolling friction coefficient orthogonal to contact normal float: spinning friction coefficient around contact normal diff --git a/pyrobolearn/worlds/world_camera.py b/pyrobolearn/worlds/world_camera.py index 8c3dd27..a2a5095 100644 --- a/pyrobolearn/worlds/world_camera.py +++ b/pyrobolearn/worlds/world_camera.py @@ -306,18 +306,18 @@ class WorldCamera(object): Returns: int: width of the visualizer camera (in pixel) int: height of the visualizer camera (in pixel) - np.float[4,4]: view matrix [4,4] - np.float[4,4]: perspective projection matrix [4,4] - np.float[3]: camera up vector expressed in the Cartesian world space - np.float[3]: forward axis of the camera expressed in the Cartesian world space - np.float[3]: This is a horizontal vector that can be used to generate rays (for mouse picking or creating - a simple ray tracer for example) - np.float[3]: This is a vertical vector that can be used to generate rays (for mouse picking or creating a - simple ray tracer for example) + np.array[float[4,4]]: view matrix [4,4] + np.array[float[4,4]]: perspective projection matrix [4,4] + np.array[float[3]]: camera up vector expressed in the Cartesian world space + np.array[float[3]]: forward axis of the camera expressed in the Cartesian world space + np.array[float[3]]: This is a horizontal vector that can be used to generate rays (for mouse picking or + creating a simple ray tracer for example) + np.array[float[3]]: This is a vertical vector that can be used to generate rays (for mouse picking or + creating a simple ray tracer for example) float: yaw angle (in radians) of the camera, in Cartesian local space coordinates float: pitch angle (in radians) of the camera, in Cartesian local space coordinates float: distance between the camera and the camera target - np.float[3]: target of the camera, in Cartesian world space coordinates + np.array[float[3]]: target of the camera, in Cartesian world space coordinates """ return self.sim.get_debug_visualizer() @@ -332,8 +332,8 @@ class WorldCamera(object): distance. yaw (float, None): camera yaw angle (in radians) left/right. If None, it will take the current yaw angle. pitch (float, None): camera pitch angle (in radians) up/down. If None, it will take the current pitch angle. - target_position (np.float[3], None): target focus point of the camera. If None, it will take the current - target position. + target_position (np.array[float[3]], None): target focus point of the camera. If None, it will take the + current target position. """ y, p, d, t = self.sim.get_debug_visualizer()[-4:] if distance is None: @@ -355,16 +355,16 @@ class WorldCamera(object): Returns: if inverse: - np.array[4,4]: view matrix - np.array[4,4]: projection matrix - np.array[4,4]: viewport matrix - np.array[4,4]: inverse of the view matrix - np.array[4,4]: inverse of the projection matrix - np.array[4,4]: inverse o the viewport matrix + np.array[float[4,4]]: view matrix + np.array[float[4,4]]: projection matrix + np.array[float[4,4]]: viewport matrix + np.array[float[4,4]]: inverse of the view matrix + np.array[float[4,4]]: inverse of the projection matrix + np.array[float[4,4]]: inverse o the viewport matrix else: - np.array[4,4]: view matrix - np.array[4,4]: projection matrix - np.array[4,4]: viewport matrix + np.array[float[4,4]]: view matrix + np.array[float[4,4]]: projection matrix + np.array[float[4,4]]: viewport matrix """ width, height, V, P = self.sim.get_debug_visualizer()[:4] Vp = np.array([[width / 2., 0, 0, width / 2.], @@ -383,9 +383,9 @@ class WorldCamera(object): Return the forward, up, and lateral vectors of the camera. Returns: - np.float[3]: forward vector - np.float[3]: up vector - np.float[3]: lateral vector (=cross product between forward and up vectors) + np.array[float[3]]: forward vector + np.array[float[3]]: up vector + np.array[float[3]]: lateral vector (=cross product between forward and up vectors) """ up_vector, forward_vector = self.sim.get_debug_visualizer()[4:6] lateral_vector = np.cross(forward_vector, up_vector) @@ -399,7 +399,7 @@ class WorldCamera(object): of turning the camera to capture what we want in the world, we keep the camera fixed and turn the world. Args: - target_position (np.float[3]): target focus point in Cartesian world coordinates + target_position (np.array[float[3]]): target focus point in Cartesian world coordinates distance (float): distance from eye to focus point yaw (float): yaw angle in radians left/right around up-axis pitch (float): pitch in radians up/down. @@ -407,7 +407,7 @@ class WorldCamera(object): up_axis_index (int): either 1 for Y or 2 for Z axis up. Returns: - np.float[4,4]: the view matrix + np.array[float[4,4]]: the view matrix More info: [1] http://www.codinglabs.net/article_world_view_projection_matrix.aspx @@ -424,12 +424,12 @@ class WorldCamera(object): of turning the camera to capture what we want in the world, we keep the camera fixed and turn the world. Args: - eye_position (np.float[3]): eye position in Cartesian world coordinates - target_position (np.float[3]): position of the target (focus) point in Cartesian world coordinates - up_vector (np.float[3]): up vector of the camera in Cartesian world coordinates + eye_position (np.array[float[3]]): eye position in Cartesian world coordinates + target_position (np.array[float[3]]): position of the target (focus) point in Cartesian world coordinates + up_vector (np.array[float[3]]): up vector of the camera in Cartesian world coordinates Returns: - np.float[4,4]: the view matrix + np.array[float[4,4]]: the view matrix More info: [1] http://www.codinglabs.net/article_world_view_projection_matrix.aspx @@ -472,7 +472,7 @@ class WorldCamera(object): Return the captured RGB image. Returns: - np.array[W,H,C]: RGB image (width, height, RGB channels) + np.array[int[W,H,C]]: RGB image (width, height, RGB channels) """ return self.get_rgba_image()[:, :, :3] @@ -481,7 +481,7 @@ class WorldCamera(object): Return the captured RGBA image. 'A' stands for alpha channel (for opacity/transparency) Returns: - np.array[W,H,C]: RGBA image (width, height, RGBA channels) + np.array[int[W,H,C]]: RGBA image (width, height, RGBA channels) """ width, height, view_matrix, projection_matrix = self.sim.get_debug_visualizer()[:4] img = np.array(self.sim.get_camera_image(width, height, view_matrix, projection_matrix)[2]) @@ -493,7 +493,7 @@ class WorldCamera(object): Return the depth image. Returns: - np.array[W,H]: depth image (width, height) + np.array[float[W,H,C]]: depth image (width, height) """ width, height, view_matrix, projection_matrix = self.sim.get_debug_visualizer()[:4] img = np.array(self.sim.get_camera_image(width, height, view_matrix, projection_matrix)[3]) @@ -510,10 +510,10 @@ class WorldCamera(object): Returns: if concatenate: - np.array[W,H,C]: RGBAD image (width, height, RGBAD channels) + np.array[int[W,H,C]]: RGBAD image (width, height, RGBAD channels) else: - np.array[W,H,C]: RGBA image (width, height, RGBA channels) - np.array[W,H]: depth image (width, height) + np.array[int[W,H,C]]: RGBA image (width, height, RGBA channels) + np.array[float[W,H,C]]: depth image (width, height) """ width, height, view_matrix, projection_matrix = self.sim.get_debug_visualizer()[:4] rgba, depth = self.sim.get_camera_image(width, height, view_matrix, projection_matrix)[2:4] @@ -529,13 +529,13 @@ class WorldCamera(object): on the screen. Args: - x_screen (np.float[4]): augmented vector coordinates of a point on the screen - Vp_inv (np.float[4,4], None): inverse of viewport matrix. If None, it will be computed. - P_inv (np.float[4,4], None): inverse of projection matrix. If None, it will be computed. - V_inv (np.float[4,4], None): inverse of view matrix. If None, it will be computed. + x_screen (np.array[float[4]]): augmented vector coordinates of a point on the screen + Vp_inv (np.array[float[4,4]], None): inverse of viewport matrix. If None, it will be computed. + P_inv (np.array[float[4,4]], None): inverse of projection matrix. If None, it will be computed. + V_inv (np.array[float[4,4]], None): inverse of view matrix. If None, it will be computed. Returns: - np.float[4]: augmented vector coordinates of the corresponding point in the world + np.array[float[4]]: augmented vector coordinates of the corresponding point in the world """ if Vp_inv is None: Vp_inv = self.Vp_inv @@ -557,13 +557,13 @@ class WorldCamera(object): Return the corresponding screen coordinates from a 3D point in the world. Args: - x_world (float[4]): augmented vector coordinates of a point in the Cartesian world space - V (np.float[4,4], None): view matrix. If None, it will be computed. - P (np.float[4,4], None): projection matrix. If None, it will be computed. - Vp (np.float[4,4], None): viewport matrix. If None, it will be computed. + x_world (np.array[float[4]]): augmented vector coordinates of a point in the Cartesian world space + V (np.array[float[4,4]], None): view matrix. If None, it will be computed. + P (np.array[float[4,4]], None): projection matrix. If None, it will be computed. + Vp (np.array[float[4,4]], None): viewport matrix. If None, it will be computed. Returns: - np.float[4]: augmented vector coordinates of the corresponding point on the screen + np.array[float[4]]: augmented vector coordinates of the corresponding point on the screen """ if V is None: V = self.V @@ -593,18 +593,18 @@ class WorldCamera(object): int: width of the visualizer camera (in pixel) int: height of the visualizer camera (in pixel) - np.float[4,4]: view matrix [4,4] - np.float[4,4]: perspective projection matrix [4,4] - np.float[3]: camera up vector expressed in the Cartesian world space - np.float[3]: forward axis of the camera expressed in the Cartesian world space - np.float[3]: This is a horizontal vector that can be used to generate rays (for mouse picking or creating - a simple ray tracer for example) - np.float[3]: This is a vertical vector that can be used to generate rays (for mouse picking or creating a - simple ray tracer for example) + np.array[float[4,4]]: view matrix [4,4] + np.array[float[4,4]]: perspective projection matrix [4,4] + np.array[float[3]]: camera up vector expressed in the Cartesian world space + np.array[float[3]]: forward axis of the camera expressed in the Cartesian world space + np.array[float[3]]: This is a horizontal vector that can be used to generate rays (for mouse picking or + creating a simple ray tracer for example) + np.array[float[3]]: This is a vertical vector that can be used to generate rays (for mouse picking or + creating a simple ray tracer for example) float: yaw angle (in radians) of the camera, in Cartesian local space coordinates float: pitch angle (in radians) of the camera, in Cartesian local space coordinates float: distance between the camera and the camera target - np.float[3]: target of the camera, in Cartesian world space coordinates + np.array[float[3]]: target of the camera, in Cartesian world space coordinates """ info = self.info view_inv = np.linalg.inv(info[2]) diff --git a/setup.py b/setup.py index 76d592d..6d2039b 100755 --- a/setup.py +++ b/setup.py @@ -29,7 +29,7 @@ setup( author_email='briandelhaisse@gmail.com', maintainer='Brian Delhaisse', maintainer_email='briandelhaisse@gmail.com', - license='(c) Brian Delhaisse', + license='GNU GPLv3', url='https://github.com/robotlearn/pyrobolearn', platforms=['Linux Ubuntu'], # python_requires='==2.7.*',