> ## Documentation Index
> Fetch the complete documentation index at: https://docs.generalrobotics.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# UR5e

## UR5e

Inherits from: [`Arm`](/robot-api/reference/base/robot/arm/Arm)

A class to control the Universal Robots UR5e robotic arm.

Attributes:
rtde\_c: RTDE Control interface object
rtde\_r: RTDE Receive interface object
rtde\_i: RTDE IO interface object
end\_effector: Gripper/end effector object if attached, should be an INSTANTIATED object
ee\_state (int): Current state of end effector (OPEN/CLOSED)

### Inherited methods

* From [`Arm`](/robot-api/reference/base/robot/arm/Arm): `setNamedPose`, `removeNamedPose`, `getNamedPose`
* From [`Robot`](/robot-api/reference/base/robot/robot/Robot): `addSensor`, `cleanup`

### **init**

```python theme={null}
UR5e.__init__(robot_ip: str = '192.168.1.102', end_effector = None, cameras: Optional[Dict[str, Camera]] = None, enable_control: bool = True)
```

Initialize the UR5e robot arm.

<ResponseField name="Arguments">
  <ParamField query="robot_ip (str)" type="str">
    IP address of the robot. Defaults to "192.168.1.102".
  </ParamField>

  <ParamField query="end_effector (optional)" type="optional">
    End effector instance to use. Defaults to None.
  </ParamField>

  <ParamField query="cameras (Optional[Dict[str, Camera]])" type="Optional[Dict[str, Camera]]">
    Named camera interfaces. Defaults to None.
  </ParamField>

  <ParamField query="enable_control (bool)" type="bool">
    Whether to enable the rtde\_c interface of the robot. For free-drive mode, set to False.
  </ParamField>
</ResponseField>

### getImage

```python theme={null}
UR5e.getImage(camera_name: str, image_type: str = 'rgb') -> Image
```

Get an image from the robot's camera.

Note: Camera names must match those defined during robot configuration.

<ResponseField name="Arguments">
  <ParamField query="camera_name (str)" type="str" required>
    Name of the camera to get an image from.
  </ParamField>

  <ParamField query="image_type (str)" type="str">
    Type of image to retrieve. One of \["rgb", "depth\_meters"]. Defaults to "rgb".
  </ParamField>
</ResponseField>

<ResponseField name="Returns">
  <ResponseField name="Image" type="Image">
    image from the specified camera
  </ResponseField>
</ResponseField>

### moveToDeltaPose

```python theme={null}
UR5e.moveToDeltaPose(delta_position: Position, delta_orientation: Orientation = Orientation(0, 0, 0, 1.0), blocking: bool = True, moving_time: float = 0.5, accel_time: float = 0.2)
```

Move the robot end effector by a relative pose offset from its current pose.

<ResponseField name="Arguments">
  <ParamField query="delta_position (Position)" type="Position" required>
    position offset (relative to the current position) added to current XYZ coordinates (meters)
  </ParamField>

  <ParamField query="delta_orientation (Orientation)" type="Orientation">
    orientation offset (relative to the current orientation) composed with current orientation. Defaults to the identity orientation.
  </ParamField>

  <ParamField query="blocking (bool)" type="bool">
    Wait for movement to complete. Defaults to True.
  </ParamField>

  <ParamField query="moving_time (float)" type="float">
    Time to complete the movement. Defaults to 0.5.
  </ParamField>

  <ParamField query="accel_time (float)" type="float">
    Time to accelerate/decelerate. Defaults to 0.2.
  </ParamField>
</ResponseField>

<ResponseField name="Returns">
  <ResponseField name="bool" type="">
    True if the movement command was successful, False otherwise
  </ResponseField>
</ResponseField>

### getState

```python theme={null}
UR5e.getState() -> dict
```

Get the complete state (mode, joint positions, velocities, end effector force, pose, speed) of the ur5e as a dictionary.

