Drake
Drake Namespace Reference

NOTE: The contents of this class are for the most part direct ports of drake/systems/plants//inverseKinBackend.m from Matlab to C++; many methods and variables follow Matlab conventions and are documented in that file. More...

Namespaces

 internal
 
 RigidBodyConstraints
 
 system_test
 
 systems
 

Classes

class  AdditiveGaussianNoiseModel
 GaussianNoiseModel. More...
 
class  AffineSystem
 AffineSystem<StateVector, InputVector, OutputVector> More...
 
class  BotVisualizer
 BotVisualizer<RobotStateVector> More...
 
class  CascadeSystem
 CascadeSystem<System1,System2> More...
 
class  CombinedVector
 operator<<() More...
 
struct  CombinedVectorUtil
 CombinedVectorUtil. More...
 
struct  CombinedVectorUtil< Vector1, Vector2, typename std::enable_if< Vector1< double >::RowsAtCompileTime==0 >::type >
 
struct  EigenVector
 EigenVector<Rows>::type<ScalarType> More...
 
class  FeedbackSystem
 FeedbackSystem<System1,System2> More...
 
struct  FunctionTraits
 FunctionTraits. More...
 
struct  FunctionTraits< std::reference_wrapper< F > >
 
struct  FunctionTraits< std::shared_ptr< F > >
 
struct  FunctionTraits< std::unique_ptr< F > >
 
class  Gain
 
struct  InputOutputRelation
 InputOutputRelation. More...
 
struct  is_combined_vector
 whether or not the given type is a CombinedVector More...
 
struct  is_combined_vector< CombinedVector< Scalar, Vector1, Vector2 > >
 
struct  is_eigen_vector
 whether or not the given type is an Eigen column vector More...
 
struct  is_eigen_vector< Eigen::Matrix< Scalar, Rows, 1, Options, MaxRows, 1 > >
 
class  LinearSystem
 
class  NoiseModel
 NoiseModel. More...
 
class  PDControlSystem
 PDControlSystem<System> More...
 
class  RigidBodyAccelerometer
 RigidBodyAccelerometer. More...
 
class  RigidBodyDepthSensor
 RigidBodyDepthSensor. More...
 
class  RigidBodyForceElement
 RigidBodyForceElement. More...
 
class  RigidBodyGyroscope
 RigidBodyGyroscope. More...
 
class  RigidBodyMagnetometer
 RigidBodyMagnetometer. More...
 
class  RigidBodyPropellor
 RigidBodyPropellor. More...
 
class  RigidBodySensor
 An abstract parent class of all sensors. More...
 
class  RigidBodySpringDamper
 RigidBodySpringDamper. More...
 
class  RigidBodySystem
 Implements the System concept by wrapping the RigidBodyTree algorithms with additional sensors and actuators/forces. More...
 
struct  SimulationOptions
 

Typedefs

template<typename ScalarType >
using VecIn = Eigen::Ref< Eigen::Matrix< ScalarType, Eigen::Dynamic, 1 > const >
 
template<typename ScalarType >
using VecOut = Eigen::Matrix< ScalarType, Eigen::Dynamic, 1 >
 
template<int num_vars>
using TaylorVard = Eigen::AutoDiffScalar< Eigen::Matrix< double, num_vars, 1 > >
 
template<int num_vars, int rows>
using TaylorVecd = Eigen::Matrix< TaylorVard< num_vars >, rows, 1 >
 
template<int num_vars, int rows, int cols>
using TaylorMatd = Eigen::Matrix< TaylorVard< num_vars >, rows, cols >
 
typedef TaylorVard< Eigen::Dynamic > TaylorVarXd
 
typedef TaylorVecd< Eigen::Dynamic, Eigen::Dynamic > TaylorVecXd
 
typedef TaylorMatd< Eigen::Dynamic, Eigen::Dynamic, Eigen::Dynamic > TaylorMatXd
 
