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,
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
32 robot.config.globalPose = Eigen::Isometry3f::Identity();
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
std::string timestamp()
SpamFilterDataPtr deactivateSpam(SpamFilterDataPtr const &spamFilter, float deactivationDurationSec, const std::string &identifier, bool deactivate)
Definition Logging.cpp:75
#define ARMARX_VERBOSE
The logging level for verbose information.
Definition Logging.h:187
std::unordered_map< std::string, armarx::armem::robot_state::description::RobotDescription > RobotDescriptionMap
std::unordered_map< std::string, Eigen::Isometry3f > RobotPoseMap
std::unordered_map< std::string, SensorValues > SensorValuesMap
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
armarx::core::time::DateTime Time
description::RobotDescription description
Definition types.h:128