Visu.h
Go to the documentation of this file.
1/*
2 * This file is part of ArmarX.
3 *
4 * ArmarX is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 * ArmarX is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * @author Fabian Reister ( fabian dot reister at kit dot edu )
17 * @date 2021
18 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
19 * GNU General Public License
20 */
21
22#pragma once
23
24#include <optional>
25
31
34// #include <RobotAPI/libraries/armem_objects/types.h>
36
38{
39
40 /**
41 * @brief Models decay of object localizations by decreasing the confidence
42 * the longer the object was not localized.
43 */
44 class Visu : public armarx::Logging
45 {
46 public:
47 Visu(const description::Segment& descriptionSegment,
48 const proprioception::Segment& proprioceptionSegment,
49 const localization::Segment& localizationSegment);
50
51
53 const std::string& prefix = "visu.");
54 void init();
55 void connect(const viz::Client& arviz, DebugObserverInterfacePrx debugObserver = nullptr);
56
57
58 private:
59 void visualizeRun();
60 void visualizeOnce(const core::time::DateTime& timestamp);
61
62
63 void visualizeRobots(viz::Layer& layer,
64 const armem::robot_state::Robots& robots,
65 bool useColModel = false);
66
67 static void visualizeFrames(
68 viz::Layer& layerFrames,
69 const std::unordered_map<std::string, std::vector<Eigen::Isometry3f>>& frames);
70
71 static void visualizeFramesIndividual(
72 viz::Layer& layerFrames,
73 const std::unordered_map<std::string, std::vector<Eigen::Isometry3f>>& frames);
74
75
76 void visualizeForceTorque(viz::Layer& layer,
77 const armem::robot_state::Robot& robot,
78 const proprioception::SensorValues& sensorValues);
79
80 struct RobotModel; // forward declaration
81
82 RobotModel*
83 getRobotModel(const armem::robot_state::description::RobotDescription& robotDescription);
84
85
86 private:
87 viz::Client arviz;
88 std::optional<DebugObserverHelper> debugObserver;
89
90 const description::Segment& descriptionSegment;
91 const proprioception::Segment& proprioceptionSegment;
92 const localization::Segment& localizationSegment;
93
94 struct RobotModel
95 {
96 RobotModel(const std::filesystem::path& robotPath);
97
99 RobotNameHelperPtr nameHelper;
100 };
101
102 std::map<std::string, RobotModel> models;
103
104 struct Properties
105 {
106 bool enabled = true;
107 float frequencyHz = 25.f;
108
109 bool framesEnabled = false;
110 bool collisionModelEnabled = false;
111
113 {
114 bool enabled = true;
115 float forceScale = 1.F;
116 };
117
118 ForceTorque forceTorque;
119 } p;
120
122 };
123
124} // namespace armarx::armem::server::robot_state
std::string timestamp()
Base Class for all Logging classes.
Definition Logging.h:240
IceUtil::Handle< RunningTask< T > > pointer_type
Shared pointer type for convenience.
void defineProperties(armarx::PropertyDefinitionsPtr defs, const std::string &prefix="visu.")
Definition Visu.cpp:44
void connect(const viz::Client &arviz, DebugObserverInterfacePrx debugObserver=nullptr)
Definition Visu.cpp:69
Visu(const description::Segment &descriptionSegment, const proprioception::Segment &proprioceptionSegment, const localization::Segment &localizationSegment)
Definition Visu.cpp:33
Represents a point in time.
Definition DateTime.h:25
std::shared_ptr< class Robot > RobotPtr
Definition Bus.h:19
::IceInternal::ProxyHandle<::IceProxy::armarx::DebugObserverInterface > DebugObserverInterfacePrx
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.
std::shared_ptr< class RobotNameHelper > RobotNameHelperPtr