14 template <
class UnitSystem>
18 template <
typename ScalarType>
22 template <
typename ScalarType>
26 template <
typename ScalarType>
36 void AddSystem(std::shared_ptr<UnitSystem> system) {
37 systems_.push_back(system);
41 template <
typename ScalarType>
42 StateVector<ScalarType>
dynamics(
const ScalarType& time,
43 const StateVector<ScalarType>& state,
44 const InputVector<ScalarType>& input)
const {
45 if ((state.
count() >= 0) && (state.
count() != systems_size())) {
46 throw std::invalid_argument(
"State count differs from systems count.");
48 if ((input.
count() >= 0) && (input.
count() != systems_size())) {
49 throw std::invalid_argument(
"Input count differs from systems count.");
51 StateVector<ScalarType> xdot(systems_size());
52 for (
int i = 0; i < systems_size(); ++i) {
59 template <
typename ScalarType>
60 OutputVector<ScalarType>
output(
const ScalarType& time,
61 const StateVector<ScalarType>& state,
62 const InputVector<ScalarType>& input)
const {
63 if ((state.
count() >= 0) && (state.
count() != systems_size())) {
64 throw std::invalid_argument(
"State count differs from systems count.");
66 if ((input.
count() >= 0) && (input.
count() != systems_size())) {
67 throw std::invalid_argument(
"Input count differs from systems count.");
69 OutputVector<ScalarType> y(systems_size());
70 for (
int i = 0; i < systems_size(); ++i) {
78 for (
auto s : systems_) {
79 if (s->isTimeVarying()) {
return true; }
86 for (
auto s : systems_) {
87 if (s->isDirectFeedthrough()) {
return true; }
108 int systems_size()
const {
return systems_.size(); }
110 std::vector<std::shared_ptr<UnitSystem> > systems_;
NArySystem()
Definition: n_ary_system.h:30
UnitVector get(int pos) const
Definition: n_ary_state.h:77
std::size_t getNumInputs() const
Definition: n_ary_system.h:98
std::size_t getNumOutputs() const
Definition: n_ary_system.h:103
static int RowsFromUnitCount(int count)
Determines how many Eigen matrix rows will be needed to represent.
Definition: n_ary_state.h:157
Definition: constants.h:3
NAryState is a Drake::Vector (concept implementation) which is a container of zero or more component ...
Definition: n_ary_state.h:26
A System which aggregates multiple instances of a UnitSystem system.
Definition: n_ary_system.h:15
StateVector< ScalarType > dynamics(const ScalarType &time, const StateVector< ScalarType > &state, const InputVector< ScalarType > &input) const
Definition: n_ary_system.h:42
void set(int pos, const UnitVector &unit)
Sets the value of the component UnitVector at position pos.
Definition: n_ary_state.h:92
int count() const
Definition: n_ary_state.h:54
OutputVector< ScalarType > output(const ScalarType &time, const StateVector< ScalarType > &state, const InputVector< ScalarType > &input) const
Definition: n_ary_system.h:60
bool isDirectFeedthrough() const
Definition: n_ary_system.h:85
bool isTimeVarying() const
Definition: n_ary_system.h:77
void AddSystem(std::shared_ptr< UnitSystem > system)
Adds.
Definition: n_ary_system.h:36
std::size_t getNumStates() const
Definition: n_ary_system.h:93