mirror of
https://github.com/wassname/pyrobolearn.git
synced 2026-10-29 13:30:12 +08:00
clean and update
This commit is contained in:
1 parent
586033304a
commit
2f16ef1105
93 files changed
+2319
-3746
No files matched your search
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
"""
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
+31
-30
@@ -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)
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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]
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
"""
|
||||
|
||||
@@ -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.
|
||||
"""
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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)
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
"""
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
"""
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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])
|
||||
|
||||
@@ -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.
|
||||
|
||||
+390
-386
File diff suppressed because it is too large.
Load diff
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
"""
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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
|
||||
@@ -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):
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
"""
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
"""
|
||||
|
||||
@@ -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.
|
||||
"""
|
||||
|
||||
@@ -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).
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
"""
|
||||
|
||||
@@ -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.
|
||||
|
||||
+285
-279
File diff suppressed because it is too large.
Load diff
+263
-260
File diff suppressed because it is too large.
Load diff
@@ -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"
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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
|
||||
|
||||
+290
-1994
File diff suppressed because it is too large.
Load diff
+318
-258
File diff suppressed because it is too large.
Load diff
@@ -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
|
||||
@@ -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
|
||||
|
||||
@@ -390,7 +390,7 @@ class URDFParser(RobotParser):
|
||||
# <material>
|
||||
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:
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 <https://creativecommons.org/licenses/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 <http://www.meshlab.net/>`_: "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 <https://www.blender.org/>`_: "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) <http://wiki.ros.org/urdf>`_, `SDF <http://sdformat.org/>`_,
|
||||
or `XML MuJoCo` files.
|
||||
|
||||
|
||||
- Tutorials on URDF:
|
||||
- `URDF Tutorials <http://wiki.ros.org/urdf/Tutorials>`_
|
||||
- `Create a URDF for an Industrial Robot <http://wiki.ros.org/Industrial/Tutorials/Create%20a%20URDF%20for%20an%20Industrial%20Robot>`_
|
||||
- Tutorials on SDF:
|
||||
- `Make a model (from Gazebo) <http://gazebosim.org/tutorials?tut=build_model>`_
|
||||
- `SDF Tutorials <http://sdformat.org/tutorials?cat=get_started&>`_
|
||||
|
||||
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 <http://wiki.ros.org/urdf/Tutorials/Adding%20Physical%20and%20Collision%20Properties%20to%20a%20URDF%20Model>`_
|
||||
- `Inertial parameters of triangle meshes <http://gazebosim.org/tutorials?tut=inertia&cat=build_robot>`_
|
||||
|
||||
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 <https://github.com/mikedh/trimesh>`_ library.
|
||||
- load and export in different formats, using the `pyassimp <https://github.com/assimp/assimp/blob/master/port/PyAssimp/README.md>`_ library (which is a Python wrapper around the `assimp <https://github.com/assimp/assimp>`_ library).
|
||||
- In Python 3, you can use the blender python library: `bpy <https://docs.blender.org/api/current/index.html>`_.
|
||||
|
||||
|
||||
That's all folks!
|
||||
+36
-36
@@ -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
|
||||
|
||||
@@ -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])
|
||||
|
||||
@@ -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.*',
|
||||
|
||||
Reference in new issue
Block a user