codac
codac_VIBesFigMap.h
Go to the documentation of this file.
1 
12 #ifndef __CODAC_VIBESFIGMAP_H__
13 #define __CODAC_VIBESFIGMAP_H__
14 
15 #include <map>
16 #include <vector>
17 
18 #include <codac_Interval.h>
19 #include <codac_VIBesFig.h>
20 #include <codac_TubeVector.h>
21 #include <codac_TrajectoryVector.h>
22 #include <codac_Beacon.h>
23 #include <codac_ColorMap.h>
24 
25 namespace codac
26 {
27  #define TRAJ_MAX_NB_DISPLAYED_POINTS 2000
28  #define TUBE_MAX_NB_DISPLAYED_SLICES 2000
29 
30  // HTML color codes:
31  #define DEFAULT_BEACON_COLOR "#D65A00[#FFB93C]"
32  #define DEFAULT_TRAJMAP_COLOR "#276279"
33  #define DEFAULT_MAPBCKGRND_COLOR "#d2d2d2[#d2d2d2]"
34  #define DEFAULT_OBS_COLOR "gray"
35  #define DEFAULT_VEHICLE_DISPLAY_ON_EACH_TRAJ true
36 
45  class VIBesFigMap : public VIBesFig
46  {
47  public:
48 
51 
57  VIBesFigMap(const std::string& fig_name);
58 
62  ~VIBesFigMap();
63 
70  void restrict_tdomain(const Interval& restricted_tdomain);
71 
78  void enable_tubes_backgrounds(bool enable = true);
79 
83  void show();
84 
90  void show(float robot_size);
91 
97  void set_tube_max_disp_slices(int max);
98 
107  void set_traj_max_disp_points(int max);
108 
117  void smooth_tube_drawing(bool smooth);
118 
122 
131  void add_tube(const TubeVector *tube, const std::string& name, int index_x, int index_y);
132 
139  void set_tube_name(const TubeVector *tube, const std::string& name);
140 
147  void set_tube_color(const TubeVector *tube, const std::string& color);
148 
157  void set_tube_color(const TubeVector *tube, const ColorMap& colormap, const Trajectory *traj_colormap = nullptr);
158 
169  void remove_tube(const TubeVector *tube);
170 
174 
188  void add_trajectory(const TrajectoryVector *traj, const std::string& name, int index_x, int index_y, const std::string& color = DEFAULT_TRAJMAP_COLOR, bool vehicle_display = DEFAULT_VEHICLE_DISPLAY_ON_EACH_TRAJ);
189 
204  void add_trajectory(const TrajectoryVector *traj, const std::string& name, int index_x, int index_y, int index_heading, const std::string& color = DEFAULT_TRAJMAP_COLOR, bool vehicle_display = DEFAULT_VEHICLE_DISPLAY_ON_EACH_TRAJ);
205 
212  void set_trajectory_name(const TrajectoryVector *traj, const std::string& name);
213 
220  void set_trajectory_color(const TrajectoryVector *traj, const std::string& color);
221 
230  void set_trajectory_color(const TrajectoryVector *traj, const ColorMap& colormap, const Trajectory *traj_colormap = nullptr);
231 
238  void set_vehicle_display(const TrajectoryVector *traj, bool vehicle_display);
239 
250  void remove_trajectory(const TrajectoryVector *traj);
251 
255 
262  void draw_vehicle(const Vector& pose, float size = -1);
263 
271  void draw_vehicle(const Vector& pose, const vibes::Params& params, float size = -1);
272 
280  void draw_vehicle(double t, const TrajectoryVector *traj, float size = -1);
281 
290  void draw_vehicle(double t, const TrajectoryVector *traj, const vibes::Params& params, float size = -1);
291 
300  void add_beacon(const Beacon& beacon, const std::string& color = DEFAULT_BEACON_COLOR);
301 
310  void add_beacon(const IntervalVector& beacon, const std::string& color = DEFAULT_BEACON_COLOR);
311 
319  void add_beacon(const Beacon& beacon, double width, const std::string& color = DEFAULT_BEACON_COLOR);
320 
328  void add_beacon(const Vector& beacon, double width, const std::string& color = DEFAULT_BEACON_COLOR);
329 
340  void add_beacons(const std::vector<Beacon>& v_beacons, const std::string& color = DEFAULT_BEACON_COLOR);
341 
351  void add_beacons(const std::vector<Beacon>& v_beacons, double width, const std::string& color = DEFAULT_BEACON_COLOR);
352 
359  void add_landmarks(const std::vector<IntervalVector>& v_m, const std::string& color = DEFAULT_BEACON_COLOR);
360 
368  void add_landmarks(const std::vector<Vector>& v_m, double width, const std::string& color = DEFAULT_BEACON_COLOR);
369 
381  void add_observation(const IntervalVector& obs, const Vector& pose, const std::string& color = DEFAULT_OBS_COLOR);
382 
394  void add_observations(const std::vector<IntervalVector>& v_obs, const Vector& pose, const std::string& color = DEFAULT_OBS_COLOR);
395 
407  void add_observation(const IntervalVector& obs, const TrajectoryVector *traj, const std::string& color = DEFAULT_OBS_COLOR);
408 
420  void add_observations(const std::vector<IntervalVector>& v_obs, const TrajectoryVector *traj, const std::string& color = DEFAULT_OBS_COLOR);
421 
433  double heading(double t, const TrajectoryVector *traj) const;
434 
436 
437  protected:
438 
445  const IntervalVector draw_tube(const TubeVector *tube);
446 
456  const IntervalVector draw_tube_background(const TubeVector *tube);
457 
467  const IntervalVector draw_trajectory(const TrajectoryVector *traj, float points_size = 0.);
468 
474  void draw_slices(const TubeVector *tube);
475 
485  void draw_beacon(const Beacon& beacon, const std::string& color, const vibes::Params& params);
486 
495  void draw_beacon(const Beacon& beacon, double width, const std::string& color, const vibes::Params& params);
496 
509  void draw_observation(const IntervalVector& obs, const Vector& pose, const std::string& color = "", const vibes::Params& params = vibes::Params());
510 
523  void draw_observation(const IntervalVector& obs, const TrajectoryVector *traj, const std::string& color = "", const vibes::Params& params = vibes::Params());
524 
525 
526  protected:
527 
533  {
534  std::string name;
535  std::string color = "";
536  std::pair<ColorMap,const Trajectory*> color_map;
537  const Tube *tube_x_copy = nullptr, *tube_y_copy;
538  bool from_first_to_last = !true;
539  int index_x, index_y;
540  };
541 
547  {
548  std::string name;
549  std::string color = "";
550  std::pair<ColorMap,const Trajectory*> color_map;
551  int index_x, index_y, index_heading = -1;
552  bool vehicle_display = DEFAULT_VEHICLE_DISPLAY_ON_EACH_TRAJ;
553  };
554 
555  std::map<const TubeVector*,FigMapTubeParams> m_map_tubes;
556  std::map<const TrajectoryVector*,FigMapTrajParams> m_map_trajs;
557 
560  bool m_smooth_drawing = false;
561  float m_robot_size = 5.5;
562 
563  unsigned int m_tube_max_nb_disp_slices = TUBE_MAX_NB_DISPLAYED_SLICES;
564  unsigned int m_traj_max_nb_disp_points = TRAJ_MAX_NB_DISPLAYED_POINTS;
565  };
566 }
567 
568 #endif
const Tube * tube_y_copy
to display previous values in background, before any new contraction
Definition: codac_VIBesFigMap.h:537
void set_tube_max_disp_slices(int max)
Limits the number of slices to be displayed for tubes.
FixPoint of a separator The fixpoint of a separator is computed by calling the "::"separate function ...
Definition: codac_capd_helpers.h:9
void set_traj_max_disp_points(int max)
Limits the number of points to be displayed for trajectories.
void set_trajectory_color(const TrajectoryVector *traj, const std::string &color)
Sets constant color properties for a given trajectory.
const std::string name() const
Returns the name of this figure.
void restrict_tdomain(const Interval &restricted_tdomain)
Restricts the display of the dynamical items to a part of their tdomain only.
void smooth_tube_drawing(bool smooth)
Enables the smoothing of tubes.
const Trajectory max(const Trajectory &y, const Trajectory &x)
One dimensional trajectory , defined as a temporal map of values.
Definition: codac_Trajectory.h:34
unsigned int m_traj_max_nb_disp_points
limit for traj points display
Definition: codac_VIBesFigMap.h:564
Specifies some parameters related to a Trajectory display.
Definition: codac_VIBesFigMap.h:546
void add_observations(const std::vector< IntervalVector > &v_obs, const Vector &pose, const std::string &color=DEFAULT_OBS_COLOR)
Adds a set of range-and-bearing uncertain observations to the map, in a static context.
const IntervalVector draw_trajectory(const TrajectoryVector *traj, float points_size=0.)
Draws a trajectory.
void draw_slices(const TubeVector *tube)
Draws the slices of a tube.
n-dimensional trajectory , defined as a temporal map of vector values
Definition: codac_TrajectoryVector.h:37
void add_beacon(const Beacon &beacon, const std::string &color=DEFAULT_BEACON_COLOR)
Adds a Beacon object to the map.
void enable_tubes_backgrounds(bool enable=true)
Enables the display of previous versions of the tubes, in order to highlight the contractions of thes...
int width() const
Returns the width of this figure.
Associates colors to a range of values.
Definition: codac_ColorMap.h:31
n-dimensional tube , defined as an interval of n-dimensional trajectories
Definition: codac_TubeVector.h:38
void set_tube_color(const TubeVector *tube, const std::string &color)
Sets constant color properties for a given tube.
void set_trajectory_name(const TrajectoryVector *traj, const std::string &name)
Sets a new name for a trajectory.
double heading(double t, const TrajectoryVector *traj) const
Returns actual or estimated heading related to some TrajectoryVector at t.
void set_tube_name(const TubeVector *tube, const std::string &name)
Sets a new name for a tube.
One dimensional tube , defined as an interval of scalar trajectories.
Definition: codac_Tube.h:47
void draw_vehicle(const Vector &pose, float size=-1)
Draws a vehicle with a given pose.
void remove_trajectory(const TrajectoryVector *traj)
Removes a trajectory from this figure.
void add_trajectory(const TrajectoryVector *traj, const std::string &name, int index_x, int index_y, const std::string &color=DEFAULT_TRAJMAP_COLOR, bool vehicle_display=DEFAULT_VEHICLE_DISPLAY_ON_EACH_TRAJ)
Adds a trajectory vector object (x,y) to this figure.
void add_tube(const TubeVector *tube, const std::string &name, int index_x, int index_y)
Adds a tube vector object to this figure.
bool from_first_to_last
order of slices display (each one on top of the next/previous one)
Definition: codac_VIBesFigMap.h:538
std::string name
human readable identifier of the tube
Definition: codac_VIBesFigMap.h:548
bool m_smooth_drawing
if true, a smooth rendering of tubes will be done
Definition: codac_VIBesFigMap.h:560
Two-dimensional graphical item based on the VIBes viewer.
Definition: codac_VIBesFig.h:29
bool m_draw_tubes_backgrounds
if true, will highlight tubes contractions
Definition: codac_VIBesFigMap.h:559
void set_vehicle_display(const TrajectoryVector *traj, bool vehicle_display)
Displays a vehicle at the end of a trajectory.
std::string name
human readable identifier of the tube
Definition: codac_VIBesFigMap.h:534
void add_observation(const IntervalVector &obs, const Vector &pose, const std::string &color=DEFAULT_OBS_COLOR)
Adds a range-and-bearing uncertain observation to the map, in a static context.
int index_y
integer references for state components
Definition: codac_VIBesFigMap.h:539
Interval m_restricted_tdomain
restricts the display to a part of the temporal domain
Definition: codac_VIBesFigMap.h:558
void draw_observation(const IntervalVector &obs, const Vector &pose, const std::string &color="", const vibes::Params &params=vibes::Params())
Draws a range-and-bearing uncertain observation on the map in static situation.
~VIBesFigMap()
VIBesFigMap destructor.
VIBesFigMap(const std::string &fig_name)
Creates a VIBesFigMap.
Two-dimensional graphical item to project dynamical items (tubes, trajectories, etc.) on a map.
Definition: codac_VIBesFigMap.h:45
unsigned int m_tube_max_nb_disp_slices
limit for slices display
Definition: codac_VIBesFigMap.h:563
void show()
Displays this figure.
const IntervalVector draw_tube(const TubeVector *tube)
Draws a tube.
void draw_beacon(const Beacon &beacon, const std::string &color, const vibes::Params &params)
Draws a Beacon object.
void add_landmarks(const std::vector< IntervalVector > &v_m, const std::string &color=DEFAULT_BEACON_COLOR)
Adds a set of boxed landmarks to the map.
std::pair< ColorMap, const Trajectory * > color_map
custom colormap of the trajectory
Definition: codac_VIBesFigMap.h:550
Specifies some parameters related to a Tube display.
Definition: codac_VIBesFigMap.h:532
void add_beacons(const std::vector< Beacon > &v_beacons, const std::string &color=DEFAULT_BEACON_COLOR)
Adds a set of Beacon objects to the map.
const IntervalVector draw_tube_background(const TubeVector *tube)
Draws the background of a tube.
float m_robot_size
if 0, no robot display
Definition: codac_VIBesFigMap.h:561
std::map< const TubeVector *, FigMapTubeParams > m_map_tubes
map of Tube objects to be displayed, together with parameters
Definition: codac_VIBesFigMap.h:555
std::map< const TrajectoryVector *, FigMapTrajParams > m_map_trajs
map of Trajectory objects to be displayed, together with parameters
Definition: codac_VIBesFigMap.h:556
std::pair< ColorMap, const Trajectory * > color_map
custom colormap of the tube
Definition: codac_VIBesFigMap.h:536
void remove_tube(const TubeVector *tube)
Removes a tube from this figure.