Drake
accelerometer.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <memory>
4 #include <string>
5 
16 
17 namespace drake {
18 namespace systems {
19 namespace sensors {
20 
21 // TODO(liang.fok): xdot is coming from LCM and must be wired separately.
22 // Once RigidBodyPlant is able to output `xdot`, update this accelerometer to
23 // use it. See #4105 and #2890.
24 
102 class Accelerometer : public systems::LeafSystem<double> {
103  public:
105 
125  Accelerometer(const std::string& name, const RigidBodyFrame<double>& frame,
126  const RigidBodyTree<double>& tree, bool include_gravity = true);
127 
149  const std::string& name,
150  const RigidBodyFrame<double>& frame,
151  const RigidBodyPlant<double>& plant,
152  bool include_gravity,
153  DiagramBuilder<double>* builder);
154 
156  bool get_include_gravity() const { return include_gravity_; }
157 
159  const RigidBodyTree<double>& get_tree() const { return tree_; }
160 
165  const RigidBodyFrame<double>& get_frame() const { return frame_; }
166 
171  return System<double>::get_input_port(plant_state_input_port_index_);
172  }
173 
178  const {
180  plant_state_derivative_input_port_index_);
181  }
182 
186  return System<double>::get_output_port(output_port_index_);
187  }
188 
189  private:
190  // Computes the "sensed" linear acceleration.
191  void CalcAccelerationOutput(const Context<double>& context,
192  AccelerometerOutput<double>* output_vector) const;
193 
194  const std::string name_;
195  const RigidBodyFrame<double> frame_;
196  const RigidBodyTree<double>& tree_;
197  const bool include_gravity_{true};
198 
199  int plant_state_input_port_index_{};
200  int plant_state_derivative_input_port_index_{};
201  int output_port_index_{};
202 };
203 
204 } // namespace sensors
205 } // namespace systems
206 } // namespace drake
const RigidBodyTree< double > & get_tree() const
Returns the RigidBodyTree that this sensor is sensing.
Definition: accelerometer.h:159
const RigidBodyFrame< double > & get_frame() const
Returns this sensor&#39;s frame, which specifies its location and orientation in the RigidBodyTree.
Definition: accelerometer.h:165
This file contains abbreviated definitions for certain specializations of Eigen::Matrix that are comm...
static Accelerometer * AttachAccelerometer(const std::string &name, const RigidBodyFrame< double > &frame, const RigidBodyPlant< double > &plant, bool include_gravity, DiagramBuilder< double > *builder)
Instantiates and attaches an Accelerometer to a RigidBodyPlant.
Definition: accelerometer.cc:44
Definition: automotive_demo.cc:88
const InputPortDescriptor< double > & get_plant_state_derivative_input_port() const
Returns a descriptor of the input port that should contain the derivative of the generalized position...
Definition: accelerometer.h:177
const InputPortDescriptor< double > & get_plant_state_input_port() const
Returns a descriptor of the input port that should contain the generalized position and velocity vect...
Definition: accelerometer.h:170
const InputPortDescriptor< T > & get_input_port(int port_index) const
Returns the descriptor of the input port at index port_index.
Definition: system.h:815
Accelerometer(const Accelerometer &)=delete
A superclass template that extends System with some convenience utilities that are not applicable to ...
Definition: leaf_system.h:82
A simulated ideal accelerometer that measures the linear acceleration of a frame associated with a Ri...
Definition: accelerometer.h:102
bool get_include_gravity() const
Returns whether gravity is included in this sensor&#39;s measurements.
Definition: accelerometer.h:156
Specializes BasicVector with accessors and setters that are useful for consumers of Accelerometer&#39;s o...
Definition: accelerometer_output.h:19
const OutputPort< T > & get_output_port(int port_index) const
Returns the output port at index port_index.
Definition: system.h:826
#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
const OutputPort< double > & get_output_port() const
Returns the state output port, which contains the sensor&#39;s sensed values.
Definition: accelerometer.h:185
Provides careful macros to selectively enable or disable the special member functions for copy-constr...