Drake
system_test_util.h
Go to the documentation of this file.
1 #pragma once
2 
7 
8 namespace Drake {
9 namespace system_test {
10 
11 template <int StatesAtCompileTime, int InputsAtCompileTime,
12  int OutputsAtCompileTime>
13 std::shared_ptr<AffineSystem<EigenVector<StatesAtCompileTime>::template type,
16 CreateRandomAffineSystem(size_t num_states, size_t num_inputs,
17  size_t num_outputs, bool direct_feedthrough = true) {
18  using ReturnType =
22 
23  auto A =
24  Eigen::Matrix<double, StatesAtCompileTime, StatesAtCompileTime>::Random(
25  num_states, num_states)
26  .eval();
27  auto B =
28  Eigen::Matrix<double, StatesAtCompileTime, InputsAtCompileTime>::Random(
29  num_states, num_inputs)
30  .eval();
31  auto C =
32  Eigen::Matrix<double, OutputsAtCompileTime, StatesAtCompileTime>::Random(
33  num_outputs, num_states)
34  .eval();
35  auto D =
36  direct_feedthrough ?
37  Eigen::Matrix<double, OutputsAtCompileTime, InputsAtCompileTime>::Random(
38  num_outputs, num_inputs)
39  .eval() :
40  Eigen::Matrix<double, OutputsAtCompileTime, InputsAtCompileTime>::Zero(
41  num_outputs, num_inputs)
42  .eval();
43  auto xdot0 =
44  Eigen::Matrix<double, StatesAtCompileTime, 1>::Random(num_states, 1)
45  .eval();
46  auto y0 =
47  Eigen::Matrix<double, OutputsAtCompileTime, 1>::Random(num_outputs, 1)
48  .eval();
49  return std::allocate_shared<ReturnType>(
50  Eigen::aligned_allocator<ReturnType>(), A, B, xdot0, C, D, y0);
51 }
52 
53 } // namespace system_test
54 } // namespace Drake
std::shared_ptr< AffineSystem< EigenVector< StatesAtCompileTime >::template type, EigenVector< InputsAtCompileTime >::template type, EigenVector< OutputsAtCompileTime >::template type > > CreateRandomAffineSystem(size_t num_states, size_t num_inputs, size_t num_outputs, bool direct_feedthrough=true)
Definition: system_test_util.h:16
NOTE: The contents of this class are for the most part direct ports of drake/systems/plants//inverseK...
Definition: Function.h:14
Eigen::Matrix< FunctionalForm, 3, 2 > A
Definition: functional_form_test.cc:619
AffineSystem<StateVector, InputVector, OutputVector>
Definition: LinearSystem.h:21
Eigen::Matrix< double, 3, 2 > C
Definition: functional_form_test.cc:621
Eigen::Matrix< FunctionalForm, 2, 3 > B
Definition: functional_form_test.cc:620
EigenVector<Rows>::type<ScalarType>
Definition: Vector.h:46
SNOPTData & D
Definition: SnoptSolver.cpp:126