robots.poses package

robots.poses.position module

class robots.poses.position.FrameProvider[source]

Bases: object


Returns the transformation between this frame and the map.

If the frame is unknown, raises UnknownFrameError.

exception robots.poses.position.InvalidFrameError[source]

Bases: exceptions.RuntimeError

class robots.poses.position.PoseManager(robot)[source]

Bases: object

A pose is for us a dict {'x':x, 'y':y, 'z':z, 'qx':qx, 'qy':qy, 'qz':qz, 'qw':qw, 'frame':frame}, ie a (x, y, z) cartesian pose in meter interpreted in a specific reference frame, and a quaternion describing the orientation of the object in radians.

This class helps with:

  • converting from other convention to our convention,
  • converting back to other conventions.
angular_distance(angle1, angle2)[source]

Returns the (minimal, oriented) angular distance between two angles after normalization on the unit circle.

Angles are assumed to be radians.

The result is oriented (from angle1 to angle2) and guaranteed to be in range ]-pi, pi].

distance(pose1, pose2='base_link')[source]

Returns the euclidian distance between two pyRobots poses.

If the second pose is omitted, “base_link” is assumed (ie, distance between a pose and the robot itself).


takes a loosly defined ‘pose’ as input and returns a properly formatted and normalized pose.

Input may be:
  • a frame
  • an incomplete pose dictionary
  • a list or tuple (x,y,z), (x,y,z,frame) or (z,y,z,rx,ry,rz) or (x,y,z,qx,qy,qz,qw)
inframe(pose, frame)[source]

Transform a pose from one frame to another one.

Uses transformation matrices. Could be refactored to use directly quaternions.

static isin(point, polygon)[source]

Determines if a 2D point is inside a given 2D polygon or not.

  • point – a (x,y) pair
  • polygon – a list of (x,y) pairs.

Copied from:


Returns the current robot’s pose, ie the pose of the ROS TF ‘base_link’ frame.

static normalize_angle(angle)[source]

Returns equivalent angle such as -pi < angle <= pi

static normalizedict(pose)[source]
pantilt(pose, ref='/base_link')[source]

Convert a xyz target to pan and tilt angles from a given viewpoint.

  • pose – the target pose
  • ref – the reference frame (default to base_link)

(pan, tilt) in radians, in ]-pi, pi]

static quaternion_from_euler(rx, ry, rz)[source]

Small regression test for the computation of angular distances

exception robots.poses.position.UnknownFrameError[source]

Bases: exceptions.RuntimeError

robots.poses.ros_positions module

class robots.poses.ros_positions.ROSFrames[source]

Bases: robots.poses.position.FrameProvider


Returns a ROS PoseStamped from a pyRobots pose.

Parameters:pose – a standard pyRobots pose (SPARK id, TF frame, [x,y,z], [x,y,z,rx,ry,rz], [x,y,z,qx,qy,qw,qz], {‘x’:..., ‘y’:...,...})
Returns:the corresponding ROS PoseStamped
inframe(pose, frame)[source]

Transforms a given pose in the given frame.

publish_transform(name, pose)[source]

Publishes a new TF frame called ‘name’ based on the pyRobots transform ‘pose’.

Note that this function does not normalize the input pose, which must already be a dictionary with the keys [x,y,z,qx,qy,qz,qw,frame].