ArticulatedObjectWriter.cpp
Go to the documentation of this file.
2 
3 #include <Eigen/Core>
4 #include <Eigen/Geometry>
5 
6 #include <VirtualRobot/Robot.h>
7 
12 
14 {
16  convert(const VirtualRobot::Robot& obj, const armem::Time& timestamp)
17  {
18  ARMARX_DEBUG << "Filename is " << obj.getFilename();
19 
20  const std::vector<std::string> packages =
22  const std::string package = armarx::ArmarXDataPath::getProject(packages, obj.getFilename());
23 
24  // make sure that the relative path is without the 'package/' prefix
25  const std::string fileRelPath = [&obj, &package]() -> std::string
26  {
27  if (simox::alg::starts_with(obj.getFilename(), package))
28  {
29  // remove "package" + "/"
30  const std::string fixedFilename = obj.getFilename().substr(package.size() + 1, -1);
31  return fixedFilename;
32  }
33 
34  return obj.getFilename();
35  }();
36 
38  .description = {.name = obj.getType(),
39  .xml = PackagePath(
40  armarx::ArmarXDataPath::getProject({package}, fileRelPath),
41  obj.getFilename()),
42  .visualization = {},
43  .info = {}},
44  .instance = obj.getName(),
45  .config = {.timestamp = timestamp,
46  .globalPose = Eigen::Isometry3f(obj.getRootNode()->getGlobalPose()),
47  .jointMap = obj.getJointValues(),
48  .proprioception = std::nullopt},
49  .timestamp = timestamp};
50  }
51 
52  bool
54  const armem::Time& timestamp)
55  {
56 
57  ARMARX_CHECK_NOT_NULL(articulatedObject);
58 
60  convert(*articulatedObject, Time::Now());
61 
62  return store(armemArticulatedObject);
63  }
64 } // namespace armarx::armem::articulated_object
armarx::armem::robot_state::Robot
Definition: types.h:126
armarx::core::time::DateTime::Now
static DateTime Now()
Definition: DateTime.cpp:55
armarx::armem::articulated_object::Writer::store
bool store(const ArticulatedObject &obj) const override
Definition: Writer.cpp:263
armarx::CMakePackageFinder::FindAllArmarXSourcePackages
static std::vector< std::string > FindAllArmarXSourcePackages()
Definition: CMakePackageFinder.cpp:438
ARMARX_CHECK_NOT_NULL
#define ARMARX_CHECK_NOT_NULL(ptr)
This macro evaluates whether ptr is not null and if it turns out to be false it will throw an Express...
Definition: ExpressionException.h:206
armarx::ArmarXDataPath::getProject
static std::string getProject(const std::vector< std::string > &projects, const std::string &relativeFilename)
Definition: ArmarXDataPath.cpp:301
armarx::starts_with
bool starts_with(const std::string &haystack, const std::string &needle)
Definition: StringHelpers.cpp:43
armarx::armem::articulated_object::convert
armem::articulated_object::ArticulatedObject convert(const VirtualRobot::Robot &obj, const armem::Time &timestamp)
Definition: ArticulatedObjectWriter.cpp:16
armarx::armem::human::Robot
@ Robot
Definition: util.h:14
ARMARX_DEBUG
#define ARMARX_DEBUG
Definition: Logging.h:177
armarx::armem::articulated_object::ArticulatedObject
armarx::armem::robot_state::Robot ArticulatedObject
Definition: types.h:140
ExpressionException.h
armarx::core::time::DateTime
Represents a point in time.
Definition: DateTime.h:24
CMakePackageFinder.h
armarx::armem::robot_state::description::RobotDescription::name
std::string name
Definition: types.h:48
armarx::armem::articulated_object::ArticulatedObjectWriter::storeArticulatedObject
bool storeArticulatedObject(const VirtualRobot::RobotPtr &articulatedObject, const armem::Time &timestamp)
Definition: ArticulatedObjectWriter.cpp:53
armarx::armem::articulated_object
Definition: ArticulatedObjectReader.cpp:25
Logging.h
ArmarXDataPath.h
armarx::PackagePath
Definition: PackagePath.h:55
armarx::armem::robot_state::Robot::description
description::RobotDescription description
Definition: types.h:128
VirtualRobot::RobotPtr
std::shared_ptr< class Robot > RobotPtr
Definition: Bus.h:18
ArticulatedObjectWriter.h