Drake
car_vis.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <string>
4 #include <vector>
5 
6 #include "drake/lcmt_viewer_link_data.hpp"
8 
9 namespace drake {
10 namespace automotive {
11 
12 /// CarVis is a base class that provides visualization geometries and their
13 /// poses.
14 ///
15 /// Instantiated templates for the following kinds of T's are provided:
16 /// - double
17 ///
18 /// They are already available to link against in the containing library.
19 ///
20 template <typename T>
21 class CarVis {
22  public:
24 
25  /// The constructor.
26  ///
27  /// @param id The ID of the vehicle being visualized. This must be unique per
28  /// vehicle in the same simulation.
29  ///
30  /// @param name The name of the vehicle being visualized. This can be any
31  /// user-defined value.
32  ///
33  CarVis(int id, const std::string& name) : id_(id), name_(name) {}
34 
35  virtual ~CarVis() {}
36 
37  /// Returns the visualization elements.
38  virtual const std::vector<lcmt_viewer_link_data>& GetVisElements() const = 0;
39 
40  /// Computes and returns the poses of the bodies that constitute the vehicle's
41  /// visualization. The provided `X_WM` is the pose of the vehicle model in the
42  /// world frame. The origin of the model's frame is assumed to be in the
43  /// middle of the vehicle's rear axle. The poses in the returned PoseBundle
44  /// are for the visualization's elements, and are also in the world frame. The
45  /// size of this bundle is the value returned by num_poses().
47  const Isometry3<T>& X_WM) const = 0;
48 
49  /// Returns the ID that was supplied to the constructor.
50  int id() const { return id_; }
51 
52  /// Returns the name that was supplied to the constructor.
53  const std::string& name() const { return name_; }
54 
55  /// Returns the number of visualization geometry poses.
56  int num_poses() const;
57 
58  private:
59  const int id_;
60  const std::string name_;
61 };
62 
63 } // namespace automotive
64 } // namespace drake
Eigen::Transform< Scalar, 3, Eigen::Isometry > Isometry3
An Isometry templated on scalar type.
Definition: eigen_types.h:106
virtual systems::rendering::PoseBundle< T > CalcPoses(const Isometry3< T > &X_WM) const =0
Computes and returns the poses of the bodies that constitute the vehicle&#39;s visualization.
Definition: automotive_demo.cc:88
STL namespace.
PoseBundle is a container for a set of poses, represented by an Isometry3, and corresponding velociti...
Definition: pose_bundle.h:40
int id() const
Returns the ID that was supplied to the constructor.
Definition: car_vis.h:50
int num_poses() const
Returns the number of visualization geometry poses.
Definition: car_vis.cc:7
CarVis is a base class that provides visualization geometries and their poses.
Definition: car_vis.h:21
const std::string & name() const
Returns the name that was supplied to the constructor.
Definition: car_vis.h:53
virtual const std::vector< lcmt_viewer_link_data > & GetVisElements() const =0
Returns the visualization elements.
virtual ~CarVis()
Definition: car_vis.h:35
#define DRAKE_NO_COPY_NO_MOVE_NO_ASSIGN(Classname)
DRAKE_NO_COPY_NO_MOVE_NO_ASSIGN deletes the special member functions for copy-construction, copy-assignment, move-construction, and move-assignment.
Definition: drake_copyable.h:33