template<typename Derived , int Nq>
using AutoDiffMatrixType = Eigen::Matrix< Eigen::AutoDiffScalar< Eigen::Matrix< typename Derived::Scalar, Nq, 1 > >, Derived::RowsAtCompileTime, Derived::ColsAtCompileTime, 0, Derived::MaxRowsAtCompileTime, Derived::MaxColsAtCompileTime >
 The appropriate AutoDiffScalar gradient type given the value type and the number of derivatives at compile time. More...
 
typedef Eigen::Matrix< double, 1, 1 > Vector1d
 
template<typename ScalarType >
using NullVector = Eigen::Matrix< ScalarType, 0, 1 >
 NullVector<ScalarType> More...
 
typedef std::chrono::system_clock TimeClock
 
typedef std::chrono::duration< doubleTimeDuration
 
typedef std::chrono::time_point< TimeClock, TimeDurationTimePoint
 

Functions

template<typename Derived , typename DerivedGradient , typename DerivedAutoDiff >
void initializeAutoDiffGivenGradientMatrix (const Eigen::MatrixBase< Derived > &val, const Eigen::MatrixBase< DerivedGradient > &gradient, Eigen::MatrixBase< DerivedAutoDiff > &auto_diff_matrix)
 Initializes an autodiff matrix given a matrix of values and gradient matrix. More...
 
template<typename Derived , typename DerivedGradient >
AutoDiffMatrixType< Derived, DerivedGradient::ColsAtCompileTime > initializeAutoDiffGivenGradientMatrix (const Eigen::MatrixBase< Derived > &val, const Eigen::MatrixBase< DerivedGradient > &gradient)
 Creates and initializes an autodiff matrix given a matrix of values and gradient matrix. More...
 
template<typename Derived , typename DerivedAutoDiff >
void initializeAutoDiff (const Eigen::MatrixBase< Derived > &val, Eigen::MatrixBase< DerivedAutoDiff > &auto_diff_matrix, Eigen::DenseIndex num_derivatives=Eigen::Dynamic, Eigen::DenseIndex deriv_num_start=0)
 Initialize a single autodiff matrix given the corresponding value matrix. More...
 
template<int Nq = Eigen::Dynamic, typename Derived >
AutoDiffMatrixType< Derived, Nq > initializeAutoDiff (const Eigen::MatrixBase< Derived > &mat, Eigen::DenseIndex num_derivatives=-1, Eigen::DenseIndex deriv_num_start=0)
 Initialize a single autodiff matrix given the corresponding value matrix. More...
 
template<typename... Args>
constexpr int totalSizeAtCompileTime ()
 Determine the total size at compile time of a number of arguments based on their SizeAtCompileTime static members. More...
 
constexpr Eigen::DenseIndex totalSizeAtRunTime ()
 Determine the total size at runtime of a number of arguments using their size() methods (base case). More...
 
template<typename Head , typename... Tail>
Eigen::DenseIndex totalSizeAtRunTime (const Eigen::MatrixBase< Head > &head, const Tail &...tail)
 Determine the total size at runtime of a number of arguments using their size() methods (recursive) More...
 
template<typename... Deriveds>
std::tuple< AutoDiffMatrixType< Deriveds, totalSizeAtCompileTime< Deriveds... >)>... > initializeAutoDiffTuple (const Eigen::MatrixBase< Deriveds > &...args)
 Given a series of Eigen matrices, create a tuple of corresponding AutoDiff matrices with values equal to the input matrices and properly initialized derivative vectors. More...
 
template<typename ScalarType , int Rows>
const Eigen::Matrix< ScalarType, Rows, 1 > & toEigen (const Eigen::Matrix< ScalarType, Rows, 1 > &vec)
 
template<template< typename > class VecType>
VecType< doublegetRandomVector (void)
 getRandomVector() More...
 
template<typename VecType >
std::size_t size (const VecType &vec)
 size() More...
 
template<typename Vector >
std::string getCoordinateName (const Vector &vec, unsigned int index)
 getCoordinateName() More...
 
template<typename System1 , typename System2 >
std::shared_ptr< CascadeSystem< System1, System2 > > cascade (const std::shared_ptr< System1 > &sys1, const std::shared_ptr< System2 > &sys2)
 cascade(sys1, sys2) More...
 
