combine.cpp
Go to the documentation of this file.
1 #include "combine.h"
2 
3 #include <sstream>
4 
6 
10 
12 {
13 
15  combine(const description::RobotDescriptionMap& robotDescriptions,
16  const localization::RobotPoseMap& globalPoses,
17  const proprioception::SensorValuesMap& sensorValues,
18  const armem::Time& timestamp)
19  {
20  std::stringstream logs;
21 
23  for (const auto& [robotName, robotDescription] : robotDescriptions)
24  {
25  // Handle missing values gracefully instead of skipping the robot altogether.
26 
27  armem::robot_state::Robot& robot = robots.emplace_back();
28 
29  robot.description = robotDescription;
30  robot.instance = ""; // TODO(fabian.reister): set this properly
31  robot.config.timestamp = timestamp;
33  robot.config.jointMap = {};
34  robot.timestamp = timestamp;
35 
36  if (auto it = globalPoses.find(robotName); it != globalPoses.end())
37  {
38  robot.config.globalPose = it->second;
39  }
40  else
41  {
42  logs << "\nNo global pose for robot '" << robotName << "'.";
43  }
44  if (auto it = sensorValues.find(robotName); it != sensorValues.end())
45  {
46  for (const auto& [name, values] : it->second.jointValueMap)
47  {
48  robot.config.jointMap.emplace(name, values.position);
49  }
50  }
51  else
52  {
53  logs << "\nNo joint positions for robot '" << robotName << "'.";
54  }
55  }
56 
57  if (not logs.str().empty())
58  {
59  // These are handled, so they are no warnings.
60  ARMARX_VERBOSE << deactivateSpam(60) << logs.str();
61  }
62 
63  return robots;
64  }
65 
66 } // namespace armarx::armem::server::robot_state
ARMARX_VERBOSE
#define ARMARX_VERBOSE
Definition: Logging.h:180
armarx::armem::robot_state::Robot
Definition: types.h:126
armarx::armem::server::robot_state::combine
armem::robot_state::Robots combine(const description::RobotDescriptionMap &robotDescriptions, const localization::RobotPoseMap &globalPoses, const proprioception::SensorValuesMap &sensorValues, const armem::Time &timestamp)
Definition: combine.cpp:15
robots
std::vector< VirtualRobot::RobotPtr > robots
Definition: VisualizationRobot.cpp:85
ProsthesisInterface.values
values
Definition: ProsthesisInterface.py:190
armarx::armem::robot_state::RobotState::jointMap
JointMap jointMap
Definition: types.h:121
combine.h
armarx::armem::robot_state::RobotState::timestamp
DateTime timestamp
Definition: types.h:118
armarx::armem::server::robot_state
Definition: RobotStateMemory.cpp:40
armarx::armem::robot_state::Robots
std::vector< Robot > Robots
Definition: forward_declarations.h:52
armarx::armem::robot_state::Robot::timestamp
DateTime timestamp
Definition: types.h:133
deactivateSpam
SpamFilterDataPtr deactivateSpam(SpamFilterDataPtr const &spamFilter, float deactivationDurationSec, const std::string &identifier, bool deactivate)
Definition: Logging.cpp:72
GfxTL::Identity
void Identity(MatrixXX< N, N, T > *a)
Definition: MatrixXX.h:523
armarx::armem::robot_state::Robot::config
RobotState config
Definition: types.h:131
armarx::armem::robot_state::RobotState::globalPose
Pose globalPose
Definition: types.h:120
types.h
armarx::armem::robot_state::Robot::instance
std::string instance
Definition: types.h:129
armarx::armem::server::robot_state::proprioception::SensorValuesMap
std::unordered_map< std::string, SensorValues > SensorValuesMap
Definition: forward_declarations.h:85
armarx::core::time::DateTime
Represents a point in time.
Definition: DateTime.h:24
armarx::armem::server::robot_state::localization::RobotPoseMap
std::unordered_map< std::string, Eigen::Isometry3f > RobotPoseMap
Definition: forward_declarations.h:73
armarx::armem::server::robot_state::description::RobotDescriptionMap
std::unordered_map< std::string, armarx::armem::robot_state::description::RobotDescription > RobotDescriptionMap
Definition: forward_declarations.h:67
Time.h
Logging.h
SensorValues.h
armarx::armem::robot_state::Robot::description
description::RobotDescription description
Definition: types.h:128