Drake
traffic_light.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <memory>
4 
5 #include <Eigen/Geometry>
6 
7 #include "drake/common/drake_copyable.h"
8 #include "drake/common/eigen_types.h"
9 #include "drake/systems/framework/leaf_system.h"
10 
11 namespace drake {
12 namespace automotive {
13 
14 /// This class is a first-pass model of a traffic light. It outputs
15 /// a vector containing its position, a radius, and whether it is open or
16 /// closed.
17 ///
18 /// It is time-triggered, and signals "green" for half of its period and "red"
19 /// for the other half.
20 ///
21 /// At this time, the only supported value of T is double.
22 // TODO(nikos-tri): Support AutoDiffXd and Symbolic.
23 
24 template <typename T>
25 class TrafficLight : public systems::LeafSystem<T> {
26  public:
28 
29  /// Positions and radius are in meters, period is in seconds.
30  TrafficLight(T x_position, T y_position, T radius, T period);
31 
32  /// No input port, because this system is time-triggered.
33  const systems::OutputPort<T>& output() const;
34 
35  private:
36  void DoCalcOutput(const systems::Context<T>& context,
37  systems::BasicVector<T>* output) const;
38 
39  // Indices for input / output ports.
40  const int traffic_input_index_{};
41  const int output_index_{};
42  int parameters_index_{};
43 
44  const VectorX<T> ReadParameters(const systems::Context<T>& context) const;
45  void WriteOutput(const VectorX<T> value,
46  systems::BasicVector<T>* output) const;
47 };
48 
49 } // namespace automotive
50 } // namespace drake
Definition: automotive_demo.cc:89
Context is an abstract base class template that represents all the inputs to a System: time...
Definition: query_handle.h:10
TrafficLight(const TrafficLight &)=delete
Eigen::Matrix< Scalar, Eigen::Dynamic, 1 > VectorX
A column vector of any size, templated on scalar type.
Definition: eigen_types.h:46
const systems::OutputPort< T > & output() const
No input port, because this system is time-triggered.
Definition: traffic_light.cc:25
An OutputPort belongs to a System and represents the properties of one of that System&#39;s output ports...
Definition: output_port.h:67
This class is a first-pass model of a traffic light.
Definition: traffic_light.h:25
int value
Definition: copyable_unique_ptr_test.cc:61
A superclass template that extends System with some convenience utilities that are not applicable to ...
Definition: leaf_system.h:82
BasicVector is a semantics-free wrapper around an Eigen vector that satisfies VectorBase.
Definition: basic_vector.h:25
#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