drexel_darwin_preview_control_webots
no way to compare when less than two revisions
Differences
This shows you the differences between two versions of the page.
— | drexel_darwin_preview_control_webots [2016/11/06 20:57] (current) – created dwallace | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Optimal Preview Control Simulation on Webots ====== | ||
+ | Simulation on Webots is does using the generated trajectories. Trajectory points are generated for each joint. | ||
+ | |||
+ | These trajectories are imported to variables in the controller program on Webots. | ||
+ | |||
+ | Here is a video link of the Darwin-OP walking used the generated trajectory points. | ||
+ | |||
+ | {{youtube> | ||
+ | |||
+ | The controller program that does this is : | ||
+ | |||
+ | <code c++> | ||
+ | #include " | ||
+ | #include < | ||
+ | |||
+ | #include < | ||
+ | #include < | ||
+ | #include < | ||
+ | #include < | ||
+ | |||
+ | using namespace webots; | ||
+ | using namespace std; | ||
+ | |||
+ | static const char *servoNames[NSERVOS] = { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | }; | ||
+ | |||
+ | // | ||
+ | Symmetry:: | ||
+ | Robot() | ||
+ | { | ||
+ | //Get time step | ||
+ | // mTimeStep = getBasicTimeStep(); | ||
+ | mTimeStep = 1; | ||
+ | | ||
+ | //Get the two RGB_LEDs | ||
+ | mEyeLED = getLED(" | ||
+ | mHeadLED = getLED(" | ||
+ | | ||
+ | //Get all the 20 Servos and enable them | ||
+ | for(int i= 0; i < NSERVOS; i++) | ||
+ | { | ||
+ | mServos[i] = getServo(servoNames[i]); | ||
+ | mServos[i]-> | ||
+ | } | ||
+ | | ||
+ | |||
+ | } | ||
+ | |||
+ | // | ||
+ | Symmetry:: | ||
+ | } | ||
+ | |||
+ | //Step function | ||
+ | void Symmetry:: | ||
+ | int ret = step(mTimeStep); | ||
+ | if (ret == -1) | ||
+ | exit(EXIT_SUCCESS); | ||
+ | } | ||
+ | |||
+ | //Wait function | ||
+ | void Symmetry:: | ||
+ | double startTime = getTime(); | ||
+ | double s = (double) ms / 1000.0; | ||
+ | while (s + startTime >= getTime()) | ||
+ | myStep(); | ||
+ | } | ||
+ | |||
+ | // function containing the main feedback loop | ||
+ | void Symmetry:: | ||
+ | |||
+ | | ||
+ | double position = 0; | ||
+ | float xp [802] = {0, |