NTRT Simulator  Version: Master
 All Classes Namespaces Files Functions Variables Typedefs Friends Pages
SpineGoalControl Class Reference

#include <SpineGoalControl.h>

Inheritance diagram for SpineGoalControl:
Collaboration diagram for SpineGoalControl:

Classes

struct  Config
 

Public Member Functions

 SpineGoalControl (SpineGoalControl::Config config, std::string args, std::string resourcePath="", std::string ec="edgeConfig.ini", std::string nc="nodeConfig.ini", std::string fc="feedbackConfig.ini", std::string gc="goalConfig.ini")
 
virtual void onSetup (BaseSpineModelLearning &subject)
 
virtual void onStep (BaseSpineModelLearning &subject, double dt)
 
virtual void onTeardown (BaseSpineModelLearning &subject)
 
const double getCPGValue (std::size_t i) const
 
double getScore () const
 
virtual void onAttach (BaseSpineModelLearning &subject)
 
void attach (tgObserver< BaseSpineCPGControl > *pObserver)
 
void notifyStep (double dt)
 
void notifySetup ()
 
void notifyTeardown ()
 

Protected Member Functions

virtual void setupCPGs (BaseSpineModelLearning &subject, array_2D nodeActions, array_4D edgeActions)
 
virtual array_2D scaleNodeActions (std::vector< std::vector< double > > actions)
 
std::vector< double > getFeedback (BaseSpineModelLearning &subject)
 
std::vector< double > getGoalFeedback (const BaseSpineModelGoal *subject)
 
void setGoalTensions (const BaseSpineModelGoal *subject, btVector3 &desiredHeading)
 
std::vector< double > getCableState (const tgSpringCableActuator &cable)
 
std::vector< double > transformFeedbackActions (std::vector< std::vector< double > > &actions, configuration &configData)
 
double calculateDistanceMoved (const BaseSpineModelGoal *subject) const
 
virtual array_4D scaleEdgeActions (std::vector< std::vector< double > > actions)
 

Protected Attributes

SpineGoalControl::Config m_config
 
std::string feedbackConfigFilename
 
NeuroEvolution feedbackEvolution
 
NeuroAdapter feedbackAdapter
 
bool feedbackLearning
 
configuration feedbackConfigData
 
std::string goalConfigFilename
 
NeuroEvolution goalEvolution
 
NeuroAdapter goalAdapter
 
bool goalLearning
 
configuration goalConfigData
 
CPGEquationsm_pCPGSys
 
std::vector
< tgCPGActuatorControl * > 
m_allControllers
 
std::string edgeConfigFilename
 
std::string nodeConfigFilename
 
configuration nodeConfigData
 
configuration edgeConfigData
 
AnnealEvolution edgeEvolution
 
AnnealEvolution nodeEvolution
 
AnnealAdapter edgeAdapter
 
AnnealAdapter nodeAdapter
 
bool nodeLearning
 
bool edgeLearning
 
std::vector< double > initConditions
 
std::size_t segments
 
tgDataObserver m_dataObserver
 
double m_updateTime
 
std::vector< double > scores
 
bool bogus
 

Detailed Description

SpineGoalControl learns the parameters for a CPG system on a spine like tensegrity structure specified as a BaseSpineModelLearning. Parameters are generated by AnnealEvolution and used in the CPGEquations family of classes. tgImpedanceController controllers are used for the detailed muscle control. Due to the number of parameters, the learned parameters are split into one config file for the nodes and another for the CPG's "edges"

Definition at line 49 of file SpineGoalControl.h.

Constructor & Destructor Documentation

SpineGoalControl::SpineGoalControl ( SpineGoalControl::Config  config,
std::string  args,
std::string  resourcePath = "",
std::string  ec = "edgeConfig.ini",
std::string  nc = "nodeConfig.ini",
std::string  fc = "feedbackConfig.ini",
std::string  gc = "goalConfig.ini" 
)

Defining the adapters here assumes the controller is around and attached for the lifecycle of the learning runs. I.E. that the setup and teardown functions are used for tgModel

Definition at line 98 of file SpineGoalControl.cpp.

