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

#include <JSONSegmentsFeedbackControl.h>

Inheritance diagram for JSONSegmentsFeedbackControl:
Collaboration diagram for JSONSegmentsFeedbackControl:

Classes

struct  Config
 

Public Member Functions

 JSONSegmentsFeedbackControl (JSONSegmentsFeedbackControl::Config config, std::string args, std::string resourcePath="")
 
virtual void onSetup (BaseQuadModelLearning &subject)
 
virtual void onStep (BaseQuadModelLearning &subject, double dt)
 
virtual void onTeardown (BaseQuadModelLearning &subject)
 
const double getCPGValue (std::size_t i) const
 
double getScore () const
 
virtual void onAttach (BaseQuadModelLearning &subject)
 
void attach (tgObserver< JSONQuadCPGControl > *pObserver)
 
void notifyStep (double dt)
 
void notifySetup ()
 
void notifyTeardown ()
 

Protected Member Functions

virtual void setupCPGs (BaseQuadModelLearning &subject, array_2D nodeActions, array_4D edgeActions, array_4D hipEdgeActions, array_4D legEdgeActions)
 
virtual array_4D scaleEdgeActions (Json::Value actions, int theirMuscles, int ourMuscles)
 
virtual array_2D scaleNodeActions (Json::Value actions)
 
std::vector< double > getFeedback (BaseQuadModelLearning &subject)
 
std::vector< double > getCableState (const tgSpringCableActuator &cable)
 
std::vector< double > transformFeedbackActions (std::vector< std::vector< double > > &actions)
 
virtual array_4D scaleEdgeActions (Json::Value edgeParam)
 
virtual void setupCPGs (BaseQuadModelLearning &subject, array_2D nodeActions, array_4D edgeActions)
 

Protected Attributes

JSONSegmentsFeedbackControl::Config m_config
 
std::vector
< tgCPGActuatorControl * > 
m_spineControllers
 
std::vector
< tgCPGActuatorControl * > 
m_hipControllers
 
std::vector
< tgCPGActuatorControl * > 
m_legControllers
 
neuralNetwork * nn
 
CPGEquationsm_pCPGSys
 
std::vector
< tgCPGActuatorControl * > 
m_allControllers
 
std::vector< double > initConditions
 
std::size_t segments
 
tgDataObserver m_dataObserver
 
double m_updateTime
 
double m_totalTime
 
std::vector< double > scores
 
std::vector< double > metrics
 
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 47 of file JSONSegmentsFeedbackControl.h.

Constructor & Destructor Documentation

JSONSegmentsFeedbackControl::JSONSegmentsFeedbackControl ( JSONSegmentsFeedbackControl::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 113 of file JSONSegmentsFeedbackControl.cpp.

Member Function Documentation

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

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

void tgSubject< JSONQuadCPGControl >::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< JSONQuadCPGControl >::notifyTeardown ( )
inherited

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

virtual void tgObserver< BaseQuadModelLearning >::onAttach ( BaseQuadModelLearning 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 JSONSegmentsFeedbackControl::onSetup ( BaseQuadModelLearning subject)
virtual

Notify the observers when a setup action has occurred.

Parameters
[in,out]subjectthe subject being observed

Reimplemented from JSONQuadCPGControl.

Definition at line 128 of file JSONSegmentsFeedbackControl.cpp.

Here is the call graph for this function:

void JSONSegmentsFeedbackControl::onStep ( BaseQuadModelLearning 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)
Todo:
add to config
Todo:
if bogus, stop trial (reset simulation)

Reimplemented from JSONQuadCPGControl.

Definition at line 227 of file JSONSegmentsFeedbackControl.cpp.

void JSONSegmentsFeedbackControl::onTeardown ( BaseQuadModelLearning 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
Todo:
  • consolidate with other controller classes.
Todo:
  • return length scale as a parameter

Reimplemented from JSONQuadCPGControl.

Definition at line 335 of file JSONSegmentsFeedbackControl.cpp.

Here is the call graph for this function:

array_4D JSONSegmentsFeedbackControl::scaleEdgeActions ( Json::Value  actions,
int  theirMuscles,
int  ourMuscles 
)
protectedvirtual
Todo:
consider adding exception here

Definition at line 601 of file JSONSegmentsFeedbackControl.cpp.

Here is the caller graph for this function:

array_4D JSONQuadCPGControl::scaleEdgeActions ( Json::Value  edgeParam)
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

Todo:
consider adding exception here

Definition at line 389 of file JSONQuadCPGControl.cpp.

void JSONQuadCPGControl::setupCPGs ( BaseQuadModelLearning subject,
array_2D  nodeActions,
array_4D  edgeActions 
)
protectedvirtualinherited
Todo:
: redo with for_each

Definition at line 205 of file JSONQuadCPGControl.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

Member Data Documentation

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

Definition at line 143 of file JSONSegmentsFeedbackControl.h.


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