<?php // сесть встать include_once dirname(__FILE__) . "/ServoTimeLine.cls.php"; $tl = new rxServoTimeLine(); // таймлайн $frames1 = new servo_frame(); // кадры $frames2 = new servo_frame(); // кадры $frames3 = new servo_frame(); // кадры $frames4 = new servo_frame(); // кадры $stepTime = 10000; $timeFrame = 100; // сесть $frames1->addFrame("s2", 90, 0); $frames1->addFrame("s2", 25, $stepTime); $frames1->addFrame("s3", 45, 0); $frames1->addFrame("s3", 175, $stepTime); $frames1->addFrame("s4", 90, 0); $frames1->addFrame("s4", 155, $stepTime); $frames2->addFrame("s9", 90, 0); $frames2->addFrame("s9", 155, $stepTime); $frames2->addFrame("s10", 45, 0); $frames2->addFrame("s10", 175, $stepTime); $frames2->addFrame("s11", 90, 0); $frames2->addFrame("s11", 25, $stepTime); $frames3->addFrame("s2", 25, 0); $frames3->addFrame("s2", 90, $stepTime);
<?php // тест include_once "ServoTimeLine.cls.php"; $tl = new rxServoTimeLine(); // первая модель передвижения---------------------------------------------------------------- $frmPack = array("s1" => array(array("angle" => 0, "time" => 0, "speed" => STL_SPEED_ACCELERATION), array("angle" => 45, "time" => 1000, "speed" => STL_SPEED_NORMAL), array("angle" => 135, "time" => 4000, "speed" => STL_SPEED_DECELERATION), array("angle" => 180, "time" => 5000, "speed" => STL_SPEED_NORMAL)), "s2" => array(array("angle" => 0, "time" => 0, "speed" => STL_SPEED_NORMAL), array("angle" => 180, "time" => 5000, "speed" => STL_SPEED_NORMAL))); // создать модель поведения на основе созданных кадров $model = new servo_modelBlank(); $model->timeWork = 5000; $model->timeFrame = 200; $model->repeats = 1; $model->addKeyFrame($frmPack); $tl->addModel($model); // вторая модель передвижения---------------------------------------------------------------- $frmPack2 = array("s2" => array(array("angle" => 0, "time" => 0, "speed" => STL_SPEED_NORMAL), array("angle" => 180, "time" => 2000, "speed" => STL_SPEED_NORMAL))); $model2 = new servo_modelBlank(); $model2->timeWork = 2000; $model2->timeFrame = 100; $model2->repeats = 0; $model2->addKeyFrame($frmPack2); $tl->addModel($model2); // подсчитать модели - разложить их по таймлайну. $tl->calculateTimeLine(); $time = 0; $time2 = 0; for ($i = 0; $i < sizeof($tl->servoKeys); $i++) { // пауза между фреймами $time = $tl->servoKeys[$i]; if ($time2 > 0) { usleep((int) ($time - $time2 * 1000));