Drake
rotary_encoders.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <memory>
4 #include <vector>
5 
9 
10 namespace drake {
11 namespace systems {
12 namespace sensors {
13 
22 template <typename T>
23 class RotaryEncoders final : public VectorSystem<T> {
24  public:
26 
27 
28  explicit RotaryEncoders(const std::vector<int>& ticks_per_revolution);
30 
36  RotaryEncoders(int input_port_size,
37  const std::vector<int>& input_vector_indices);
38 
40  RotaryEncoders(int input_port_size,
41  const std::vector<int>& input_vector_indices,
42  const std::vector<int>& ticks_per_revolution);
43 
45  template <typename U>
46  explicit RotaryEncoders(const RotaryEncoders<U>&);
47 
49  std::unique_ptr<Parameters<T>> AllocateParameters() const override;
50 
53  Context<T>* context,
54  const Eigen::Ref<VectorX<T>>& calibration_offsets) const;
55 
57  Eigen::VectorBlock<const VectorX<T>> get_calibration_offsets(
58  const Context<T>& context) const;
59 
60  private:
61  // Allow different specializations to access each other's private data.
62  template <typename> friend class RotaryEncoders;
63 
64  // Outputs the transformed signal.
65  void DoCalcVectorOutput(
66  const Context<T>& context,
67  const Eigen::VectorBlock<const VectorX<T>>& input,
68  const Eigen::VectorBlock<const VectorX<T>>& state,
69  Eigen::VectorBlock<VectorX<T>>* output) const override;
70 
71  void SetDefaultParameters(const LeafContext<T>& context,
72  Parameters<T>* params) const override;
73 
74  const int num_encoders_{0}; // Dimension of the output port.
75  const std::vector<int> indices_; // Selects from the input port.
76  const std::vector<int> ticks_per_revolution_; // For quantization.
77 };
78 
79 } // namespace sensors
80 } // namespace systems
81 } // namespace drake
This file contains abbreviated definitions for certain specializations of Eigen::Matrix that are comm...
A base class that specializes LeafSystem for use with only zero or one vector input ports...
Definition: vector_system.h:30
Definition: automotive_demo.cc:88
Context is an abstract base class template that represents all the inputs to a System: time...
Definition: query_handle.h:10
Eigen::Matrix< Scalar, Eigen::Dynamic, 1 > VectorX
A column vector of any size, templated on scalar type.
Definition: eigen_types.h:46
friend class RotaryEncoders
Definition: rotary_encoders.h:62
LeafContext is a container for all of the data necessary to uniquely determine the computations perfo...
Definition: leaf_context.h:31
std::unique_ptr< Parameters< T > > AllocateParameters() const override
Calibration offsets are defined as parameters.
Definition: rotary_encoders.cc:101
void set_calibration_offsets(Context< T > *context, const Eigen::Ref< VectorX< T >> &calibration_offsets) const
Set the calibration offset parameters.
Definition: rotary_encoders.cc:115
Parameters is a container for variables that parameterize a System so that it can represent a family ...
Definition: parameters.h:26
Simple model to capture the quantization and calibration offset effects of a rotary encoder...
Definition: rotary_encoders.h:23
#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
Eigen::VectorBlock< const VectorX< T > > get_calibration_offsets(const Context< T > &context) const
Retreive the calibration offset parameters.
Definition: rotary_encoders.cc:126
Provides careful macros to selectively enable or disable the special member functions for copy-constr...