template<typename System >
std::shared_ptr< AffineSystem< NullVector, System::template StateVector, System::template InputVector > > timeInvariantLQR (const System &sys, const typename System::template StateVector< double > &x0, const typename System::template InputVector< double > &u0, const Eigen::MatrixXd &Q, const Eigen::MatrixXd &R)
 
template<typename System1 , typename System2 >
std::shared_ptr< FeedbackSystem< System1, System2 > > feedback (const std::shared_ptr< System1 > &sys1, const std::shared_ptr< System2 > &sys2)
 feedback(sys1, sys2) More...
 
template<class Vector >
bool encode (const double &t, const Vector &x, drake::lcmt_drake_signal &msg)
 
template<class Vector >
bool decode (const drake::lcmt_drake_signal &msg, double &t, Vector &x)
 
template<typename System >
void runLCM (std::shared_ptr< System > sys, std::shared_ptr< lcm::LCM > lcm, double t0, double tf, const typename System::template StateVector< double > &x0, const SimulationOptions &options=default_simulation_options)
 runLCM More...
 
template<typename System >
void runLCM (const System &sys, std::shared_ptr< lcm::LCM > lcm, double t0, double tf)
 
DRAKERBSYSTEM_EXPORT RigidBodySystem::StateVector< doublegetInitialState (const RigidBodySystem &sys)
 
void parseForceElement (RigidBodySystem &sys, XMLElement *node)
 
void parseRobot (RigidBodySystem &sys, XMLElement *node)
 
void parseURDF (RigidBodySystem &sys, XMLDocument *xml_doc)
 
void parseSDFJoint (RigidBodySystem &sys, int model_id, XMLElement *node, PoseMap &pose_map)
 
void parseSDFLink (RigidBodySystem &sys, int model_id, XMLElement *node, PoseMap &pose_map)
 
void parseSDFModel (RigidBodySystem &sys, int model_id, XMLElement *node)
 
void parseSDF (RigidBodySystem &sys, XMLDocument *xml_doc)
 
Eigen::VectorXd spatialForceInFrameToJointTorque (const RigidBodyTree *tree, const KinematicsCache< double > &rigid_body_state, const RigidBodyFrame *frame, const Eigen::Matrix< double, 6, 1 > &force)
 spatialForceInFrameToJointTorque More...
 
bool handle_realtime_factor (const TimePoint &wall_clock_start_time, double sim_time, double realtime_factor, double timeout_seconds)
 
template<typename System >
double simulate (const System &sys, double ti, double tf, const typename System::template StateVector< double > &xi, const SimulationOptions &options)
 simulate More...
 
template<typename System >
void simulate (const System &sys, double t0, double tf, const typename System::template StateVector< double > &x0)
 simulate More...
 
template<typename System >
void simulate (const System &sys, double t0, double tf)
 simulate More...
 
template<typename System >
std::size_t getNumStates (const System &sys)
 getNumStates() More...
 
template<typename System >
std::size_t getNumInputs (const System &sys)
 getNumInputs() More...
 
template<typename System >
std::size_t getNumOutputs (const System &sys)
 getNumOutputs() More...
 
template<typename System >
System::template StateVector< doublegetInitialState (const System &sys)
 getInitialState() More...
 
template<typename Scalar , typename System >
System::template StateVector< Scalar > createStateVector (const System &sys)
 Create a new, uninitialized state vector for the system. More...
 
template<typename Derived >
void resizeDerivativesToMatchScalar (Eigen::MatrixBase< Derived > &mat, const typename Derived::Scalar &scalar)
 Resize derivatives vector of each element of a matrix to to match the size of the derivatives vector of a given scalar. More...
 
template<typename... Args, typename ReturnType >
auto make_function (ReturnType(*p)(Args...)) -> std::function< ReturnType(Args...)>
 make_function Note that a completely general make_function implementation is not possible due to ambiguities, but this works for all of the cases in this file Inspired by http://stackoverflow.com/a/21740143/2228557 More...
 
