frame_conversions.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <Eigen/Core>
4 
6 
8 #include <RobotAPI/libraries/armem_locations/aron/Location.aron.generated.h>
10 
12 {
13  void
14  toGlobal(armarx::navigation::location::arondto::Location& framedLoc,
15  const Eigen::Matrix4f& framedToGlobal)
16  {
17  if (framedLoc.framedPose.header.frame == armarx::GlobalFrame)
18  {
19  // No need to change to global
20  framedLoc.framedPose.header.agent = ""; // sanity set
21  return;
22  }
23 
24  framedLoc.framedPose.pose = framedToGlobal * framedLoc.framedPose.pose;
25  framedLoc.framedPose.header.frame = armarx::GlobalFrame;
26  framedLoc.framedPose.header.agent = "";
27  }
28 
29  void
30  toGlobal(armarx::navigation::location::arondto::Location& framedLoc,
31  const armarx::objpose::ObjectPose& objPose)
32  {
33  if (framedLoc.framedPose.header.frame == armarx::GlobalFrame)
34  {
35  // No need to change to global
36  framedLoc.framedPose.header.agent = ""; // sanity set
37  return;
38  }
39 
40  if (simox::alg::starts_with(objPose.objectID.str(), framedLoc.framedPose.header.agent))
41  {
42  ARMARX_CHECK(framedLoc.framedPose.header.frame ==
43  "root"); // TODO: Right now we only allow root
44  toGlobal(framedLoc, objPose.objectPoseGlobal);
45  return;
46  }
47 
48  throw armarx::LocalException(
49  "Could not convert a framedLocation because the used object is wrong!");
50  }
51 
52 } // namespace armarx::armem::locations
armarx::armem::locations
Definition: Reader.cpp:11
armarx::GlobalFrame
const std::string GlobalFrame
Definition: FramedPose.h:62
armarx::starts_with
bool starts_with(const std::string &haystack, const std::string &needle)
Definition: StringHelpers.cpp:43
ARMARX_CHECK
#define ARMARX_CHECK(expression)
Shortcut for ARMARX_CHECK_EXPRESSION.
Definition: ExpressionException.h:82
FramedPose.h
armarx::armem::locations::toGlobal
void toGlobal(armarx::navigation::location::arondto::Location &framedLoc, const Eigen::Matrix4f &framedToGlobal)
Definition: frame_conversions.h:14
ObjectPose.h
ExpressionException.h
armarx::objpose::ObjectPose::objectID
armarx::ObjectID objectID
The object ID, i.e. dataset, class name and instance name.
Definition: ObjectPose.h:58
GfxTL::Matrix4f
MatrixXX< 4, 4, float > Matrix4f
Definition: MatrixXX.h:601
armarx::objpose::ObjectPose::objectPoseGlobal
Eigen::Matrix4f objectPoseGlobal
The object pose in the global frame.
Definition: ObjectPose.h:73
armarx::objpose::ObjectPose
An object pose as stored by the ObjectPoseStorage.
Definition: ObjectPose.h:36
armarx::ObjectID::str
std::string str() const
Return "dataset/className" or "dataset/className/instanceName".
Definition: ObjectID.cpp:55