Control¶
The following classes are used to realise the generated motion on a simulated system.
MPC¶
-
namespace
gambol -
class
MPC¶ - #include <MPC.h>
Wrapper for model predictive control for simulation
Functionality is fairly basic, main purpose is to wrap the optimization update.
Public Types
-
using
VectorXd= Eigen::VectorXd¶
Public Functions
-
MPC()¶ Constructor.
-
virtual
~MPC() = default¶ Destructor.
-
void
SetInitialConfig(const VectorXd &qpos, const VectorXd &qvel)¶ Set new initial configuration
This is used to fix the MPC to the current state.
-
void
SetTime(double t)¶ Update time
Bring phases closer by shortening the tip. End of phases is padded with contact (stance mode) to achieve a rolling horizion.
-
bool
Predict(NodesHolder &solution)¶ Perform optimization on current configurations
Function is blocking until optimization is done.
- Parameters
solution – NodesHolder for optimized results
- Returns
True if solver return is SUCCESS or ACCEPTABLE
Public Members
-
NlpFormulation
formulation_¶
-
ifopt::IpoptSolver::Ptr
solver_¶
-
ifopt::Problem
nlp_¶
-
int
optimizations_¶
Private Functions
-
void
InterpolateOldSolution(const ifopt::VariableSet::Ptr &set, const NodesHolder &old_solution)¶ Interpolate a new variable set from a previous solution.
The solution from a previous optimization will have different node times. This method will use the new times to interpolate the previous solution.
Private Members
-
double
t_last_¶ Simulation time of last update.
-
double
delta_t_¶ Simulation time difference between last updates.
Private Static Functions
-
static NodesVariables::Ptr
GetVariableFromHolder(const NodesHolder &holder, const std::string &name)¶ Get a single variable from NodesHolder based on name.
-
using
-
class
Robot State¶
CsvLogger¶
-
namespace
gambol -
class
CsvLogger¶ - #include <CsvLogger.h>
Class to log simulation data to file.
It is made to log during an online MPC scheme, so it logs both optimized trajectories and simulated data when this trajectory is applied.
Public Types
-
using
VectorXd= Eigen::VectorXd¶
Public Functions
-
explicit
CsvLogger(const std::string &name = "")¶ Constructor.
- Parameters
name – Name for part of the file, e.g. model name
-
virtual
~CsvLogger() = default¶ Filestream is RAII and closes itself.
-
void
log(double t, const VectorXd &qpos, const VectorXd &qvel, const VectorXd &qacc, const VectorXd &qpos_r, const VectorXd &qvel_r, const VectorXd &u_ff, const VectorXd &u_fb, const std::vector<VectorXd> &forces, const std::vector<VectorXd> &forces_r, int predict_count = 0)¶ Create log entry.
This corresponds to a single row in the file.
Public Static Functions
-
static std::string
fileNameFromPath(std::string path)¶ Return file name from a path.
-
using
-
class