13 this->viewer = viewer;
15 this->currentTime = 0;
17 this->trajectories = std::vector<DesignerTrajectoryPtr>();
18 this->timeOptimalTrajectories = std::vector<TrajectoryPtr>();
22DesignerTrajectoryPlayer::updateLoop()
24 bool endReached =
true;
27 for (
TrajectoryPtr currentTrajectory : this->timeOptimalTrajectories)
29 if (!currentTrajectory)
33 if (currentTime < currentTrajectory->getTimeLength() * 1000)
35 Ice::DoubleSeq ice_JA = currentTrajectory->getStates(currentTime / 1000, 0);
37 std::vector<float> jA = std::vector<float>(ice_JA.begin(), ice_JA.end());
38 robot->getRobotNodeSet(trajectories[i]->getRns()->getName())->setJointValues(jA);
43 viewer->updateRobotVisualization();
44 currentTime = currentTime + (1000.0 / fps);
61 timer = std::shared_ptr<QTimer>(
new QTimer(
this));
62 connect(timer.get(), SIGNAL(timeout()),
this, SLOT(updateLoop()));
68 if (current && current->getNrOfUserWaypoints() != 1)
71 timeOptimalTrajectories.push_back(traj);
80 timer->start(1000.0 / fps);
void setFPS(int fps)
setFPS sets the refresh rate of the player (the amount of updates of the visualization) to fps
void startPlayback()
startPlayback starts the actual visualization of the trajectory
void finishedPlayback()
finishedPlayback tells all relevant controllers that the trajectory playback has stopped
void addTrajectory(DesignerTrajectoryPtr trajectory)
addTrajectory inserts a trajetory to the DesignerTrajectory player All added Trajectories will be pla...
DesignerTrajectoryPlayer(RobotVisualizationPtr viewer, VirtualRobot::RobotPtr robot)
DesignerTrajectoryPlayer construct a new DesignerTrajectoryPlayer that can be started to play a Traje...
The Trajectory class represents n-dimensional sampled trajectories.
std::shared_ptr< class Robot > RobotPtr
This file offers overloads of toIce() and fromIce() functions for STL container types.
IceInternal::Handle< Trajectory > TrajectoryPtr
std::shared_ptr< DesignerTrajectory > DesignerTrajectoryPtr
std::shared_ptr< RobotVisualization > RobotVisualizationPtr