<ResponseField name="Returns">
  <ResponseField name="dict" type="dict">
    Current state of the robot containing: - robot\_mode: int, Current robot mode (eg. 0 = Disconnected, 2 = Booting, 7 = Running, etc.) - joint\_positions: 6-element list, Current joint positions (radians) - joint\_velocities: 6-element list, Current joint velocities (radians/s) - tcp\_force: 6-element list, Generalized forces in the Tool Center Point (N) - tcp\_pose: 6-element list, Current TCP pose \[x, y, z, rx, ry, rz] where rotation is in rotation vector format - tcp\_speed: 6-element list, Actual speed of the tool given in Cartesian coordinates (m/s)
  </ResponseField>
</ResponseField>

### moveToPose

```python theme={null}
UR5e.moveToPose(position: Position, orientation: Orientation, blocking: bool = True, moving_time: float = 2.0, accel_time: float = 0.5, avoid_force: bool = False, stop_acceleration: float = 5, force_threshold: float = 10)
```

Move the robot end effector to a specified pose with respect to the base frame.

The argument `avoid_force` can be used to stop the movement early if the force applied to the end effector exceeds a threshold, useful for soft placement or other movements where a collision is possible/ expected.

<ResponseField name="Arguments">
  <ParamField query="position (Position)" type="Position" required>
    Target pose position (meters)
  </ParamField>

  <ParamField query="orientation (Orientation)" type="Orientation" required>
    Target pose orientation
  </ParamField>

  <ParamField query="blocking (bool)" type="bool">
    Wait for movement to complete. Defaults to True.
  </ParamField>

  <ParamField query="moving_time (float)" type="float">
    Time to complete the movement (seconds). Defaults to 2.0s.
  </ParamField>

  <ParamField query="accel_time (float)" type="float">
    Time to spend accelerating and decelerating (seconds). Defaults to 0.5s.
  </ParamField>

  <ParamField query="avoid_force (bool)" type="bool">
    If True, the robot will stop the movement early if the force applied to the end effector exceeds a threshold. Defaults to False.
  </ParamField>

  <ParamField query="stop_acceleration (float)" type="float">
    Acceleration to use when stopping the movement. Defaults to 1.0.
  </ParamField>

  <ParamField query="force_threshold (float)" type="float">
    Threshold for force to consider the movement successful. Defaults to 10.0.
  </ParamField>
</ResponseField>

<ResponseField name="Returns">
  <ResponseField name="bool" type="">
    True if the movement command was successful, False otherwise
  </ResponseField>
</ResponseField>

<ResponseField name="Raises">
  <ParamField query="ValueError" type="">
    If moving\_time or accel\_time are not positive floats or integers
  </ParamField>
</ResponseField>

### startFreeDrive

```python theme={null}
UR5e.startFreeDrive()
```

Starts free drive mode, in which the robot is compliant and can be moved by hand but supports its own weight.

### endFreeDrive

```python theme={null}
UR5e.endFreeDrive()
```

Ends free drive mode, allowing the robot to be controlled by moveToPose() or moveToDeltaPose()

(but no longer movable by hand)

### moveToNamedPose

```python theme={null}
UR5e.moveToNamedPose(pose_name: str, blocking: bool = True, moving_time: float = 2.0, accel_time: float = 0.75)
```

Move the robot to the joint angles of a named pose.

<ResponseField name="Arguments">
  <ParamField query="pose_name (str)" type="str" required>
    Name of the pose to move to. Options are "home", "sleep", and "upright".
  </ParamField>

  <ParamField query="blocking (bool)" type="bool">
    Wait for movement to complete. Defaults to True.
  </ParamField>

  <ParamField query="moving_time (float)" type="float">
    Time to complete the movement. Defaults to 2.0.
  </ParamField>

  <ParamField query="accel_time (float)" type="float">
    Time to accelerate/decelerate. Defaults to 0.75.
  </ParamField>
</ResponseField>

<ResponseField name="Returns">
  <ResponseField name="bool" type="">
    True if the movement command was successful, False otherwise
  </ResponseField>
</ResponseField>

### moveByVelocity

```python theme={null}
UR5e.moveByVelocity(linear_velocity: Velocity, angular_velocity: Velocity, frame: str = 'body')
```

Move the robot end effector with specified velocities.