template<typename... Args, typename ReturnType , typename ClassType >
auto make_function (ReturnType(ClassType::*p)(Args...)) -> std::function< ReturnType(ClassType &, Args...)>
 

Variables

static const SimulationOptions default_simulation_options
 

Detailed Description

NOTE: The contents of this class are for the most part direct ports of drake/systems/plants//inverseKinBackend.m from Matlab to C++; many methods and variables follow Matlab conventions and are documented in that file.

Typedef Documentation

using AutoDiffMatrixType = Eigen::Matrix< Eigen::AutoDiffScalar<Eigen::Matrix<typename Derived::Scalar, Nq, 1> >, Derived::RowsAtCompileTime, Derived::ColsAtCompileTime, 0, Derived::MaxRowsAtCompileTime, Derived::MaxColsAtCompileTime>

The appropriate AutoDiffScalar gradient type given the value type and the number of derivatives at compile time.

using TaylorMatd = Eigen::Matrix<TaylorVard<num_vars>, rows, cols>
typedef TaylorMatd<Eigen::Dynamic, Eigen::Dynamic, Eigen::Dynamic> TaylorMatXd
using TaylorVard = Eigen::AutoDiffScalar<Eigen::Matrix<double, num_vars, 1> >
typedef TaylorVard<Eigen::Dynamic> TaylorVarXd
using TaylorVecd = Eigen::Matrix<TaylorVard<num_vars>, rows, 1>
typedef TaylorVecd<Eigen::Dynamic, Eigen::Dynamic> TaylorVecXd
typedef std::chrono::system_clock TimeClock
typedef std::chrono::duration<double> TimeDuration
typedef std::chrono::time_point<TimeClock, TimeDuration> TimePoint
using VecIn = Eigen::Ref<Eigen::Matrix<ScalarType, Eigen::Dynamic, 1> const>
using VecOut = Eigen::Matrix<ScalarType, Eigen::Dynamic, 1>
typedef Eigen::Matrix<double, 1, 1> Vector1d

Function Documentation

bool Drake::decode ( const drake::lcmt_drake_signal &  msg,
double t,
Vector &  x 
)

Here is the call graph for this function:

Here is the caller graph for this function:

bool Drake::encode ( const double t,
const Vector &  x,
drake::lcmt_drake_signal &  msg 
)

Here is the call graph for this function:

Here is the caller graph for this function:

System::template StateVector<double> Drake::getInitialState ( const System &  sys)

getInitialState()

Returns a random feasible initial condition

Here is the call graph for this function:

DRAKERBSYSTEM_EXPORT RigidBodySystem::StateVector<double> Drake::getInitialState ( const RigidBodySystem sys)

Here is the call graph for this function:

Here is the caller graph for this function:

bool Drake::handle_realtime_factor ( const TimePoint wall_clock_start_time,
double  sim_time,
double  realtime_factor,
double  timeout_seconds 
)
inline

Determines whether the simulation time has lagged behind the real time beyond the specified

timeout_seconds

, after accounting for the real-time factor. If it has, throw a

std::runtime_error

exception.

Parameters
wall_clock_start_timeThe the simulation's start time.
sim_timeThe current simulation time.
realtime_factorThe simulation's desired real-time factor. This is the speed at which the simulation should run relative to real-time. For example, 0 means the simulation should run as fast as possible, 1.0 means the simulation should run at real-time, and 2.0 means the simulation should run at 2X real-time speed.
timeout_secondsThe maximum difference between the current time and the desired time (as determined based on the current simulation time and real-time factor) before which an exception is thrown. return True if the realtime factor was successfully handled. False otherwise.

Here is the caller graph for this function:

void Drake::initializeAutoDiff ( const Eigen::MatrixBase< Derived > &  val,
Eigen::MatrixBase< DerivedAutoDiff > &  auto_diff_matrix,
Eigen::DenseIndex  num_derivatives = Eigen::Dynamic,
Eigen::DenseIndex  deriv_num_start = 0 
)

Initialize a single autodiff matrix given the corresponding value matrix.

