29 #include "yamlbuilder/TensegrityModel.h"
50 std::vector<std::string> tagsToControl) :
51 m_startTime(startTime),
52 m_minLength(minLength),
54 m_tagsToControl(tagsToControl),
58 if( m_startTime < 0.0 ) {
59 throw std::invalid_argument(
"Start time must be greater than or equal to zero.");
62 else if( m_minLength > 1 ) {
63 throw std::invalid_argument(
"minLength is a percent, must be less than 1. (100%)");
65 else if( m_minLength < 0.0) {
66 throw std::invalid_argument(
"minLength is a percent, must be greater than 0.");
69 else if( rate < 0.0 ) {
70 throw std::invalid_argument(
"Rate cannot be negative.");
83 std::cout <<
"Finding cables with the tag: " << tag << std::endl;
86 std::cout <<
"The following cables were found and will be controlled: "
89 for (std::size_t i = 0; i < foundActuators.size(); i ++) {
90 std::cout << foundActuators[i]->getTags() << std::endl;
93 initialRL[foundActuators[i]->getTags()] = foundActuators[i]->getRestLength();
95 std::cout <<
"Cable rest length at t=0 is "
96 << initialRL[foundActuators[i]->getTags()] << std::endl;
100 cablesWithTags.insert( cablesWithTags.end(), foundActuators.begin(),
101 foundActuators.end() );
111 std::cout <<
"Setting up the HorizontalSpine controller." << std::endl;
116 std::vector<std::string>::iterator it;
117 for( it = m_tagsToControl.begin(); it < m_tagsToControl.end(); it++ ) {
121 std::cout <<
"Finished setting up the controller." << std::endl;
129 if( m_timePassed > m_startTime ) {
132 for (std::size_t i = 0; i < cablesWithTags.size(); i ++) {
133 double currRestLength = cablesWithTags[i]->getRestLength();
136 double minRestLength = initialRL[cablesWithTags[i]->getTags()] * m_minLength;
138 if( currRestLength > minRestLength ) {
140 std::cout <<
"." << i;
143 double nextRestLength = currRestLength - m_rate * dt;
146 cablesWithTags[i]->setControlInput(nextRestLength,dt);
void initializeActuators(TensegrityModel &subject, std::string tag)
Convenience function for combining strings with ints, mostly for naming structures.
SpineKinematicsTestController(double startTime, double minLength, double rate, std::vector< std::string > tagsToControl)
Contains the definition of class SpineKinematicsTestController.
Contains the definition of abstract base class tgSpringCableActuator. Assumes that the string is line...
A series of functions to assist with file input/output.
Contains the definition of class tgBasicActuator.
virtual void onSetup(TensegrityModel &subject)
std::vector< T * > find(const tgTagSearch &tagSearch)
virtual void onStep(TensegrityModel &subject, double dt)