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 
40  fromAron(aronRobotDescription, robotDescription);
41 
42  return robotDescription;
43  }
44 
45  std::optional<RobotState>
47  {
48  arondto::Robot aronRobot;
49  try
50  {
51  aronRobot.fromAron(instance.data());
52  }
53  catch (...)
54  {
55  ARMARX_WARNING << "Conversion to RobotState failed!";
56  return std::nullopt;
57  }
58 
59  RobotState robotState;
60  fromAron(aronRobot.state, robotState);
61 
62  return robotState;
63  }
64 
65 } // 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:42
armarx::armem::human::Robot
@ Robot
Definition: util.h:14
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:46
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:186
armarx::armem::base::EntityInstanceBase::data
const DataT & data() const
Definition: EntityInstanceBase.h:129
armarx::PackagePath
Definition: PackagePath.h:55