Set the values of auto_diff_matrix to be equal to val, and for each element i of auto_diff_matrix, resize the derivatives vector to num_derivatives, and set derivative number deriv_num_start + i to one (all other elements of the derivative vector set to zero).

Parameters
[in]mat'regular' matrix of values
[out]retAutoDiff matrix
[in]num_derivativesthe size of the derivatives vector
Default: the size of mat
[in]deriv_num_startstarting index into derivative vector (i.e. element deriv_num_start in derivative vector corresponds to mat(0, 0)).
Default: 0

Here is the caller graph for this function:

AutoDiffMatrixType<Derived, Nq> Drake::initializeAutoDiff ( const Eigen::MatrixBase< Derived > &  mat,
Eigen::DenseIndex  num_derivatives = -1,
Eigen::DenseIndex  deriv_num_start = 0 
)

Initialize a single autodiff matrix given the corresponding value matrix.

Create autodiff matrix that matches mat in size with derivatives of compile time size Nq and runtime size num_derivatives. Set its values to be equal to val, and for each element i of auto_diff_matrix, set derivative number deriv_num_start + i to one (all other derivatives set to zero).

Parameters
[in]mat'regular' matrix of values
[in]num_derivativesthe size of the derivatives vector
Default: the size of mat
[in]deriv_num_startstarting index into derivative vector (i.e. element deriv_num_start in derivative vector corresponds to mat(0, 0)).
Default: 0
Returns
AutoDiff matrix

Here is the call graph for this function:

void Drake::initializeAutoDiffGivenGradientMatrix ( const Eigen::MatrixBase< Derived > &  val,
const Eigen::MatrixBase< DerivedGradient > &  gradient,
Eigen::MatrixBase< DerivedAutoDiff > &  auto_diff_matrix 
)

Initializes an autodiff matrix given a matrix of values and gradient matrix.

Parameters
[in]valvalue matrix
[in]gradientgradient matrix; the derivatives of val(j) are stored in row j of the gradient matrix.
[out]autodiff_matrixmatrix of AutoDiffScalars with the same size as val

Here is the caller graph for this function:

AutoDiffMatrixType<Derived, DerivedGradient::ColsAtCompileTime> Drake::initializeAutoDiffGivenGradientMatrix ( const Eigen::MatrixBase< Derived > &  val,
const Eigen::MatrixBase< DerivedGradient > &  gradient 
)

Creates and initializes an autodiff matrix given a matrix of values and gradient matrix.

Parameters
[in]valvalue matrix
[in]gradientgradient matrix; the derivatives of val(j) are stored in row j of the gradient matrix.
Returns
autodiff_matrix matrix of AutoDiffScalars with the same size as val

Here is the call graph for this function:

std::tuple< AutoDiffMatrixType<Deriveds, totalSizeAtCompileTime<Deriveds...>)>...> Drake::initializeAutoDiffTuple ( const Eigen::MatrixBase< Deriveds > &...  args)

Given a series of Eigen matrices, create a tuple of corresponding AutoDiff matrices with values equal to the input matrices and properly initialized derivative vectors.

The size of the derivative vector of each element of the matrices in the output tuple will be the same, and will equal the sum of the number of elements of the matrices in args. If all of the matrices in args have fixed size, then the derivative vectors will also have fixed size (being the sum of the sizes at compile time of all of the input arguments), otherwise the derivative vectors will have dynamic size. The 0th element of the derivative vectors will correspond to the derivative with respect to the 0th element of the first argument. Subsequent derivative vector elements correspond first to subsequent elements of the first input argument (traversed first by row, then by column), and so on for subsequent arguments.

Parameters
argsa series of Eigen matrices
Returns
a tuple of properly initialized AutoDiff matrices corresponding to args

Here is the call graph for this function:

Here is the caller graph for this function:

auto Drake::make_function ( ReturnType(*)(Args...)  p) -> std::function<ReturnType(Args...)>

make_function Note that a completely general make_function implementation is not possible due to ambiguities, but this works for all of the cases in this file Inspired by http://stackoverflow.com/a/21740143/2228557

