Drake
car_vis_applicator.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <map>
4 #include <memory>
5 
8 #include "drake/lcmt_viewer_load_robot.hpp"
12 
13 namespace drake {
14 namespace automotive {
15 
41 template <typename T>
43  public:
45 
47  ~CarVisApplicator() override {}
48 
52 
56 
63  void AddCarVis(std::unique_ptr<CarVis<T>> vis);
64 
67  lcmt_viewer_load_robot get_load_robot_message() const;
68 
70  int num_cars() const { return static_cast<int>(visualizers_.size()); }
71 
73  int num_vis_poses() const;
74 
75  private:
76  systems::rendering::PoseBundle<T> MakePoseBundleOutput() const;
77 
78  void CalcPoseBundleOutput(const systems::Context<T>& context,
79  systems::rendering::PoseBundle<T>* output) const;
80 
81  // The key is the car ID.
82  std::map<int, std::unique_ptr<const CarVis<T>>> visualizers_;
83 
84  // The key is the car ID and the value is the starting index within the output
85  // PoseBundle.
86  mutable std::map<int, int> starting_indices_;
87 
88  int input_port_index_{};
89  int output_port_index_{};
90  bool context_allocated_{false};
91 };
92 
93 } // namespace automotive
94 } // namespace drake
int num_vis_poses() const
Returns the total number of poses of bodies being visualized.
Definition: car_vis_applicator.cc:146
CarVisApplicator takes as input a PoseVector containing vehicle poses.
Definition: car_vis_applicator.h:42
Definition: automotive_demo.cc:88
CarVisApplicator()
Definition: car_vis_applicator.cc:27
const systems::OutputPort< T > & get_visual_geometry_poses_output_port() const
Returns the output port that contains the visual geometry poses of all vehicle visualizations.
Definition: car_vis_applicator.cc:45
Context is an abstract base class template that represents all the inputs to a System: time...
Definition: query_handle.h:10
lcmt_viewer_load_robot get_load_robot_message() const
Returns an lcmt_viewer_load_robot message containing the geometries of the bodies being visualized...
Definition: car_vis_applicator.cc:60
PoseBundle is a container for a set of poses, represented by an Isometry3, and corresponding velociti...
Definition: pose_bundle.h:40
const systems::InputPortDescriptor< T > & get_car_poses_input_port() const
Returns a descriptor of the input port that contains the vehicle poses in the form of a PoseBundle...
Definition: car_vis_applicator.cc:39
int num_cars() const
Returns the number vehicles being visualized.
Definition: car_vis_applicator.h:70
void AddCarVis(std::unique_ptr< CarVis< T >> vis)
Adds a CarVis object for a vehicle.
Definition: car_vis_applicator.cc:50
InputPortDescriptor is a notation for specifying the kind of input a System accepts, on a given port.
Definition: input_port_descriptor.h:19
An OutputPort belongs to a System and represents the properties of one of that System&#39;s output ports...
Definition: output_port.h:67
A superclass template that extends System with some convenience utilities that are not applicable to ...
Definition: leaf_system.h:43
CarVis is a base class that provides visualization geometries and their poses.
Definition: car_vis.h:21
~CarVisApplicator() override
Definition: car_vis_applicator.h:47
#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:35
Provides careful macros to selectively enable or disable the special member functions for copy-constr...