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 <array>
25#include <atomic>
26#include <map>
27#include <mutex>
28#include <optional>
29#include <set>
30#include <string>
31
32#include <VirtualRobot/VirtualRobot.h>
33
38
41
49
50namespace armarx
51{
53} // namespace armarx
54
56{
57 struct ScanPoint
58 {
59 Eigen::Vector3f point;
60 float intensity;
61 };
62
63 /**
64 * @brief Models decay of object localizations by decreasing the confidence
65 * the longer the object was not localized.
66 */
67 class Visu : public armarx::Logging
68 {
69 public:
70 Visu();
71
72
74 const std::string& prefix = "visu.");
75 void init(const wm::CoreSegment* coreSegment,
76 armem::robot_state::VirtualRobotReader* virtualRobotReader);
77 void connect(const viz::Client& arviz, DebugObserverInterfacePrx debugObserver = nullptr);
78
80 const std::string& tabName);
81 void remoteGuiUpdate();
82
83
84 private:
85 void visualizeRun();
86 void visualizeOnce(const Time& timestamp);
87
88 Eigen::Isometry3f getCalibrationOffset(const std::string& sensorFrame) const;
89 void createOrUpdateCalibrationTab();
90
91 viz::Client arviz;
92 std::optional<DebugObserverHelper> debugObserver;
93
94 struct Properties
95 {
96 bool enabled = true;
97 bool uniformColor = false;
98 bool colorByIntensity = true;
99 float frequencyHz = 5;
100 int maxRobotAgeMs = 100;
101 int pointSizeInPixels = 3;
102 } p;
103
105
106 armem::robot_state::VirtualRobotReader* virtualRobotReader;
107
108 std::map<std::string, std::pair<VirtualRobot::RobotPtr, DateTime>> robots;
109
110 VirtualRobot::RobotPtr getSynchronizedRobot(const std::string& name,
111 const DateTime& timestamp);
112
113 void visualizeScan(const std::vector<ScanPoint>& points,
114 const std::string& sensorName,
115 const std::string& agentName,
116 const viz::Color& color);
117
118 std::map<std::string, armem::laser_scans::LaserScanStamped> getCurrentLaserScans();
119
120 const wm::CoreSegment* coreSegment;
121
122 // --- Extrinsic calibration via Remote GUI ---
123
124 struct SensorCalibrationData
125 {
126 float x = 0.f; // [mm]
127 float y = 0.f; // [mm]
128 float yaw = 0.f; // [deg]
129 };
130
131 // Cleared and rebuilt on each tab update. [0]=x [mm], [1]=y [mm], [2]=yaw [deg]
132 struct CalibrationTab : armarx::RemoteGui::Client::Tab
133 {
134 std::map<std::string, std::array<armarx::RemoteGui::Client::FloatSpinBox, 3>> sensors;
135 };
136
138 std::string remoteGuiTabName_;
139
140 mutable std::mutex sensorMutex_;
141 std::set<std::string> knownSensorFrames_;
142 std::map<std::string, SensorCalibrationData> calibrationData_;
143
144 CalibrationTab calibrationTab_;
145 std::atomic<bool> needsTabRebuild_{false};
146 };
147
148} // namespace armarx::armem::server::laser_scans
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:46
void connect(const viz::Client &arviz, DebugObserverInterfacePrx debugObserver=nullptr)
Definition Visu.cpp:69
void init(const wm::CoreSegment *coreSegment, armem::robot_state::VirtualRobotReader *virtualRobotReader)
Definition Visu.cpp:61
void connectRemoteGui(armarx::LightweightRemoteGuiComponentPluginUser *guiUser, const std::string &tabName)
Definition Visu.cpp:89
Represents a point in time.
Definition DateTime.h:25
std::shared_ptr< class Robot > RobotPtr
Definition Bus.h:19
This file is part of ArmarX.
armarx::core::time::DateTime Time
This file offers overloads of toIce() and fromIce() functions for STL container types.
::IceInternal::ProxyHandle<::IceProxy::armarx::DebugObserverInterface > DebugObserverInterfacePrx
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.