Object that describes the URDF Robot.
import { HemisphereLight, MathUtils } from 'three';
import URDFLoader from 'urdf-loader';
// scene, camera and renderer are initialized here
const URL = 'https://raw.githubusercontent.com/gkjohnson/urdf-loaders/master/urdf/T12/urdf/T12_flipped.URDF';
scene.add( new HemisphereLight( 0xffffff, 0x444444, 3 ) );
camera.position.set( 6, 5, 8 );
const robot = await new URDFLoader().loadAsync( URL );
robot.rotation.x = Math.PI / 2;
robot.position.y = 1.1;
// a pose as joint name to value pairs, as it might arrive from telemetry: every hip, knee
// and ankle pitch joint in "robot.joints" gets its angle
const angles = { HP: 30, KP: 120, AP: - 60 };
const pose = {};
for ( const name in robot.joints ) {
const angle = angles[ name.slice( 0, 2 ) ];
if ( angle !== undefined ) pose[ name ] = MathUtils.degToRad( angle );
}
robot.setJointValues( pose );
scene.add( robot );On this page
Properties
robotName: string
The name of the robot described in the <robot> tag.
A dictionary of linkName : URDFLink with all links in the robot.
A dictionary of jointName : URDFJoint with all joints in the robot.
A dictionary of colliderName : Object3D with all collision nodes in the robot.
A dictionary of visualName : Object3D with all visual nodes in the robot.
A dictionary of all the named frames in the robot including links, joints, colliders, and visual.
Methods
setJointValue(
// The name of the joint to set
name: string,
// The value(s) to set
...angle: number
): booleanSets the joint value of the joint with the given name. Returns true if the joint changed.
setJointValues(
// A dictionary of joint names to values
jointValueDictionary: Object
): booleanSets the joint values for all the joints in the dictionary indexed by joint name. Returns true if a joint changed.