test_load_urdf
1 Basic Functionality
Importing URDF files
Effects
Import 3 URDF files
Achieve movement and rotation of the first robot
2 Implementation Process
2.1 Initialize the environment and import URDF files
env = RFUniverseBaseEnv()
ur5 = env.LoadURDF(id=639787, path=os.path.abspath('../URDF/UR5/ur5_robot.urdf'), native_ik=True)
ur5.SetTransform(position=[1, 0, 0])
yumi = env.LoadURDF(id=358136, path=os.path.abspath('../URDF/yumi_description/urdf/yumi.urdf'), native_ik=False)
yumi.SetTransform(position=[2, 0, 0])
kinova = env.LoadURDF(id=985135, path=os.path.abspath('../URDF/kinova_gen3/GEN3_URDF_V12.urdf'), native_ik=False)
kinova.SetTransform(position=[3, 0, 0])
Import 3 URDF files in sequence and specify the initial positions of the three rigid bodies
native_ik
is a plugin. When set tofalse
, you cannot use interfaces likeIKTargetDoMove
mentioned in 2.2 and can only manually set the position of each joint (usingSetJointPosition
). Conversely, when set totrue
, you cannot manually set throughSetJointPosition
.
2.2 Setting the action of the first rigid body
ur5.IKTargetDoMove(position=[0, 0.5, 0], duration=0.1, relative=True)
env.step()
ur5.WaitDo()
The meaning of parameters in
IKTargetDoMove
:position
: The target position of the rigid body’s endduration
: The duration from the current position to the target positionrelative
: Whentrue
, it is relative to the current position; whenfalse
, it moves to the absolute position in world coordinates
ur5.IKTargetDoMove(position=[0, 0, -0.5], duration=0.1, relative=True)
env.step()
ur5.WaitDo()
ur5.IKTargetDoMove(position=[0, -0.2, 0.3], duration=0.1, relative=True)
ur5.IKTargetDoRotateQuaternion(quaternion=utility.UnityEularToQuaternion([0, 90, 0]), duration=30, relative=True)
env.step()
ur5.WaitDo()
while 1:
env.step()
Since the first rigid body has
native_ik
set totrue
initially, only the end position needs to be specified, and the ik algorithm inversely calculates the angles of each joint