Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Visualization messages can be sent to the LCC to draw basic shapes and text in the map view, where the vehicles are shown as well. An example use case for this would be to draw the desired path that a vehicle is supposed to take on command, to check if it actually follows this path. The messages can also be used to show additional information to the running program or simply to debug the sent trajectory by checking the created path visually.

Data structure

The visualization IDL file looks like this:

#include "Color.idl"
#include "Point2D.idl"

#ifndef VISUALIZATION_IDL
#define VISUALIZATION_IDL

enum VisualizationType 
{
    LineStrips=0,
    Polygon,
    StringMessage
};

struct Visualization 
{
    //Id to be able to delete the viz later on
    unsigned long long id; //@key

    VisualizationType type;
    unsigned long long time_to_live;

    sequence<Point2D> points;
    double size; //Line width in pixels or text size in pt
    string string_message;

    Color color;
};
#endif

Each visualization message thus consists of seven data fields which need to be filled accordingly to draw the desired information in the LCC: ID, visualization type, time_to_live, points, size, string_message  and color.

ID

Each visualization command is identified by a unique ID. Choose different IDs for commands that should be displayed at the same time, or use the same ID to override an older visualization message.

The highest ID is always drawn last, so, if you want to draw symbols on top of each other, always make sure that you use the right order of IDs.

Visualization Type

Currently, three command types are supported: You can draw a line, a polygon or a string.

...

For strings, you need to specifiy a single point where the string is drawn, and you should set the string message that should be displayed.

Time to Live

Each visualization command is removed automatically after a given time. Here, you can set the time to live in nanoseconds.

Points

This field defines the set of points between which lines should be drawn, or the point where the string message should be shown. The coordinate system is the same as the one used for the vehicles.

Points is a custom IDL data type . (see below)which is a structPoint2D{ doublex; doubley}. Points are set according to the coordinate system.

Size

Here you can define the line width or the size of the string message.

String Message

Just set a string for this field (as RTI uses its own string format, be aware that setting this value with a std::string data type might lead to an error message, but give it a try before you use RTI's own implementation).

Color

Lines, polygons and strings can be given any color within the RGB spectrum.

Color is a custom IDL data type . (see below)

Further data structures

struct Point2D {
    double x;    
    double y;    
};

Points are just set according to the coordinate system explained elsewhere.

struct Color 
{
    octet a;
    octet r;
    octet g;
    octet b;
};

which is a struct Color{octeta; octetr; octetg; octetb}. Color values are just regular RGB values. The transparency value should be ignored.

Usage example

Warning: The usage of the function cpm::init also allows the user to set command line parameters. To seperate different LCC test domains, e.g. when different students want to use the LCC at the same time in the same network, it is possible to set parameters such as --dds_domain. Another important parameter, --dds_initial_peer, can also be set for the LCC. These two parameters must also be set accordingly for your own programs, such as your own visualization implementations. So, if you set these parameters for the LCC yourself or call the LCC using a script that sets these parameters, always use them for any other program that is based on the cpm library for communication as well. (Or set the domain ID etc yourself if you do not wish to use the cpm library, which is not recommended)

This example can also be found in the Lab's Git.

...

C++

cd ~/dev/software/LabControlCenter/test/VizualizationTest.cpp