18 std::cout <<
"Hello World!\n";
19 unsigned i, j, updateCount;
21 double mySamplingRate = 1000.0;
22 double samplePeriod = 1 / mySamplingRate;
23 unsigned mySampleCount = 30000;
40 pinMode(5, ANALOG_IN, 31);
42 cout <<
"Muscles initialized. Press any key to calibrate loadcells and wind up motor for each muscle...\n";
47 cout <<
"\t- Muscle " << i <<
" wound up and LC calibrated...\n";
51 cout <<
"Muscle windup complete! Press any key to calibrate encoders for each muscle...\n";
56 cout <<
"\t- Muscle " << i <<
" calibrated...\n";
59 cout <<
"Calibration complete! Let's read data for " << mySampleCount/mySamplingRate <<
"seconds...\n";
63 for (i = 0, t = 0.0, updateCount = 0; i < mySampleCount; i++, t += samplePeriod) {
72 mc[j] = max(((j%2==0)?4:4) * cos(2 * 3.1416 * 1 * t + ((j%2==0)?0:3.1416)), 0);
82 jtAngle = (double) getAnalogInPin(5, 31);
83 printf(
"%0.3lf: q1 %+06.2lf ", t, jtAngle);
88 printf(
"| M(%d): MC %+06.2lfV, MT %+06.2lfN, TE %+06.2lfmm ", \
89 (
int)m[j].getChannelID(), \
90 m[j].getMotorCommand(), \
91 m[j].getMuscleTension(), \
92 m[j].getTendonExcursion());
97 cout <<
"\nSampling complete! Press any key to wind down motors.\n";
This is the class object for each muscle channel.
void windUp()
Function starts/energizes the motor of the muscle channel to wind up the tendons to prevent slack.
void readMuscleTension()
Uses the DAQ subsystem to read the muscle tension detected by the loadcell and puts it in the interna...
void calibrateTension(double loadCellGain=NAN)
Sets the gain to calibrate the transformation of the loadcell voltage to force in newtons....
void startMuscleControl()
Starts the force controller and update the status of the muscle channel. This function only needs to ...
void executeControl()
Executes the control law set by the controlRoutine function pointer.
void windDown()
Function stops/deenergizes the motor of the muscle channel to wind down the tendons before system shu...
void readTendonExcursion()
Uses the DAQ subsystem to read the tendon excursion detected by the shaft encoder and puts it in the ...
void setMotorCommand(double newCommand)
Sets the current motor command to be sent to the DC motor.
void calibrateExcursion(double spoolDiameter=NAN)
Calibrates the rotary incremental shaft encoder to zero degrees and set the conversion from angle to ...
unsigned myosynNumMuscles()
Returns the number of muscles configured by the library.
double myosynSamplingRate(double newSamplingRate=myosyn_samplingRate_global)
Sets the sampling rate of the data acquisition and controller of all the muscle channels....
void myosynWaitForClock()
This blocking function waits for the clock period to finish between two function calls....
void myosynSetConfiguration(DAQarrangement DAQconfiguration)
Set the muscle configuration/arrangement type of the library. List of possibilities in the DAQarrange...
unsigned muscleID[nMuscles]