<ResponseField name="Arguments">
  <ParamField query="linear_velocity (Velocity)" type="Velocity" required>
    Linear velocity components
  </ParamField>

  <ParamField query="angular_velocity (Velocity)" type="Velocity" required>
    Angular velocity components
  </ParamField>

  <ParamField query="frame (str)" type="str">
    *No description provided.*
  </ParamField>
</ResponseField>

### stop

```python theme={null}
UR5e.stop(immediate = False)
```

Stop any movement of the robot (soft emergency-stop).

<ResponseField name="Arguments">
  <ParamField query="immediate (bool, optional)" type="bool, optional">
    If True, stops immediately by killing script. If False, performs controlled stop and doesn't kill the script. Defaults to False.
  </ParamField>
</ResponseField>

### suction\_grasp

```python theme={null}
UR5e.suction_grasp(approach_direction: np.ndarray = None, compliant_force: bool = False, force: float = 20, approach_distance: float = 0.1, approach_time: float = 2, *args, **kwargs)
```

Performs last step of suction grip, approaches the object and returns to the original position

Uses force readings to minimize excessive force on the robot

<ResponseField name="Arguments">
  <ParamField query="approach_direction (np.ndarray)" type="np.ndarray">
    *No description provided.*
  </ParamField>

  <ParamField query="compliant_force (bool)" type="bool">
    *No description provided.*
  </ParamField>

  <ParamField query="force (float)" type="float">
    *No description provided.*
  </ParamField>

  <ParamField query="approach_distance (float)" type="float">
    *No description provided.*
  </ParamField>

  <ParamField query="approach_time (float)" type="float">
    *No description provided.*
  </ParamField>

  <ParamField query="args" type="">
    *No description provided.*
  </ParamField>

  <ParamField query="kwargs" type="">
    *No description provided.*
  </ParamField>
</ResponseField>

### grasp

```python theme={null}
UR5e.grasp(*args, **kwargs)
```

Close the gripper to grasp an object.

Only works if an end effector is configured. Changes ee\_state to CLOSED.

<ResponseField name="Arguments">
  <ParamField query="args" type="">
    *No description provided.*
  </ParamField>

  <ParamField query="kwargs" type="">
    *No description provided.*
  </ParamField>
</ResponseField>

### validate\_grasp

```python theme={null}
UR5e.validate_grasp()
```

Validate that the grasp is successful.

<ResponseField name="Returns">
  <ResponseField name="bool" type="">
    True if the grasp is successful, False otherwise
  </ResponseField>

  <ResponseField name="None" type="">
    If the end effector does not support validation
  </ResponseField>
</ResponseField>

### release

```python theme={null}
UR5e.release()
```

Open the gripper to release an object.

Only works if an end effector is configured. Changes ee\_state to OPEN.

### shutdown

```python theme={null}
UR5e.shutdown()
```

Shutdown the robot safely.

Stops the robot and disconnects RTDE interfaces.

### getEndEffectorPose

```python theme={null}
UR5e.getEndEffectorPose() -> Pose
```

Get the current end effector pose with respect to the base frame.

<ResponseField name="Returns">
  <ResponseField name="Pose" type="Pose">
    Current end effector position and orientation
  </ResponseField>
</ResponseField>

### getPosition

```python theme={null}
UR5e.getPosition() -> Position
```

Get the current end effector position with respect to the robot base (meters)

<ResponseField name="Returns">
  <ResponseField name="Position" type="Position">
    Current end effector position with respect to the robot base
  </ResponseField>
</ResponseField>

### getOrientation

```python theme={null}
UR5e.getOrientation(name: str = '') -> Orientation
```

Get the current end effector orientation with respect to the robot base

<ResponseField name="Arguments">
  <ParamField query="name (str)" type="str">
    *No description provided.*
  </ParamField>
</ResponseField>

<ResponseField name="Returns">
  <ResponseField name="Orientation" type="Orientation">
    Current end effector orientation with respect to the robot base
  </ResponseField>

  <ResponseField name="name" type="str, optional">
    Unused
  </ResponseField>
</ResponseField>

### getJointAngles

```python theme={null}
UR5e.getJointAngles() -> list
```

Get a list of the 6 current joint angles in radians

<ResponseField name="Returns">
  <ResponseField name="list" type="list">
    List of current joint angles in radians
  </ResponseField>
