@@ -172,11 +172,24 @@ bool Environment::applyCommand(const Command& command)
172
172
}
173
173
break ;
174
174
}
175
-
176
- case tesseract_environment::CommandType::CHANGE_JOINT_LIMITS:
175
+ case tesseract_environment::CommandType::CHANGE_JOINT_POSITION_LIMITS:
176
+ {
177
+ const auto & cmd = static_cast <const tesseract_environment::ChangeJointPositionLimitsCommand&>(command);
178
+ if (!changeJointPositionLimits (cmd.getLimits ()))
179
+ return false ;
180
+ break ;
181
+ }
182
+ case tesseract_environment::CommandType::CHANGE_JOINT_VELOCITY_LIMITS:
183
+ {
184
+ const auto & cmd = static_cast <const tesseract_environment::ChangeJointVelocityLimitsCommand&>(command);
185
+ if (!changeJointVelocityLimits (cmd.getLimits ()))
186
+ return false ;
187
+ break ;
188
+ }
189
+ case tesseract_environment::CommandType::CHANGE_JOINT_ACCELERATION_LIMITS:
177
190
{
178
- const auto & cmd = static_cast <const tesseract_environment::ChangeJointLimitsCommand &>(command);
179
- if (!changeJointLimits (cmd. getJointName (), cmd.getLimits ()))
191
+ const auto & cmd = static_cast <const tesseract_environment::ChangeJointAccelerationLimitsCommand &>(command);
192
+ if (!changeJointAccelerationLimits ( cmd.getLimits ()))
180
193
return false ;
181
194
break ;
182
195
}
@@ -370,18 +383,161 @@ bool Environment::changeJointOrigin(const std::string& joint_name, const Eigen::
370
383
return true ;
371
384
}
372
385
373
- bool Environment::changeJointLimits (const std::string& joint_name, const tesseract_scene_graph::JointLimits& limits)
386
+ bool Environment::changeJointPositionLimits (const std::string& joint_name, double lower, double upper)
387
+ {
388
+ std::lock_guard<std::mutex> lock (mutex_);
389
+ tesseract_scene_graph::JointLimits::ConstPtr jl = scene_graph_->getJointLimits (joint_name);
390
+ if (jl == nullptr )
391
+ return false ;
392
+
393
+ tesseract_scene_graph::JointLimits jl_copy = *jl;
394
+ jl_copy.lower = lower;
395
+ jl_copy.upper = upper;
396
+
397
+ if (!scene_graph_->changeJointLimits (joint_name, jl_copy))
398
+ return false ;
399
+
400
+ // TODO: Only change joint limits rather than completely rebuilding kinematics
401
+ if (!manipulator_manager_->update ())
402
+ return false ;
403
+
404
+ ++revision_;
405
+ commands_.push_back (std::make_shared<ChangeJointPositionLimitsCommand>(joint_name, lower, upper));
406
+
407
+ environmentChanged ();
408
+
409
+ return true ;
410
+ }
411
+
412
+ bool Environment::changeJointPositionLimits (const std::unordered_map<std::string, std::pair<double , double > >& limits)
413
+ {
414
+ std::lock_guard<std::mutex> lock (mutex_);
415
+ for (const auto & l : limits)
416
+ {
417
+ tesseract_scene_graph::JointLimits::ConstPtr jl = scene_graph_->getJointLimits (l.first );
418
+ if (jl == nullptr )
419
+ return false ;
420
+
421
+ tesseract_scene_graph::JointLimits jl_copy = *jl;
422
+ jl_copy.lower = l.second .first ;
423
+ jl_copy.upper = l.second .second ;
424
+
425
+ if (!scene_graph_->changeJointLimits (l.first , jl_copy))
426
+ return false ;
427
+ }
428
+
429
+ // TODO: Only change joint limits rather than completely rebuilding kinematics
430
+ if (!manipulator_manager_->update ())
431
+ return false ;
432
+
433
+ ++revision_;
434
+ commands_.push_back (std::make_shared<ChangeJointPositionLimitsCommand>(limits));
435
+
436
+ environmentChanged ();
437
+
438
+ return true ;
439
+ }
440
+
441
+ bool Environment::changeJointVelocityLimits (const std::string& joint_name, double limit)
442
+ {
443
+ std::lock_guard<std::mutex> lock (mutex_);
444
+ tesseract_scene_graph::JointLimits::ConstPtr jl = scene_graph_->getJointLimits (joint_name);
445
+ if (jl == nullptr )
446
+ return false ;
447
+
448
+ tesseract_scene_graph::JointLimits jl_copy = *jl;
449
+ jl_copy.velocity = limit;
450
+
451
+ if (!scene_graph_->changeJointLimits (joint_name, jl_copy))
452
+ return false ;
453
+
454
+ // TODO: Only change joint limits rather than completely rebuilding kinematics
455
+ if (!manipulator_manager_->update ())
456
+ return false ;
457
+
458
+ ++revision_;
459
+ commands_.push_back (std::make_shared<ChangeJointVelocityLimitsCommand>(joint_name, limit));
460
+
461
+ environmentChanged ();
462
+
463
+ return true ;
464
+ }
465
+
466
+ bool Environment::changeJointVelocityLimits (const std::unordered_map<std::string, double >& limits)
467
+ {
468
+ std::lock_guard<std::mutex> lock (mutex_);
469
+ for (const auto & l : limits)
470
+ {
471
+ tesseract_scene_graph::JointLimits::ConstPtr jl = scene_graph_->getJointLimits (l.first );
472
+ if (jl == nullptr )
473
+ return false ;
474
+
475
+ tesseract_scene_graph::JointLimits jl_copy = *jl;
476
+ jl_copy.velocity = l.second ;
477
+
478
+ if (!scene_graph_->changeJointLimits (l.first , jl_copy))
479
+ return false ;
480
+ }
481
+
482
+ // TODO: Only change joint limits rather than completely rebuilding kinematics
483
+ if (!manipulator_manager_->update ())
484
+ return false ;
485
+
486
+ ++revision_;
487
+ commands_.push_back (std::make_shared<ChangeJointVelocityLimitsCommand>(limits));
488
+
489
+ environmentChanged ();
490
+
491
+ return true ;
492
+ }
493
+
494
+ bool Environment::changeJointAccelerationLimits (const std::string& joint_name, double limit)
374
495
{
375
496
std::lock_guard<std::mutex> lock (mutex_);
376
- if (!scene_graph_->changeJointLimits (joint_name, limits))
497
+ tesseract_scene_graph::JointLimits::ConstPtr jl = scene_graph_->getJointLimits (joint_name);
498
+ if (jl == nullptr )
499
+ return false ;
500
+
501
+ tesseract_scene_graph::JointLimits jl_copy = *jl;
502
+ jl_copy.acceleration = limit;
503
+
504
+ if (!scene_graph_->changeJointLimits (joint_name, jl_copy))
377
505
return false ;
378
506
379
507
// TODO: Only change joint limits rather than completely rebuilding kinematics
380
508
if (!manipulator_manager_->update ())
381
509
return false ;
382
510
383
511
++revision_;
384
- commands_.push_back (std::make_shared<ChangeJointLimitsCommand>(joint_name, limits));
512
+ commands_.push_back (std::make_shared<ChangeJointAccelerationLimitsCommand>(joint_name, limit));
513
+
514
+ environmentChanged ();
515
+
516
+ return true ;
517
+ }
518
+
519
+ bool Environment::changeJointAccelerationLimits (const std::unordered_map<std::string, double >& limits)
520
+ {
521
+ std::lock_guard<std::mutex> lock (mutex_);
522
+ for (const auto & l : limits)
523
+ {
524
+ tesseract_scene_graph::JointLimits::ConstPtr jl = scene_graph_->getJointLimits (l.first );
525
+ if (jl == nullptr )
526
+ return false ;
527
+
528
+ tesseract_scene_graph::JointLimits jl_copy = *jl;
529
+ jl_copy.acceleration = l.second ;
530
+
531
+ if (!scene_graph_->changeJointLimits (l.first , jl_copy))
532
+ return false ;
533
+ }
534
+
535
+ // TODO: Only change joint limits rather than completely rebuilding kinematics
536
+ if (!manipulator_manager_->update ())
537
+ return false ;
538
+
539
+ ++revision_;
540
+ commands_.push_back (std::make_shared<ChangeJointAccelerationLimitsCommand>(limits));
385
541
386
542
environmentChanged ();
387
543
0 commit comments