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

#include <JSONQuadFeedbackControl.h>

Inherits JSONCPGControl, JSONCPGControl, and JSONCPGControl.

Collaboration diagram for JSONQuadFeedbackControl:

Classes

struct  Config
 

Public Member Functions

 JSONQuadFeedbackControl (JSONQuadFeedbackControl::Config config, std::string args, std::string resourcePath="")
 
virtual void onSetup (BaseSpineModelLearning &subject)
 
virtual void onStep (BaseSpineModelLearning &subject, double dt)
 
virtual void onTeardown (BaseSpineModelLearning &subject)
 
 JSONQuadFeedbackControl (JSONQuadFeedbackControl::Config config, std::string args, std::string resourcePath="")
 
virtual void onSetup (BaseSpineModelLearning &subject)
 
virtual void onStep (BaseSpineModelLearning &subject, double dt)
 
virtual void onTeardown (BaseSpineModelLearning &subject)
 
 JSONQuadFeedbackControl (JSONQuadFeedbackControl::Config config, std::string args, std::string resourcePath="")
 
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< JSONCPGControl > *pObserver)
 
void notifyStep (double dt)
 
void notifySetup ()
 
void notifyTeardown ()
 

Protected Member Functions

virtual void setupCPGs (BaseSpineModelLearning &subject, array_2D nodeActions, array_4D edgeActions)
 
virtual void setupHighCPGs (array_2D nodeActions, array_4D highEdgeActions, Json::Value highLowEdgeActions)
 
virtual array_4D scaleEdgeActions (Json::Value edgeParam)
 
virtual array_2D scaleNodeActions (Json::Value actions)
 
virtual array_4D scaleHighEdgeActions (Json::Value highEdgeParam)
 
std::vector< double > getFeedback (BaseSpineModelLearning &subject)
 
std::vector< double > getCableState (const tgSpringCableActuator &cable)
 
std::vector< double > transformFeedbackActions (std::vector< std::vector< double > > &actions)
 
virtual void setupCPGs (BaseSpineModelLearning &subject, array_2D nodeActions, array_4D edgeActions)
 
virtual array_2D scaleNodeActions (Json::Value actions)
 
std::vector< double > getFeedback (BaseSpineModelLearning &subject)
 
std::vector< double > getCableState (const tgSpringCableActuator &cable)
 
std::vector< double > transformFeedbackActions (std::vector< std::vector< double > > &actions)
 
virtual void setupCPGs (BaseSpineModelLearning &subject, array_2D nodeActions, array_4D edgeActions)
 
virtual array_2D scaleNodeActions (Json::Value actions)
 
std::vector< double > getFeedback (BaseSpineModelLearning &subject)
 
std::vector< double > getCableState (const tgSpringCableActuator &cable)
 
std::vector< double > transformFeedbackActions (std::vector< std::vector< double > > &actions)
 

Protected Attributes

JSONQuadFeedbackControl::Config m_config
 
std::vector
< tgCPGActuatorControl * > 
m_controllers [9]
 
std::vector
< tgCPGActuatorControl * > 
m_highControllers
 
neuralNetwork * nn
 
int n_bodyParts
 
int n_muscSpine
 
int n_muscHip
 
int n_muscLeg
 
double P
 
double D
 
std::vector
< tgCPGActuatorControl * > 
m_spineControllers
 
CPGEquationsm_pCPGSys
 
std::vector
< tgCPGActuatorControl * > 
m_allControllers
 
std::vector< double > initConditions
 
std::size_t segments
 
tgDataObserver m_dataObserver
 
double m_updateTime
 
std::vector< double > scores
 
bool bogus
 
std::string controlFilename
 
std::string controlFilePath
 

Detailed Description

JSONFeedbackControl 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 46 of file JSONQuadFeedbackControl.h.

Constructor & Destructor Documentation

JSONQuadFeedbackControl::JSONQuadFeedbackControl ( JSONQuadFeedbackControl::Config  config,
std::string  args,
std::string  resourcePath = "" 
)

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 119 of file JSONQuadFeedbackControl.cpp.

Member Function Documentation

void tgSubject< JSONCPGControl >::attach ( tgObserver< JSONCPGControl > *  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< JSONCPGControl >::notifySetup ( )
inherited

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

void tgSubject< JSONCPGControl >::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< JSONCPGControl >::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.

virtual void JSONQuadFeedbackControl::onSetup ( BaseSpineModelLearning subject)
virtual

Notify the observers when a setup action has occurred.

Parameters
[in,out]subjectthe subject being observed

Reimplemented from JSONCPGControl.

virtual void JSONQuadFeedbackControl::onSetup ( BaseSpineModelLearning subject)
virtual

Notify the observers when a setup action has occurred.

Parameters
[in,out]subjectthe subject being observed

Reimplemented from JSONCPGControl.

void JSONQuadFeedbackControl::onSetup ( BaseSpineModelLearning subject)
virtual

Notify the observers when a setup action has occurred.

Parameters
[in,out]subjectthe subject being observed

Reimplemented from JSONCPGControl.

Definition at line 134 of file JSONQuadFeedbackControl.cpp.

virtual void JSONQuadFeedbackControl::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 JSONCPGControl.

virtual void JSONQuadFeedbackControl::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

Reimplemented from JSONCPGControl.

void JSONQuadFeedbackControl::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

Max and min heights added to config

Todo:
if bogus, stop trial (reset simulation)

Reimplemented from JSONCPGControl.

Definition at line 217 of file JSONQuadFeedbackControl.cpp.

virtual void JSONQuadFeedbackControl::onTeardown ( BaseSpineModelLearning subject)
virtual

Notify the observers when a teardown action has occurred.

Parameters
[in,out]subjectthe subject being observed

Reimplemented from JSONCPGControl.

virtual void JSONQuadFeedbackControl::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 JSONCPGControl.

void JSONQuadFeedbackControl::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 JSONCPGControl.

Definition at line 260 of file JSONQuadFeedbackControl.cpp.

Here is the call graph for this function:

array_4D JSONQuadFeedbackControl::scaleEdgeActions ( Json::Value  edgeParam)
protectedvirtual

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

Todo:
consider adding exception here
Todo:
consider adding exception here

Reimplemented from JSONCPGControl.

Definition at line 595 of file JSONQuadFeedbackControl.cpp.

Here is the caller graph for this function:

array_4D JSONQuadFeedbackControl::scaleHighEdgeActions ( Json::Value  highEdgeParam)
protectedvirtual
Todo:
consider adding exception here

Definition at line 706 of file JSONQuadFeedbackControl.cpp.

Here is the caller graph for this function:

Member Data Documentation

neuralNetwork * JSONQuadFeedbackControl::nn
protected
Todo:
generalize this if we need more than one
Todo:
generalize this if we need more than one
Todo:
generalize this if we need more than one

Definition at line 144 of file JSONQuadFeedbackControl.h.


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