</ResponseField>

### getJointVelocities

```python theme={null}
UR5e.getJointVelocities() -> list
```

Get a list of the 6 current joint velocities in radians/second

<ResponseField name="Returns">
  <ResponseField name="list" type="list">
    List of current joint velocities in radians/second
  </ResponseField>
</ResponseField>

### setJointAngles

```python theme={null}
UR5e.setJointAngles(angles: list, blocking: bool = True, moving_time: float = 2.0, accel_time: float = 0.5)
```

Set joint angles directly.

<ResponseField name="Arguments">
  <ParamField query="angles (list)" type="list" required>
    List of 6 target joint angles in radians
  </ParamField>

  <ParamField query="blocking (bool)" type="bool">
    Wait for movement to complete. Defaults to True.
  </ParamField>

  <ParamField query="moving_time (float)" type="float">
    Time to complete the movement. Defaults to 2.0.
  </ParamField>

  <ParamField query="accel_time (float)" type="float">
    Time to accelerate/decelerate. Defaults to 0.5.
  </ParamField>
</ResponseField>

<ResponseField name="Returns">
  <ResponseField name="bool" type="">
    True if the movement command was successful, False otherwise
  </ResponseField>
</ResponseField>

<ResponseField name="Raises">
  <ParamField query="ValueError" type="">
    If moving\_time or accel\_time are not positive floats or integers
  </ParamField>
</ResponseField>

### moveToHome

```python theme={null}
UR5e.moveToHome(moving_time: float = 2.0, accel_time: float = 0.75)
```

Move the robot to a predefined home position.

<ResponseField name="Arguments">
  <ParamField query="moving_time (float)" type="float">
    *No description provided.*
  </ParamField>

  <ParamField query="accel_time (float)" type="float">
    *No description provided.*
  </ParamField>
</ResponseField>

### servoJointAngles

```python theme={null}
UR5e.servoJointAngles(angles: list, time: float, lookahead_time: float = 0.03, gain: float = 300.0)
```

Command the setpoint and gain of the low-level joint position controller (linear in joint-space).

This function expects to be called in a 500Hz loop with joint positions that are close to each other.
Example use cases: real-time control using classical or Reinforcement-Learning controllers.

<ResponseField name="Arguments">
  <ParamField query="angles (list)" type="list" required>
    List of target joint angles in radians
  </ParamField>

  <ParamField query="time (float)" type="float" required>
    (seconds) Duration for which the command controls the robot. This is blocking.
  </ParamField>

  <ParamField query="lookahead_time (float)" type="float">
    (seconds) Range \[0.03,0.2]. The current position is projected forward in time with the current velocity, and used to smooth the trajectory. A low value gives fast reaction, a high value prevents overshoot.
  </ParamField>

  <ParamField query="gain (float)" type="float">
    (range \[100,2000]) Proportional gain of the PID controller that tracks target joint position Higher gains will cause the robot to move faster, but could cause jerkiness or oscillations.
  </ParamField>
</ResponseField>

<ResponseField name="Returns">
  <ResponseField name="bool" type="">
    True if the movement command was successful, False otherwise
  </ResponseField>
</ResponseField>

<ResponseField name="Raises">
  <ParamField query="ValueError" type="">
    If time is not a positive float or int
  </ParamField>
</ResponseField>

### initPeriod

```python theme={null}
UR5e.initPeriod()
```

Initialize the control loop period to 0.002 seconds (500Hz).

<ResponseField name="Returns">
  <ResponseField name="Optional[float]" type="">
    Current time (indicating the start of the current loop iteration), or None if the robot is not in control mode
  </ResponseField>
</ResponseField>

### waitPeriod

```python theme={null}
UR5e.waitPeriod(t_start: float)
```

Wait for the rest of the 0.002 second (500Hz) control period using a combination of sleep and spin.

Used together with initPeriod and servoJointAngles (see ServoJointAngles documentation for example).

<ResponseField name="Arguments">
  <ParamField query="t_start (float)" type="float" required>
    (float) Time at which the current loop iteration started, from initPeriod()
  </ParamField>
</ResponseField>
