Skip to content

utils

CircularArray

Bases: object

Simple implementation of a circular array. You can append to it any number of times but only "size" items will be kept

Timer

Simple helper class to compute the rate at which something is called.

"smoothing" determines the size of the underlying circular array, which averages out variations in call rate over time.

use timer.tick() to record an event use timer.fps() to report the average event rate.

angle_to_quaternion(angle)

Convert an angle in radians into a quaternion message.

map_to_world(poses, map_info)

Takes a two dimensional numpy array of poses

[[x0,y0,theta0], [x1,y1,theta1], [x2,y2,theta2], ... ]

And converts them from map coordinate space (pixels) to world coordinate space (meters). - Conversion is done in place, so this function does not return anything. - Provide the MapMetaData object from a map message to specify the change in coordinates. - This implements the same computation as map_to_world_slow but vectorized and inlined

map_to_world_slow(x, y, t, map_info)

Converts given (x,y,t) coordinates from the coordinate space of the map (pixels) into world coordinates (meters). Provide the MapMetaData object from a map message to specify the change in coordinates. *** Logical, but slow implementation, when you need a lot of coordinate conversions, use the map_to_world function

particle_to_pose(particle)

Converts a particle in the form [x, y, theta] into a Pose object

particles_to_poses(particles)

Converts a two dimensional array of particles into an array of Poses. Particles can be a array like [[x0, y0, theta0], [x1, y1, theta1]...]

quaternion_to_angle(q)

Convert a quaternion message into an angle in radians. The angle represents the yaw. This is not just the z component of the quaternion.

rotation_matrix(theta)

Creates a rotation matrix for the given angle in radians

world_to_map(poses, map_info)

Takes a two dimensional numpy array of poses

[[x0,y0,theta0], [x1,y1,theta1], [x2,y2,theta2], ... ]

And converts them from world coordinate space (meters) to world coordinate space (pixels). - Conversion is done in place, so this function does not return anything. - Provide the MapMetaData object from a map message to specify the change in coordinates. - This implements the same computation as world_to_map_slow but vectorized and inlined - You may have to transpose the returned x and y coordinates to directly index a pixel array

world_to_map_slow(x, y, t, map_info)

Converts given (x,y,t) coordinates from the coordinate space of the world (meters) into map coordinates (pixels). Provide the MapMetaData object from a map message to specify the change in coordinates. *** Logical, but slow implementation, when you need a lot of coordinate conversions, use the world_to_map function