Skip to content

ROS object reader

deempalme edited this page May 13, 2019 · 1 revision

Description

The section called ROS object reader reads incoming data from a ROS message and translate it into a readable data that you could use directly into Torero libray or your project.

Type Code
Header #include "rocinante/ros_object_reader.h"

List of all public members

Returns Member
ROSObjectReader(const std::string &message_name)
void resubscribe(const std::string &message_name)
const std::vector *const segments()
const std::string& subscribed_message()

ROS object reader

Constructing the class

This function will create the ROS object reader class, you only need to define the ROS message name.

namespace Rocinante {
  ROSObjectReader(const std::string &message_name);
}

  Arguments

Type Name Description
[const std::string&] message_name ROS message name as listed at console using rostopic list command.

Changing the ROS topic (message)

This will change the read message, the new message must be the same type than the previous.

void resubscribe(const std::string &message_name);

  Arguments

Type Name Description
[const std::string&] message_name ROS message name as listed at console using rostopic list command.

Obtaining the address to the data vector

This function will return the address to the vector containing all the read data.

const std::vector<Visualizer::Object> *segments() const;

  Returns
    [const std::vector<Visualizer::Object> *const] | Returns the address of the vector containing the data.


Obtaining the name of the subscribed message

This function will return the name of the ROS message.

const std::string &subscribed_message();

  Returns
    [const std::string&] | Returns the ROS message name.



Data structure

ROS messages' structure

Objects message

This message is the data container for all the objects.

Header header

object[] objects

Object message

This message represents a single object with 3D position, 3D dimensions, 3D speed, orientation in Euler angles, object's path, type of object and object's name

Header header

float32 position_x
float32 position_y
float32 position_z

float32 width
float32 height
float32 length

float32 velocity_x
float32 velocity_y
float32 velocity_z

float32 pitch
float32 yaw
float32 roll

lane[] path

int32 type

string name

Output data structure

Objects

This represents a single object with 3D position, orientation in Euler angles, 3D dimensions, RGBA color, arrow orientation in Euler angles, arrow length, if the arrow is visible, if is a solid object (filled faces), line width and the object's name

struct Object{
  // Object position (LOCATED at the object's center)
  float x = 0.0f;
  float y = 0.0f;
  float z = 0.0f;
  // Object direction (in radians)
  float pitch = 0.0f;
  float yaw   = 0.0f;
  float roll  = 0.0f;
  // Object's size in meters
  float width  = 1.0f;
  float length = 1.0f;
  float height = 1.0f;
  // Object's color (0 to 255)
  float r     = 255.0f;
  float g     = 255.0f;
  float b     = 255.0f;
  float alpha = 255.0f;
  // Arrow's properties:
  // Arrow's direction (in readians)
  float arrow_pitch = 0.0f;
  float arrow_yaw   = 0.0f;
  float arrow_roll  = 0.0f;
  // Arrow's length in meters
  float arrow_length = 1.0f;
  // Displays the arrow
  bool arrow = true;
  // Displays the object as a solid (filled faces)
  bool solid = false;
  // Line width in meters
  float line_width = 0.1f;
  std::string name;
};