robot_conversions.cpp
Go to the documentation of this file.
1 #include "robot_conversions.h"
2 
3 #include <filesystem>
4 
6 
9 #include <RobotAPI/libraries/armem_robot_state/aron/RobotDescription.aron.generated.h>
12 
13 
14 namespace fs = ::std::filesystem;
15 
17 {
18 
19  std::optional<description::RobotDescription>
21  {
22  arondto::RobotDescription aronRobotDescription;
23  try
24  {
25  aronRobotDescription.fromAron(instance.data());
26  }
27  catch (...)
28  {
29  ARMARX_WARNING << "Conversion to RobotDescription failed!";
30  return std::nullopt;
31  }
32 
33  description::RobotDescription robotDescription{
34  .name = "",
35  .xml = ::armarx::PackagePath("", fs::path("")), // initialize empty, no default c'tor
36  .visualization = {},
37  .info = {}};
38 
39  fromAron(aronRobotDescription, robotDescription);
40 
41  return robotDescription;
42  }
43 
44  std::optional<RobotState>
46  {
47  arondto::Robot aronRobot;
48  try
49  {
50  aronRobot.fromAron(instance.data());
51  }
52  catch (...)
53  {
54  ARMARX_WARNING << "Conversion to RobotState failed!";
55  return std::nullopt;
56  }
57 
58  RobotState robotState;
59  fromAron(aronRobot.state, robotState);
60 
61  return robotState;
62  }
63 
64 } // namespace armarx::armem::robot_state
armarx::armem::robot_state::fromAron
void fromAron(const arondto::ObjectInstance &dto, RobotState &bo)
Definition: aron_conversions.cpp:27
armarx::armem::robot_state::description::RobotDescription
Definition: types.h:44
armarx::armem::wm::EntityInstance
Client-side working entity instance.
Definition: memory_definitions.h:32
armarx::armem::robot_state::RobotState
Definition: types.h:113
armarx::armem::robot_state
Definition: RobotStatePredictionClient.cpp:41
armarx::armem::human::Robot
@ Robot
Definition: util.h:17
aron_conversions.h
armarx::armem::robot_state::convertRobotDescription
std::optional< description::RobotDescription > convertRobotDescription(const armem::wm::EntityInstance &instance)
Definition: robot_conversions.cpp:20
armarx::armem::robot_state::convertRobotState
std::optional< RobotState > convertRobotState(const armem::wm::EntityInstance &instance)
Definition: robot_conversions.cpp:45
aron_conversions.h
memory_definitions.h
aron_conversions.h
armarx::armem::robot_state::description::RobotDescription::name
std::string name
Definition: types.h:48
Logging.h
robot_conversions.h
ARMARX_WARNING
#define ARMARX_WARNING
Definition: Logging.h:193
armarx::armem::base::EntityInstanceBase::data
const DataT & data() const
Definition: EntityInstanceBase.h:129
armarx::PackagePath
Definition: PackagePath.h:52