@@ -38,9 +38,9 @@ namespace tesseract_environment
38
38
struct ofkt_builder : public boost ::dfs_visitor<>
39
39
{
40
40
ofkt_builder (OFKTStateSolver& tree,
41
- std::vector<std::pair<std::string, std::array< double , 2 >>>& limits ,
41
+ std::vector<tesseract_scene_graph::Joint::ConstPtr>& kinematic_joints ,
42
42
std::string prefix = " " )
43
- : tree_(tree), limits_(limits ), prefix_(prefix)
43
+ : tree_(tree), kinematic_joints_(kinematic_joints ), prefix_(prefix)
44
44
{
45
45
}
46
46
@@ -60,12 +60,12 @@ struct ofkt_builder : public boost::dfs_visitor<>
60
60
std::string parent_link_name = prefix_ + joint->parent_link_name ;
61
61
std::string child_link_name = prefix_ + joint->child_link_name ;
62
62
63
- tree_.addNode (joint, joint_name, parent_link_name, child_link_name, limits_ );
63
+ tree_.addNode (joint, joint_name, parent_link_name, child_link_name, kinematic_joints_ );
64
64
}
65
65
66
66
protected:
67
67
OFKTStateSolver& tree_;
68
- std::vector<std::pair<std::string, std::array< double , 2 >>>& limits_ ;
68
+ std::vector<tesseract_scene_graph::Joint::ConstPtr>& kinematic_joints_ ;
69
69
std::string prefix_;
70
70
};
71
71
@@ -156,9 +156,9 @@ bool OFKTStateSolver::init(tesseract_scene_graph::SceneGraph::ConstPtr scene_gra
156
156
link_map_[root_name] = root_.get ();
157
157
current_state_->link_transforms [root_name] = root_->getWorldTransformation ();
158
158
159
- std::vector<std::pair<std::string, std::array< double , 2 >>> limits ;
160
- limits .reserve (scene_graph->getJoints ().size ());
161
- ofkt_builder builder (*this , limits );
159
+ std::vector<tesseract_scene_graph::Joint::ConstPtr> kinematic_joints ;
160
+ kinematic_joints .reserve (scene_graph->getJoints ().size ());
161
+ ofkt_builder builder (*this , kinematic_joints );
162
162
163
163
std::map<tesseract_scene_graph::SceneGraph::Vertex, size_t > index_map;
164
164
boost::associative_property_map<std::map<tesseract_scene_graph::SceneGraph::Vertex, size_t >> prop_index_map (
@@ -174,11 +174,15 @@ bool OFKTStateSolver::init(tesseract_scene_graph::SceneGraph::ConstPtr scene_gra
174
174
boost::visitor (builder).root_vertex (scene_graph->getVertex (root_name)).vertex_index_map (prop_index_map));
175
175
176
176
// Populate Joint Limits
177
- limits_.resize (static_cast <long >(limits.size ()), 2 );
178
- for (std::size_t i = 0 ; i < limits.size (); ++i)
177
+ limits_.joint_limits .resize (static_cast <long int >(kinematic_joints.size ()), 2 );
178
+ limits_.velocity_limits .resize (static_cast <long int >(kinematic_joints.size ()));
179
+ limits_.acceleration_limits .resize (static_cast <long int >(kinematic_joints.size ()));
180
+ for (std::size_t i = 0 ; i < kinematic_joints.size (); ++i)
179
181
{
180
- limits_ (static_cast <long >(i), 0 ) = limits[i].second [0 ];
181
- limits_ (static_cast <long >(i), 1 ) = limits[i].second [1 ];
182
+ limits_.joint_limits (static_cast <long >(i), 0 ) = kinematic_joints[i]->limits ->lower ;
183
+ limits_.joint_limits (static_cast <long >(i), 1 ) = kinematic_joints[i]->limits ->upper ;
184
+ limits_.velocity_limits (static_cast <long >(i)) = kinematic_joints[i]->limits ->velocity ;
185
+ limits_.acceleration_limits (static_cast <long >(i)) = kinematic_joints[i]->limits ->acceleration ;
182
186
}
183
187
184
188
revision_ = 1 ;
@@ -263,15 +267,15 @@ EnvState::ConstPtr OFKTStateSolver::getCurrentState() const { return current_sta
263
267
264
268
EnvState::Ptr OFKTStateSolver::getRandomState () const
265
269
{
266
- return getState (joint_names_, tesseract_common::generateRandomNumber (limits_));
270
+ return getState (joint_names_, tesseract_common::generateRandomNumber (limits_. joint_limits ));
267
271
}
268
272
269
- const Eigen::MatrixX2d & OFKTStateSolver::getLimits () const { return limits_; }
273
+ const tesseract_common::KinematicLimits & OFKTStateSolver::getLimits () const { return limits_; }
270
274
271
275
void OFKTStateSolver::onEnvironmentChanged (const Commands& commands)
272
276
{
273
- std::vector<std::pair<std::string, std::array< double , 2 >>> new_limits ;
274
- new_limits .reserve (commands.size ());
277
+ std::vector<tesseract_scene_graph::Joint::ConstPtr> new_kinematic_joints ;
278
+ new_kinematic_joints .reserve (commands.size ());
275
279
276
280
std::vector<std::string> removed_joints;
277
281
removed_joints.reserve (commands.size ());
@@ -292,7 +296,7 @@ void OFKTStateSolver::onEnvironmentChanged(const Commands& commands)
292
296
const auto & cmd = static_cast <const tesseract_environment::AddCommand&>(*command);
293
297
const tesseract_scene_graph::Joint::ConstPtr& joint = cmd.getJoint ();
294
298
295
- addNode (joint, joint->getName (), joint->parent_link_name , joint->child_link_name , new_limits );
299
+ addNode (joint, joint->getName (), joint->parent_link_name , joint->child_link_name , new_kinematic_joints );
296
300
break ;
297
301
}
298
302
case tesseract_environment::CommandType::MOVE_LINK:
@@ -317,7 +321,7 @@ void OFKTStateSolver::onEnvironmentChanged(const Commands& commands)
317
321
318
322
nodes_.erase (old_joint_name);
319
323
320
- addNode (joint, joint->getName (), joint->parent_link_name , joint->child_link_name , new_limits );
324
+ addNode (joint, joint->getName (), joint->parent_link_name , joint->child_link_name , new_kinematic_joints );
321
325
break ;
322
326
}
323
327
case tesseract_environment::CommandType::MOVE_JOINT:
@@ -369,9 +373,9 @@ void OFKTStateSolver::onEnvironmentChanged(const Commands& commands)
369
373
const auto & cmd = static_cast <const tesseract_environment::AddSceneGraphCommand&>(*command);
370
374
const tesseract_scene_graph::Joint::ConstPtr& joint = cmd.getJoint ();
371
375
372
- addNode (joint, joint->getName (), joint->parent_link_name , joint->child_link_name , new_limits );
376
+ addNode (joint, joint->getName (), joint->parent_link_name , joint->child_link_name , new_kinematic_joints );
373
377
374
- ofkt_builder builder (*this , new_limits , cmd.getPrefix ());
378
+ ofkt_builder builder (*this , new_kinematic_joints , cmd.getPrefix ());
375
379
376
380
std::map<tesseract_scene_graph::SceneGraph::Vertex, size_t > index_map;
377
381
boost::associative_property_map<std::map<tesseract_scene_graph::SceneGraph::Vertex, size_t >> prop_index_map (
@@ -400,8 +404,8 @@ void OFKTStateSolver::onEnvironmentChanged(const Commands& commands)
400
404
// Assign the lower/upper. Velocity, acceleration, and effort are ignored
401
405
if (it != limits.end ())
402
406
{
403
- limits_ (static_cast <Eigen::Index>(i), 0 ) = it->second .first ;
404
- limits_ (static_cast <Eigen::Index>(i), 1 ) = it->second .second ;
407
+ limits_. joint_limits (static_cast <Eigen::Index>(i), 0 ) = it->second .first ;
408
+ limits_. joint_limits (static_cast <Eigen::Index>(i), 1 ) = it->second .second ;
405
409
}
406
410
}
407
411
@@ -429,26 +433,49 @@ void OFKTStateSolver::onEnvironmentChanged(const Commands& commands)
429
433
std::remove_if (joint_names_.begin (), joint_names_.end (), [removed_joints](const std::string& joint_name) {
430
434
return (std::find (removed_joints.begin (), removed_joints.end (), joint_name) != removed_joints.end ());
431
435
}));
432
- Eigen::MatrixX2d l1 (limits_.rows () - static_cast <long >(removed_joints.size ()), 2 );
436
+
437
+ tesseract_common::KinematicLimits l1;
438
+ l1.joint_limits .resize (static_cast <long int >(joint_names_.size ()), 2 );
439
+ l1.velocity_limits .resize (static_cast <long int >(joint_names_.size ()));
440
+ l1.acceleration_limits .resize (static_cast <long int >(joint_names_.size ()));
441
+
433
442
long cnt = 0 ;
434
- for (long i = 0 ; i < limits_.rows (); ++i)
443
+ for (long i = 0 ; i < limits_.joint_limits .rows (); ++i)
444
+ {
435
445
if (std::find (removed_joints_indices.begin (), removed_joints_indices.end (), i) == removed_joints_indices.end ())
436
- l1.row (cnt++) = limits_.row (i);
446
+ {
447
+ l1.joint_limits .row (cnt) = limits_.joint_limits .row (i);
448
+ l1.velocity_limits (cnt) = limits_.velocity_limits (i);
449
+ l1.acceleration_limits (cnt) = limits_.acceleration_limits (i);
450
+ ++cnt;
451
+ }
452
+ }
437
453
438
454
limits_ = l1;
439
455
}
440
456
441
457
// Populate Joint Limits
442
- if (new_limits .empty () == false )
458
+ if (new_kinematic_joints .empty () == false )
443
459
{
444
- Eigen::MatrixX2d l (limits_.rows () + static_cast <long >(new_limits.size ()), 2 );
445
- Eigen::MatrixX2d l2 (static_cast <long >(new_limits.size ()), 2 );
446
- for (std::size_t i = 0 ; i < new_limits.size (); ++i)
460
+ tesseract_common::KinematicLimits l;
461
+ long s = limits_.joint_limits .rows () + static_cast <long >(new_kinematic_joints.size ());
462
+ l.joint_limits .resize (s, 2 );
463
+ l.velocity_limits .resize (s);
464
+ l.acceleration_limits .resize (s);
465
+
466
+ limits_.joint_limits .block (0 , 0 , limits_.joint_limits .rows (), 2 ) = limits_.joint_limits ;
467
+ limits_.velocity_limits .head (limits_.joint_limits .rows ()) = limits_.velocity_limits ;
468
+ limits_.acceleration_limits .head (limits_.joint_limits .rows ()) = limits_.acceleration_limits ;
469
+
470
+ long cnt = limits_.joint_limits .size ();
471
+ for (std::size_t i = 0 ; i < new_kinematic_joints.size (); ++i)
447
472
{
448
- l2 (static_cast <long >(i), 0 ) = new_limits[i].second [0 ];
449
- l2 (static_cast <long >(i), 1 ) = new_limits[i].second [1 ];
473
+ limits_.joint_limits (cnt, 0 ) = new_kinematic_joints[i]->limits ->lower ;
474
+ limits_.joint_limits (cnt, 1 ) = new_kinematic_joints[i]->limits ->upper ;
475
+ limits_.velocity_limits (cnt) = new_kinematic_joints[i]->limits ->velocity ;
476
+ limits_.acceleration_limits (cnt) = new_kinematic_joints[i]->limits ->acceleration ;
477
+ ++cnt;
450
478
}
451
- l << limits_, l2;
452
479
limits_ = l;
453
480
}
454
481
@@ -514,7 +541,7 @@ void OFKTStateSolver::addNode(const tesseract_scene_graph::Joint::ConstPtr& join
514
541
const std::string& joint_name,
515
542
const std::string& parent_link_name,
516
543
const std::string& child_link_name,
517
- std::vector<std::pair<std::string, std::array< double , 2 >>>& limits )
544
+ std::vector<tesseract_scene_graph::Joint::ConstPtr>& kinematic_joints )
518
545
{
519
546
OFKTNode::UPtr n;
520
547
switch (joint->type )
@@ -544,8 +571,7 @@ void OFKTStateSolver::addNode(const tesseract_scene_graph::Joint::ConstPtr& join
544
571
current_state_->joint_transforms [n->getJointName ()] = n->getWorldTransformation ();
545
572
nodes_[joint_name] = std::move (n);
546
573
joint_names_.push_back (joint_name);
547
- limits.push_back (
548
- std::make_pair (joint_name, std::array<double , 2 >({ joint->limits ->lower , joint->limits ->upper })));
574
+ kinematic_joints.push_back (joint);
549
575
break ;
550
576
}
551
577
case tesseract_scene_graph::JointType::CONTINUOUS:
@@ -560,8 +586,7 @@ void OFKTStateSolver::addNode(const tesseract_scene_graph::Joint::ConstPtr& join
560
586
current_state_->joint_transforms [n->getJointName ()] = n->getWorldTransformation ();
561
587
nodes_[joint_name] = std::move (n);
562
588
joint_names_.push_back (joint_name);
563
- limits.push_back (
564
- std::make_pair (joint_name, std::array<double , 2 >({ joint->limits ->lower , joint->limits ->upper })));
589
+ kinematic_joints.push_back (joint);
565
590
break ;
566
591
}
567
592
case tesseract_scene_graph::JointType::PRISMATIC:
@@ -576,8 +601,7 @@ void OFKTStateSolver::addNode(const tesseract_scene_graph::Joint::ConstPtr& join
576
601
current_state_->joint_transforms [n->getJointName ()] = n->getWorldTransformation ();
577
602
nodes_[joint_name] = std::move (n);
578
603
joint_names_.push_back (joint_name);
579
- limits.push_back (
580
- std::make_pair (joint_name, std::array<double , 2 >({ joint->limits ->lower , joint->limits ->upper })));
604
+ kinematic_joints.push_back (joint);
581
605
break ;
582
606
}
583
607
default :
0 commit comments