Example #1
0
// Will be called from subclasses, as is virtual function
//----------------------------------------------------------------------------------------------------------------------  
void Muscle::toXml(ci::XmlTree& muscle)
{
  // XMLTree muscle provided by subclass   //ci::XmlTree muscle("Muscle", "");
  muscle.setAttribute("Name", getName());
  muscle.setAttribute("IsFlexor", isFlexor());
  muscle.setAttribute("IsMono", isMonoArticulate());
    
  ci::XmlTree attach("Attachment",""); 
  attach.setAttribute("Origin", getOrigin()); 
  attach.setAttribute("Insertion", getInsertion());   
  muscle.push_back(attach);
  
  double Fmax = getForceMax();
  ci::XmlTree maxForce("MaxIsoForce", toString(Fmax));
  muscle.push_back(maxForce);
  
  double Vmax = getVelocityMax();
  ci::XmlTree maxVel("MaxVelocity", toString(Vmax));
  muscle.push_back(maxVel);  
  
  ci::XmlTree length("Length",""); 
  length.setAttribute("Optimal", getOptimalLength()); 
  length.setAttribute("Min", m_lengthMin); 
  length.setAttribute("Max", m_lengthMax); 
  muscle.push_back(length);
  
  ci::XmlTree hillParams("HillParameters",""); 
  hillParams.setAttribute("Shortening", m_hillSh); 
  hillParams.setAttribute("Lengthening", m_hillLn); 
  hillParams.setAttribute("Asymptote", m_hillMax); 
  hillParams.setAttribute("Slope", m_hillSlope); 
  muscle.push_back(hillParams);
}
Example #2
0
//----------------------------------------------------------------------------------------------------------------------
void CTRNN::toXml(ci::XmlTree& xml)
{
  ci::XmlTree nn("CTRNN","");
  nn.setAttribute("Size", size);
  nn.setAttribute("Weight", getWeightSum());
  
  for(int i = 0; i < size; ++i)
  {
    ci::XmlTree n("Neuron","");
    n.setAttribute("Index", i);
    n.setAttribute("Bias", biases[i]);
    n.setAttribute("TimeConstant", taus[i]);
    n.setAttribute("Gain", gains[i]);
    
    for(int j = 0; j < size; ++j)
    {
      ci::XmlTree w("Weight", toString(weights[j][i]));
      w.setAttribute("From", j);
      n.push_back(w);
    }

    nn.push_back(n);
  }
  
  xml.push_back(nn);
}
Example #3
0
//----------------------------------------------------------------------------------------------------------------------  
void SMCAgent::toXml(ci::XmlTree& xml)
{
  if(m_distanceSensor != NULL)
    m_distanceSensor->toXml(xml);
  
  xml.push_back(ci::XmlTree("MaxSpeed", toString(m_maxSpeed)));
  float maxAngSpeed = radiansToDegrees(m_maxAngularSpeed);
  xml.push_back(ci::XmlTree("MaxAngularSpeed", toString(maxAngSpeed)));
  xml.push_back(ci::XmlTree("MaxPosition", toString(m_maxPosition)));
  xml.push_back(ci::XmlTree("PositionWraps", toString(m_positionWraps)));
  float maxAngle = radiansToDegrees(m_maxAngle);
  xml.push_back(ci::XmlTree("MaxAngle", toString(maxAngle)));
  xml.push_back(ci::XmlTree("AngleWraps", toString(m_angleWraps)));
    
  // ctrnn
  m_ctrnn->toXml(xml);
}