Here is the caller graph for this function:

auto make_function ( ReturnType(ClassType::*)(Args...)  p) -> std::function<ReturnType(ClassType&, Args...)>

Here is the call graph for this function:

void Drake::parseForceElement ( RigidBodySystem sys,
XMLElement *  node 
)

Here is the call graph for this function:

Here is the caller graph for this function:

void Drake::parseRobot ( RigidBodySystem sys,
XMLElement *  node 
)

Here is the call graph for this function:

Here is the caller graph for this function:

void Drake::parseSDF ( RigidBodySystem sys,
XMLDocument *  xml_doc 
)

Here is the call graph for this function:

Here is the caller graph for this function:

void Drake::parseSDFJoint ( RigidBodySystem sys,
int  model_id,
XMLElement *  node,
PoseMap pose_map 
)

Here is the caller graph for this function:

void Drake::parseSDFLink ( RigidBodySystem sys,
int  model_id,
XMLElement *  node,
PoseMap pose_map 
)

Here is the call graph for this function:

Here is the caller graph for this function:

void Drake::parseSDFModel ( RigidBodySystem sys,
int  model_id,
XMLElement *  node 
)

Here is the call graph for this function:

Here is the caller graph for this function:

void Drake::parseURDF ( RigidBodySystem sys,
XMLDocument *  xml_doc 
)

Here is the call graph for this function:

Here is the caller graph for this function:

void Drake::resizeDerivativesToMatchScalar ( Eigen::MatrixBase< Derived > &  mat,
const typename Derived::Scalar &  scalar 
)

Resize derivatives vector of each element of a matrix to to match the size of the derivatives vector of a given scalar.

If the mat and scalar inputs are AutoDiffScalars, resize the derivatives vector of each element of the matrix mat to match the number of derivatives of the scalar. This is useful in functions that return matrices that do not depend on an AutoDiffScalar argument (e.g. a function with a constant output), while it is desired that information about the number of derivatives is preserved.

Parameters
matmatrix, for which the derivative vectors of the elements will be resized
scalarscalar to match the derivative size vector against.

Here is the caller graph for this function:

void Drake::runLCM ( const System &  sys,
std::shared_ptr< lcm::LCM >  lcm,
double  t0,
double  tf 
)

Here is the call graph for this function:

Eigen::VectorXd spatialForceInFrameToJointTorque ( const RigidBodyTree tree,
const KinematicsCache< double > &  rigid_body_state,
const RigidBodyFrame frame,
const Eigen::Matrix< double, 6, 1 > &  force 
)

spatialForceInFrameToJointTorque

helper function for rigid body force elements. todo: move this into RigidBodyTree?

Here is the call graph for this function:

Here is the caller graph for this function:

std::shared_ptr<AffineSystem<NullVector, System::template StateVector, System::template InputVector> > Drake::timeInvariantLQR ( const System &  sys,
const typename System::template StateVector< double > &  x0,
const typename System::template InputVector< double > &  u0,
const Eigen::MatrixXd &  Q,
const Eigen::MatrixXd &  R 
)

Here is the call graph for this function:

const Eigen::Matrix<ScalarType, Rows, 1>& Drake::toEigen ( const Eigen::Matrix< ScalarType, Rows, 1 > &  vec)

Here is the caller graph for this function:

constexpr int Drake::totalSizeAtCompileTime ( )

Determine the total size at compile time of a number of arguments based on their SizeAtCompileTime static members.

Here is the call graph for this function:

Here is the caller graph for this function:

constexpr Eigen::DenseIndex Drake::totalSizeAtRunTime ( )

Determine the total size at runtime of a number of arguments using their size() methods (base case).

Here is the caller graph for this function:

Eigen::DenseIndex Drake::totalSizeAtRunTime ( const Eigen::MatrixBase< Head > &  head,
const Tail &...  tail 
)

Determine the total size at runtime of a number of arguments using their size() methods (recursive)

Here is the call graph for this function:

Variable Documentation

const SimulationOptions default_simulation_options
static