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  .instance = obj.getName(),
43  .config = {.timestamp = timestamp,
44  .globalPose = Eigen::Affine3f(obj.getRootNode()->getGlobalPose()),
45  .jointMap = obj.getJointValues(),
46  .proprioception = std::nullopt},
47  .timestamp = timestamp};
48  }
49 
50  bool
52  const armem::Time& timestamp)
53  {
54 
55  ARMARX_CHECK_NOT_NULL(articulatedObject);
56 
58  convert(*articulatedObject, Time::Now());
59 
60  return store(armemArticulatedObject);
61  }
62 } // namespace armarx::armem::articulated_object
armarx::armem::robot::Robot
Definition: types.h:68
armarx::core::time::DateTime::Now
static DateTime Now()
Definition: DateTime.cpp:55
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::ArticulatedObject
armarx::armem::robot::Robot ArticulatedObject
Definition: types.h:140
armarx::armem::articulated_object::convert
armem::articulated_object::ArticulatedObject convert(const VirtualRobot::Robot &obj, const armem::Time &timestamp)
Definition: ArticulatedObjectWriter.cpp:16
armarx::armem::robot::Robot::description
RobotDescription description
Definition: types.h:70
armarx::armem::human::Robot
@ Robot
Definition: util.h:14
ARMARX_DEBUG
#define ARMARX_DEBUG
Definition: Logging.h:177
armarx::armem::articulated_object::Writer::store
bool store(const ArticulatedObject &obj) override
Definition: Writer.cpp:262
ExpressionException.h
armarx::core::time::DateTime
Represents a point in time.
Definition: DateTime.h:24
CMakePackageFinder.h
armarx::armem::robot::RobotDescription::name
std::string name
Definition: types.h:21
armarx::armem::articulated_object::ArticulatedObjectWriter::storeArticulatedObject
bool storeArticulatedObject(const VirtualRobot::RobotPtr &articulatedObject, const armem::Time &timestamp)
Definition: ArticulatedObjectWriter.cpp:51
armarx::armem::articulated_object
Definition: ArticulatedObjectReader.cpp:24
Logging.h
ArmarXDataPath.h
armarx::PackagePath
Definition: PackagePath.h:55
VirtualRobot::RobotPtr
std::shared_ptr< class Robot > RobotPtr
Definition: Bus.h:18
ArticulatedObjectWriter.h