11 VirtualRobot::TimeOptimalTrajectory&
trajectory,
12 std::vector<std::vector<double>>& userPoints,
13 VirtualRobot::RobotNodeSetPtr rns,
22 throw InvalidArgumentException(
"Rns is null");
25 if (rns->getAllRobotNodes().size() == 0)
28 throw InvalidArgumentException(
"Rns is empty");
34 timestep = (timestep > 0) ? timestep : 0.01;
42 std::vector<double> timestamps;
46 std::vector<std::vector<double>> nodeData;
47 std::vector<std::vector<double>> nodeData2;
50 timestamps.push_back(0);
52 for (
unsigned int i = 0; i < rns->getSize(); i++)
54 nodeData.push_back({
trajectory.getPosition(0)[i]});
58 for (
double t = timestep; t <
trajectory.getDuration(); t += timestep)
60 Eigen::VectorXd positions =
trajectory.getPosition(t);
62 for (
unsigned int i = 0; i < positions.size(); i++)
64 nodeData[i].push_back(positions[i]);
68 timestamps.push_back(t);
71 LimitlessStateSeq state;
72 for (VirtualRobot::RobotNodePtr node : rns->getAllRobotNodes())
74 LimitlessState current;
75 current.enabled = node->isLimitless();
76 current.limitLo = node->getJointLimitLow();
77 current.limitHi = node->getJointLimitHigh();
78 state.push_back(current);
81 Ice::StringSeq dimensionNames = rns->getNodeNames();
87 traj->setLimitless(state);
124 for (pass = 1; pass < 10; pass++)
127 std::vector<double> times;
130 for (
double t = 0; t <
trajectory.getDuration();
133 Eigen::VectorXd jointAngles =
134 Eigen::VectorXd::Map(&userPoints[i][0], userPoints[i].size());
139 Eigen::VectorXd pointJointAngles =
trajectory.getPosition(t);
146 const double distance = (jointAngles - pointJointAngles).
norm();
156 if (i >= userPoints.size())
170 if (times.size() < userPoints.size())
180 pass == 1 ?
ARMARX_INFO << pass <<
" pass needed to find mapping"
181 :
ARMARX_INFO << pass <<
" passes needed to find mapping";
184 ARMARX_INFO <<
"More than" << pass <<
"passes needed for calculation";
186 throw InvalidArgumentException(
"No TimedTrajectory could be created");
static TimedTrajectory createTimedTrajectory(VirtualRobot::TimeOptimalTrajectory &trajectory, std::vector< std::vector< double > > &userPoints, VirtualRobot::RobotNodeSetPtr rns, double maxDeviation)
Creates a TimedTrajectory out of the TimeOptimalTrajectory and maps the parameter userPoints to it.