@@ -289,14 +289,21 @@ struct Environment::Implementation
289289
290290 bool initHelper (const std::vector<std::shared_ptr<const Command>>& commands);
291291
292- void setState (const std::unordered_map<std::string, double >& joints);
292+ void setState (const std::unordered_map<std::string, double >& joints,
293+ const tesseract_common::TransformMap& floating_joints = {});
293294
294- void setState (const std::vector<std::string>& joint_names, const Eigen::Ref<const Eigen::VectorXd>& joint_values);
295+ void setState (const std::vector<std::string>& joint_names,
296+ const Eigen::Ref<const Eigen::VectorXd>& joint_values,
297+ const tesseract_common::TransformMap& floating_joints = {});
295298
296299 Eigen::VectorXd getCurrentJointValues () const ;
297300
298301 Eigen::VectorXd getCurrentJointValues (const std::vector<std::string>& joint_names) const ;
299302
303+ tesseract_common::TransformMap getCurrentFloatingJointValues () const ;
304+
305+ tesseract_common::TransformMap getCurrentFloatingJointValues (const std::vector<std::string>& joint_names) const ;
306+
300307 std::vector<std::string> getStaticLinkNames (const std::vector<std::string>& joint_names) const ;
301308
302309 void clear ();
@@ -425,7 +432,7 @@ struct Environment::Implementation
425432
426433 tesseract_scene_graph::SceneState current_state;
427434 ar& boost::serialization::make_nvp (" current_state" , current_state);
428- setState (current_state.joints );
435+ setState (current_state.joints , current_state. floating_joints );
429436
430437 // No need to serialize the contact allowed validator because it cannot be modified and is constructed internally
431438 // from the scene graph
@@ -567,16 +574,18 @@ bool Environment::Implementation::initHelper(const std::vector<std::shared_ptr<c
567574 return initialized;
568575}
569576
570- void Environment::Implementation::setState (const std::unordered_map<std::string, double >& joints)
577+ void Environment::Implementation::setState (const std::unordered_map<std::string, double >& joints,
578+ const tesseract_common::TransformMap& floating_joints)
571579{
572- state_solver->setState (joints);
580+ state_solver->setState (joints, floating_joints );
573581 currentStateChanged ();
574582}
575583
576584void Environment::Implementation::setState (const std::vector<std::string>& joint_names,
577- const Eigen::Ref<const Eigen::VectorXd>& joint_values)
585+ const Eigen::Ref<const Eigen::VectorXd>& joint_values,
586+ const tesseract_common::TransformMap& floating_joints)
578587{
579- state_solver->setState (joint_names, joint_values);
588+ state_solver->setState (joint_names, joint_values, floating_joints );
580589 currentStateChanged ();
581590}
582591
@@ -601,6 +610,21 @@ Eigen::VectorXd Environment::Implementation::getCurrentJointValues(const std::ve
601610 return jv;
602611}
603612
613+ tesseract_common::TransformMap Environment::Implementation::getCurrentFloatingJointValues () const
614+ {
615+ return current_state.floating_joints ;
616+ }
617+
618+ tesseract_common::TransformMap
619+ Environment::Implementation::getCurrentFloatingJointValues (const std::vector<std::string>& joint_names) const
620+ {
621+ tesseract_common::TransformMap fjv;
622+ for (const auto & joint_name : joint_names)
623+ fjv[joint_name] = current_state.floating_joints .at (joint_name);
624+
625+ return fjv;
626+ }
627+
604628std::vector<std::string>
605629Environment::Implementation::getStaticLinkNames (const std::vector<std::string>& joint_names) const
606630{
@@ -2427,40 +2451,44 @@ const std::string& Environment::getName() const
24272451 return std::as_const<Implementation>(*impl_).scene_graph ->getName ();
24282452}
24292453
2430- void Environment::setState (const std::unordered_map<std::string, double >& joints)
2454+ void Environment::setState (const std::unordered_map<std::string, double >& joints,
2455+ const tesseract_common::TransformMap& floating_joints)
24312456{
24322457 {
24332458 std::unique_lock<std::shared_mutex> lock (mutex_);
2434- impl_->setState (joints);
2459+ impl_->setState (joints, floating_joints );
24352460 }
24362461
24372462 std::shared_lock<std::shared_mutex> lock (mutex_);
24382463 impl_->triggerCurrentStateChangedCallbacks ();
24392464}
24402465
24412466void Environment::setState (const std::vector<std::string>& joint_names,
2442- const Eigen::Ref<const Eigen::VectorXd>& joint_values)
2467+ const Eigen::Ref<const Eigen::VectorXd>& joint_values,
2468+ const tesseract_common::TransformMap& floating_joints)
24432469{
24442470 {
24452471 std::unique_lock<std::shared_mutex> lock (mutex_);
2446- impl_->setState (joint_names, joint_values);
2472+ impl_->setState (joint_names, joint_values, floating_joints );
24472473 }
24482474
24492475 std::shared_lock<std::shared_mutex> lock (mutex_);
24502476 impl_->triggerCurrentStateChangedCallbacks ();
24512477}
24522478
2453- tesseract_scene_graph::SceneState Environment::getState (const std::unordered_map<std::string, double >& joints) const
2479+ tesseract_scene_graph::SceneState Environment::getState (const std::unordered_map<std::string, double >& joints,
2480+ const tesseract_common::TransformMap& floating_joints) const
24542481{
24552482 std::shared_lock<std::shared_mutex> lock (mutex_);
2456- return std::as_const<Implementation>(*impl_).state_solver ->getState (joints);
2483+ return std::as_const<Implementation>(*impl_).state_solver ->getState (joints, floating_joints );
24572484}
24582485
24592486tesseract_scene_graph::SceneState Environment::getState (const std::vector<std::string>& joint_names,
2460- const Eigen::Ref<const Eigen::VectorXd>& joint_values) const
2487+ const Eigen::Ref<const Eigen::VectorXd>& joint_values,
2488+ const tesseract_common::TransformMap& floating_joints) const
24612489{
24622490 std::shared_lock<std::shared_mutex> lock (mutex_);
2463- return std::as_const<Implementation>(*impl_).state_solver ->getState (joint_names, joint_values);
2491+ return std::as_const<Implementation>(*impl_).state_solver ->getState (joint_names, joint_values, floating_joints );
24642492}
24652493
24662494tesseract_scene_graph::SceneState Environment::getState () const
@@ -2543,6 +2571,19 @@ Eigen::VectorXd Environment::getCurrentJointValues(const std::vector<std::string
25432571 return std::as_const<Implementation>(*impl_).getCurrentJointValues (joint_names);
25442572}
25452573
2574+ tesseract_common::TransformMap Environment::getCurrentFloatingJointValues () const
2575+ {
2576+ std::shared_lock<std::shared_mutex> lock (mutex_);
2577+ return std::as_const<Implementation>(*impl_).getCurrentFloatingJointValues ();
2578+ }
2579+
2580+ tesseract_common::TransformMap
2581+ Environment::getCurrentFloatingJointValues (const std::vector<std::string>& joint_names) const
2582+ {
2583+ std::shared_lock<std::shared_mutex> lock (mutex_);
2584+ return std::as_const<Implementation>(*impl_).getCurrentFloatingJointValues (joint_names);
2585+ }
2586+
25462587std::string Environment::getRootLinkName () const
25472588{
25482589 std::shared_lock<std::shared_mutex> lock (mutex_);
0 commit comments