scene_state.cpp
Go to the documentation of this file.
1 
33 #include <boost/serialization/access.hpp>
34 #include <boost/serialization/map.hpp>
35 #include <boost/serialization/nvp.hpp>
36 #include <boost/serialization/unordered_map.hpp>
38 
40 #include <tesseract_common/utils.h>
42 
43 namespace tesseract_scene_graph
44 {
45 Eigen::VectorXd SceneState::getJointValues(const std::vector<std::string>& joint_names) const
46 {
47  Eigen::VectorXd jv;
48  jv.resize(static_cast<long int>(joint_names.size()));
49  for (auto j = 0U; j < joint_names.size(); ++j)
50  jv(j) = joints.at(joint_names[j]);
51 
52  return jv;
53 }
54 
55 tesseract_common::TransformMap SceneState::getFloatingJointValues(const std::vector<std::string>& joint_names) const
56 {
58  for (const auto& joint_name : joint_names)
59  fjv[joint_name] = floating_joints.at(joint_name);
60 
61  return fjv;
62 }
63 
64 bool SceneState::operator==(const SceneState& rhs) const
65 {
66  auto isometry_equal = [](const Eigen::Isometry3d& iso_1, const Eigen::Isometry3d& iso_2) {
67  return iso_1.isApprox(iso_2, 1e-5);
68  };
69 
70  using namespace tesseract_common;
71  bool equal = true;
72  equal &= isIdenticalMap<std::unordered_map<std::string, double>, double>(joints, rhs.joints);
73  equal &= isIdenticalMap<TransformMap, Eigen::Isometry3d>(floating_joints, rhs.floating_joints, isometry_equal);
74  equal &= isIdenticalMap<TransformMap, Eigen::Isometry3d>(link_transforms, rhs.link_transforms, isometry_equal);
75  equal &= isIdenticalMap<TransformMap, Eigen::Isometry3d>(joint_transforms, rhs.joint_transforms, isometry_equal);
76 
77  return equal;
78 }
79 bool SceneState::operator!=(const SceneState& rhs) const { return !operator==(rhs); }
80 
81 template <class Archive>
82 void SceneState::serialize(Archive& ar, const unsigned int /*version*/)
83 {
84  ar& BOOST_SERIALIZATION_NVP(joints);
85  ar& BOOST_SERIALIZATION_NVP(floating_joints);
86  ar& BOOST_SERIALIZATION_NVP(link_transforms);
87  ar& BOOST_SERIALIZATION_NVP(joint_transforms);
88 }
89 
90 } // namespace tesseract_scene_graph
91 
94 BOOST_CLASS_EXPORT_IMPLEMENT(tesseract_scene_graph::SceneState)
tesseract_scene_graph::SceneState::floating_joints
tesseract_common::TransformMap floating_joints
The floating joint values used for calculating the joint and link transforms.
Definition: scene_state.h:74
tesseract_common
utils.h
tesseract_common::TransformMap
AlignedMap< std::string, Eigen::Isometry3d > TransformMap
TESSERACT_SERIALIZE_ARCHIVES_INSTANTIATE
#define TESSERACT_SERIALIZE_ARCHIVES_INSTANTIATE(Type)
TESSERACT_COMMON_IGNORE_WARNINGS_PUSH
#define TESSERACT_COMMON_IGNORE_WARNINGS_PUSH
tesseract_scene_graph::SceneState
This holds a state of the scene.
Definition: scene_state.h:59
tesseract_scene_graph::SceneState::serialize
void serialize(Archive &ar, const unsigned int version)
Definition: scene_state.cpp:82
tesseract_scene_graph::SceneState::getFloatingJointValues
tesseract_common::TransformMap getFloatingJointValues(const std::vector< std::string > &joint_names) const
Definition: scene_state.cpp:55
serialization.h
tesseract_scene_graph::SceneState::joints
std::unordered_map< std::string, double > joints
The joint values used for calculating the joint and link transforms.
Definition: scene_state.h:71
tesseract_scene_graph::SceneState::operator==
bool operator==(const SceneState &rhs) const
Definition: scene_state.cpp:64
tesseract_scene_graph::SceneState::operator!=
bool operator!=(const SceneState &rhs) const
Definition: scene_state.cpp:79
tesseract_scene_graph::SceneState::joint_transforms
tesseract_common::TransformMap joint_transforms
The joint transforms in world coordinate system.
Definition: scene_state.h:80
TESSERACT_COMMON_IGNORE_WARNINGS_POP
#define TESSERACT_COMMON_IGNORE_WARNINGS_POP
tesseract_scene_graph::SceneState::getJointValues
Eigen::VectorXd getJointValues(const std::vector< std::string > &joint_names) const
Definition: scene_state.cpp:45
scene_state.h
This holds a state of the scene.
tesseract_scene_graph::SceneState::link_transforms
tesseract_common::TransformMap link_transforms
The link transforms in world coordinate system.
Definition: scene_state.h:77
macros.h
tesseract_scene_graph
Definition: fwd.h:32
eigen_serialization.h


tesseract_scene_graph
Author(s): Levi Armstrong
autogenerated on Sun May 18 2025 03:01:49