Drake
continuous_system.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <cstdint>
4 #include <stdexcept>
5 #include <string>
6 
10 
11 namespace drake {
12 namespace systems {
13 
16 template <typename T>
18  public:
23  const Context<T>& context, const StateVector<T>& generalized_velocity,
24  StateVector<T>* configuration_derivatives) const override {
25  if (generalized_velocity.size() != configuration_derivatives->size()) {
26  throw std::out_of_range(
27  "generalized_velocity.size() " +
28  std::to_string(generalized_velocity.size()) +
29  " != configuration_derivatives.size() " +
30  std::to_string(configuration_derivatives->size()) +
31  ". Do you need to override the default implementation of " +
32  "MapVelocityToConfigurationDerivatives?");
33  }
34 
35  for (int i = 0; i < generalized_velocity.size(); ++i) {
36  configuration_derivatives->SetAtIndex(i,
37  generalized_velocity.GetAtIndex(i));
38  }
39  }
40 
41  protected:
43 
44  private:
45  // ContinuousSystem objects are neither copyable nor moveable.
46  ContinuousSystem(const ContinuousSystem<T>& other) = delete;
47  ContinuousSystem& operator=(const ContinuousSystem<T>& other) = delete;
48  ContinuousSystem(ContinuousSystem<T>&& other) = delete;
49  ContinuousSystem& operator=(ContinuousSystem<T>&& other) = delete;
50 };
51 
52 } // namespace systems
53 } // namespace drake
void MapVelocityToConfigurationDerivatives(const Context< T > &context, const StateVector< T > &generalized_velocity, StateVector< T > *configuration_derivatives) const override
Applies the identity mapping.
Definition: continuous_system.h:22
virtual int size() const =0
Returns the number of elements in the vector.
Definition: constants.h:3
StateVector is an abstract base class template for vector quantities within the state of a System...
Definition: state_vector.h:20
The Context is a container for all of the data necessary to uniquely determine the computations perfo...
Definition: context.h:38
virtual void SetAtIndex(int index, const T &value)=0
Replaces the state at the given index with the value.
virtual const T GetAtIndex(int index) const =0
Returns the element at the given index in the vector.
A template interface for Systems that have continuous dynamics.
Definition: continuous_system_interface.h:15
std::string to_string(const Eigen::MatrixBase< Derived > &a)
Definition: testUtil.h:29
ContinuousSystem()
Definition: continuous_system.h:42
An abstract base class template for Systems that have continuous dynamics.
Definition: continuous_system.h:17