Warning
This page is located in archive. Go to the latest version of this course pages. Go the latest version of this page.

Data Types

Data types used in the tasks are defined in the library redcp, which contains support wrappers for data structures commonly used in robotics. The individual data types allow for standardizing the interfaces between the functional parts of the robot software architecture. The implementation of the library is inspired by the ROS middleware used in robotics to manage the software architecture of the robots. While the ROS messages are only data wrappers, our implementation features several simplifications, and some classes include additional code to simplify work with them.

The data types used in the course tasks are inherited from the Message class and are as follows.

  1. Header
  2. Vector3
  3. Quaternion
  4. Pose
  5. Odometry
  6. Twist
  7. Path
  8. LaserScan
  9. OccupancyGrid
  10. NavGraph

The structure of the individual classes and the description of their methods follows.


The general message header contains information common for most data (message) types.

Attributes

  • timestamp - float - Creation timestamp of the message.
  • frame_id - string - String identification of the coordinate reference frame in which the data are represented (default to base_frame).

Vector3

Representation of 3D vectors with $x$, $y$, $z$ component.

Attributes

  • x - float - $x$ coordinate.
  • y - float - $y$ coordinate.
  • z - float - $z$ coordinate.

Quaternion

Representation of 3D orientation using unit quaternion. There are multiple ways to represent the rotations in robotics, with the rotation matrices and quaternions being superior to Euler angles with their commonly used variant Tait–Bryan angles. The Euler angles represent the robot orientation in 3D using rotations around the principal axes of the robot. In particular, the original Euler angles are prescribed by one of the following orders of rotation ($zxz$, $xyx$, $yzy$, $zyz$, $xzx$, $yxy$) with the more common representation using the Tait–Bryan angles variant prescribed by one of the following orders of rotation ($xyz$, $yzx$, $zxy$, $xzy$, $zyx$, $yxz$) commonly referred to as yaw (rotation around $z$ axis), pitch (rotation around $y$ axis), and roll (rotation around $x$ axis) of the robot, similar to the following figure (courtesy of novatel.com).

There are two principal problems in using Euler (Tait–Bryan) angles. First is the missing standardization of rotation order, which leaves us with twelve possible sequences of rotations. Second, the Gimball-lock effect, which is a loss of Degree of Freedom that occurs when two axes are driven into a parallel configuration by the sequence of the rotations. Hence, representation of the orientation using quaternions and rotation matrices is considered a better option.

Attributes

  • x - float - $x$ component.
  • y - float - $y$ component.
  • z - float - $z$ component.
  • w - float - $w$ component.

Methods

  • to_R() - Method to convert quaternion into the rotation matrix.
  • from_R(R) - Method to convert rotation matrix R into the quaternion representation.
  • to_Euler() - Method to convert quaternion into Euler angles (yaw, pitch, roll) - $xyz$ order.
  • from_Euler(yaw, pitch, roll) - Method to convert Euler ($xyz$ order) angles yaw,pitch,roll into the quaternion.

Pose

Class representing robot pose in free space in the form of $x$, $y$, $z$ position vector, and orientation quaternion.

Attributes

  • position - Vector3 - Position component.
  • orientation - Quaternion - Orientation component.

Methods

  • dist(other) - Method to calculate the euclidean distance between self and the other Pose.
  • plot(ax) - Method to 2D plot the pose into the matplotlib.pyplot axes ax.

Path

Class representing the robot path in free space as a list of poses.

Attributes

  • poses - Pose[] - List of robot poses.

Methods

  • plot(ax, skipstep=0) - 2D plot of the path with an optional skipstep.

Odometry

Class representing robot odometry as a timestamped pose in the given reference frame.

Attributes

  • header - Header - Timestamp and reference frame id of the Odometry message.
  • pose - Pose - Pose of the robot.

Twist

Class representing velocity in free space broken into linear and angular components.

Attributes

  • linear - Vector3 - $(v_x, v_y, v_z)$ components of the linear speed.
  • angular - Vector3 - $(\omega_x, \omega_y, \omega_z)$ components of the angular speed.

LaserScan

Class for representing a single line scan from a planar laser scanner.

Attributes

  • header - Header - Timestamp and reference frame id of the Odometry message.
  • angle_min - float - Start angle of the scan [rad].
  • angle_max - float - End angle of the scan [rad].
  • angle_increment - float - The angular distance between measurements [rad]
  • range_min - float - Minimum measurable distance [m].
  • range_max - float - Maximum measurable distance [m].
  • distances - float[] - Distance data [m] (note: distance data out of the sensor's range should be discarded).

Methods

  • plot(ax) - Method to 2D plot the LaserScan into the matplotlib.pyplot axes ax.

OccupancyGrid

Class representing occupancy grid map.

Attributes

  • header - Header - Timestamp and reference frame id of the Odometry message.
  • resolution - float - The map resolution [m/cell].
  • width - float - Width of the map [cells].
  • height - float - Height of the map [cells].
  • origin - Pose - The map's origin [m, m, rad]. It is the real-world pose of the cell (0,0) in the map.
  • data - float[] - The map data in row-major order.

Methods

  • plot(ax) - Method to plot the grid map into the matplotlib.pyplot axes ax.
  • clone() - Method to create a deep copy of the grid.
  • pose_to_xy(pose) - Method to convert given pose to coords as tuple (x,y).
  • xy_to_idx(x, y) - Method to convert the given x, y coords to the index of the array representing the grid.
  • xy_to_pose(x, y) - Method to convert the given x, y coords to pose.
  • world_to_map(positions) - Method to convert positions to map coords.
  • map_to_world(positions) - Method to convert map coords to poses.
  • coords_to_pose(coords) - Method to convert given coords to pose.
  • pose_to_coords(pose) - Method to convert given pose to coords.

Class representing the navigation graph $\mathcal{G}=(V, E)$, where $V$ is a set of vertices and $E$ is a set of edges.

Attributes

  • poses - Pose[] - List of graph vertices $V$.
  • edges - list( (i,j) ) - List of index tuples representing the graph edges $E$.

Methods

  • plot(ax) - Method to plot the grid map into the matplotlib.pyplot axes ax.

courses/crl-courses/redcp/tasks/data_types.txt · Last modified: 2022/11/25 07:11 by faiglj