# URDFRobot

class in `urdf-loader`, extends `URDFLink`

```js
import { URDFRobot } from 'urdf-loader';
```

Object that describes the URDF Robot.

Example: Applying a pose by joint name

```js
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 );
```

## Properties

### .robotName: string

The name of the robot described in the `<robot>` tag.

### .links: Object<string, URDFLink>

A dictionary of `linkName : URDFLink` with all links in the robot.

### .joints: Object<string, URDFJoint>

A dictionary of `jointName : URDFJoint` with all joints in the robot.

### .colliders: Object<string, Object3D>

A dictionary of `colliderName : Object3D` with all collision nodes in the robot.

### .visual: Object<string, Object3D>

A dictionary of `visualName : Object3D` with all visual nodes in the robot.

### .frames: Object<string, Object3D>

A dictionary of all the named frames in the robot including links, joints, colliders, and visual.

## Methods

### .setJointValue

```js
.setJointValue( name: string, ...angle: number ): boolean
```

Sets the joint value of the joint with the given name. Returns true if the joint changed.

- `name`, `string`: The name of the joint to set
- `angle`, `number`: The value(s) to set

Returns `boolean`: Returns true if the joint changed.

### .setJointValues

```js
.setJointValues( jointValueDictionary: Object ): boolean
```

Sets the joint values for all the joints in the dictionary indexed by joint name. Returns true if a joint changed.

- `jointValueDictionary`, `Object`: A dictionary of joint names to values

Returns `boolean`: Returns true if a joint changed.
