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 
28 #include <ArmarXCore/core/time.h>
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,
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* getRobotModel(const armem::robot_state::description::RobotDescription& robotDescription);
83 
84 
85  private:
86  viz::Client arviz;
87  std::optional<DebugObserverHelper> debugObserver;
88 
89  const description::Segment& descriptionSegment;
90  const proprioception::Segment& proprioceptionSegment;
91  const localization::Segment& localizationSegment;
92 
93  struct RobotModel
94  {
95  RobotModel(const std::filesystem::path& robotPath);
96 
98  RobotNameHelperPtr nameHelper;
99  };
100 
101  std::map<std::string, RobotModel> models;
102 
103  struct Properties
104  {
105  bool enabled = true;
106  float frequencyHz = 25.f;
107 
108  bool framesEnabled = false;
109  bool collisionModelEnabled = false;
110 
111  struct ForceTorque
112  {
113  bool enabled = true;
114  float forceScale = 1.F;
115  };
116 
117  ForceTorque forceTorque;
118  } p;
119 
121  };
122 
123 } // namespace armarx::armem::server::robot_state
Client.h
armarx::armem::server::robot_state::Visu::init
void init()
Definition: Visu.cpp:62
armarx::armem::robot_state::description::RobotDescription
Definition: types.h:44
armarx::armem::robot_state::Robot
Definition: types.h:126
robots
std::vector< VirtualRobot::RobotPtr > robots
Definition: VisualizationRobot.cpp:85
armarx::armem::server::robot_state::Visu::Properties::ForceTorque
Definition: Visu.h:111
DateTime.h
armarx::armem::server::robot_state::proprioception::Segment
Definition: Segment.h:47
armarx::armem::server::robot_state::localization::Segment
Definition: Segment.h:44
armarx::armem::server::robot_state::description::Segment
Definition: Segment.h:43
armarx::armem::server::robot_state::Visu::Visu
Visu(const description::Segment &descriptionSegment, const proprioception::Segment &proprioceptionSegment, const localization::Segment &localizationSegment)
Definition: Visu.cpp:31
armarx::armem::server::robot_state::proprioception::SensorValues
Definition: SensorValues.h:43
armarx::armem::server::robot_state::Visu::Properties::ForceTorque::enabled
bool enabled
Definition: Visu.h:113
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::server::robot_state::Visu::connect
void connect(const viz::Client &arviz, DebugObserverInterfacePrx debugObserver=nullptr)
Definition: Visu.cpp:67
forward_declarations.h
armarx::RobotNameHelperPtr
std::shared_ptr< class RobotNameHelper > RobotNameHelperPtr
Definition: RobotNameHelper.h:34
enabled
std::atomic< bool > * enabled
Definition: RemoteGuiWidgetController.cpp:75
TaskUtil.h
armarx::core::time::DateTime
Represents a point in time.
Definition: DateTime.h:24
DebugObserverHelper.h
armarx::Logging
Base Class for all Logging classes.
Definition: Logging.h:232
IceUtil::Handle< class PropertyDefinitionContainer >
armarx::armem::server::robot_state::Visu
Models decay of object localizations by decreasing the confidence the longer the object was not local...
Definition: Visu.h:44
IceInternal::ProxyHandle<::IceProxy::armarx::DebugObserverInterface >
time.h
Logging.h
armarx::viz::Client
Definition: Client.h:109
armarx::viz::Layer
Definition: Layer.h:12
armarx::armem::server::robot_state::Visu::defineProperties
void defineProperties(armarx::PropertyDefinitionsPtr defs, const std::string &prefix="visu.")
Definition: Visu.cpp:42
armarx::armem::server::robot_state::Visu::Properties::ForceTorque::forceScale
float forceScale
Definition: Visu.h:114
RobotNameHelper.h
VirtualRobot::RobotPtr
std::shared_ptr< class Robot > RobotPtr
Definition: Bus.h:18