Here is the call graph for this function:

Member Function Documentation

void tgSubject< BaseSpineCPGControl >::attach ( tgObserver< BaseSpineCPGControl > *  pObserver)
inherited

Attach an observer to the subject of the observer.

Parameters
[in,out]pObservera pointer to an observer for the subject; do nothing if the pointer is NULL
void tgSubject< BaseSpineCPGControl >::notifySetup ( )
inherited

Call tgObserver<T>::onSetup() on all observers in the order in which they were attached.

void tgSubject< BaseSpineCPGControl >::notifyStep ( double  dt)
inherited

Call tgObserver<T>::onStep() on all observers in the order in which they were attached.

Parameters
[in]dtthe number of seconds since the previous call; do nothing if not positive
void tgSubject< BaseSpineCPGControl >::notifyTeardown ( )
inherited

Call tgObserver<T>::onTeardown() on all observers in the order in which they were attached.

virtual void tgObserver< BaseSpineModelLearning >::onAttach ( BaseSpineModelLearning subject)
inlinevirtualinherited

Notify the observers when an attach action has occurred. Will only occur once, typically before setup

Parameters
[in,out]subjectthe subject being observed

Definition at line 55 of file tgObserver.h.

void SpineGoalControl::onSetup ( BaseSpineModelLearning subject)
virtual

Notify the observers when a setup action has occurred.

Parameters
[in,out]subjectthe subject being observed

Reimplemented from BaseSpineCPGControl.

Reimplemented in SpineOnlineControl.

Definition at line 135 of file SpineGoalControl.cpp.

Here is the caller graph for this function:

void SpineGoalControl::onStep ( BaseSpineModelLearning subject,
double  dt 
)
virtual

Notify the observers when a step action has occurred.

Parameters
[in,out]subjectthe subject being observed
[in]thenumber of seconds since the previous call; must be positive
Todo:
add to config
Todo:
if bogus, stop trial (reset simulation)

Reimplemented from BaseSpineCPGControl.

Reimplemented in SpineOnlineControl.

Definition at line 178 of file SpineGoalControl.cpp.

void SpineGoalControl::onTeardown ( BaseSpineModelLearning subject)
virtual

Notify the observers when a teardown action has occurred.

Parameters
[in,out]subjectthe subject being observed
Todo:
  • consolidate with other controller classes.
Todo:
  • return length scale as a parameter

Reimplemented from BaseSpineCPGControl.

Reimplemented in SpineOnlineControl.

Definition at line 227 of file SpineGoalControl.cpp.

array_4D BaseSpineCPGControl::scaleEdgeActions ( std::vector< std::vector< double > >  actions)
protectedvirtualinherited

Takes a vector of parameters reported by learning, and then converts it into a format used to assign to the CPGEdges Note that if the CPG edges change, this will need to change

Definition at line 364 of file BaseSpineCPGControl.cpp.

Member Data Documentation

AnnealAdapter BaseSpineCPGControl::edgeAdapter
protectedinherited

Handles getting parameters from and returning scores to the evolution object. Needs to persist throughout a simulation

Definition at line 175 of file BaseSpineCPGControl.h.

std::string BaseSpineCPGControl::edgeConfigFilename
protectedinherited

Hold the filename that gets passed to the respective configuration objects Having two of each of these allows for different groups of parameters to be specified

Definition at line 154 of file BaseSpineCPGControl.h.

AnnealEvolution BaseSpineCPGControl::edgeEvolution
protectedinherited

The object that holds all of the data for the evolution run in vectors of populations. Needs to persist throughout a simulation

Definition at line 168 of file BaseSpineCPGControl.h.

configuration BaseSpineCPGControl::nodeConfigData
protectedinherited

A file input/output system that uses .ini files. The object converts a string to data in the filename that it has been passed.

Definition at line 161 of file BaseSpineCPGControl.h.

bool BaseSpineCPGControl::nodeLearning
protectedinherited

A booelan that indicates whether the respective group is learning this run. Is passed to the evolution adapter

Definition at line 181 of file BaseSpineCPGControl.h.


The documentation for this class was generated from the following files: