ZenohController.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 * @package ...
17 * @author Andre Meixner ( andre dot meixner at kit dot edu )
18 * @date 2024
19 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20 * GNU General Public License
21 */
22
23#pragma once
24
25#include <string>
26
27#include <Ice/Object.h>
28
29#include <SimoxUtility/math/convert/mat3f_to_quat.h>
30#include <SimoxUtility/math/convert/mat4f_to_pos.h>
31#include <SimoxUtility/math/convert/mat4f_to_quat.h>
32#include <SimoxUtility/math/convert/pos_quat_to_mat4f.h>
33#include <VirtualRobot/VirtualRobot.h>
34
35#include <ArmarXCore/interface/core/UserException.h>
36#include <ArmarXCore/interface/observers/ObserverInterface.h>
37#include <ArmarXCore/interface/serialization/Eigen/Eigen_fdi.h>
38
41#include <RobotAPI/interface/units/RobotUnit/NJointController.h>
42
43//#include <zenoh.h>
44#include <zenoh.hxx>
45#include <zenoh/api/subscriber.hxx>
46
48{
49 template <typename NJointTaskspaceController>
51 {
52 public:
54 const armarx::NJointControllerConfigPtr& config,
55 const VirtualRobot::RobotPtr& robot);
56
57 void init();
58
60 void updateConfigZenoh(const zenoh::Sample& sample);
61
62 //overwritten for specific templates, see .cpp
63 std::string
64 getClassName(const Ice::Current& = Ice::emptyCurrent) const final
65 {
66 return "NJointZenohTaskspaceUnknownController";
67 }
68
69 void additionalTask() final; // This is where the magic happens
70 void onPublish(const SensorAndControl&,
72 const DebugObserverInterfacePrx&) override; // To log metrics
73
74 private:
75 /// Test for zenoh communication
76 std::string _connect_endpoint = "tcp/10.6.0.248:7447";
77 std::string _state_key = "realtime/state";
78 std::string _config_key = "realtime/config";
79 std::string _config_json = "";
80
81 std::unique_ptr<zenoh::Session> _session;
82 std::unique_ptr<zenoh::Publisher> _publisher;
83 // std::unique_ptr<zenoh::Subscriber> _subscriber;
84
85 // Logging stuff
86 std::chrono::steady_clock::time_point time_last_packet;
87 double frequency_ms;
88 double latency_ms;
89 };
90} // namespace armarx::control::njoint_controller::task_space
NJointTaskspaceController(const RobotUnitPtr &robotUnit, const NJointControllerConfigPtr &config, const VirtualRobot::RobotPtr &)
Definition Base.cpp:138
void onPublish(const SensorAndControl &, const DebugDrawerInterfacePrx &, const DebugObserverInterfacePrx &) override
std::string getClassName(const Ice::Current &=Ice::emptyCurrent) const final
NJointZenohTaskspaceController(const armarx::RobotUnitPtr &robotUnit, const armarx::NJointControllerConfigPtr &config, const VirtualRobot::RobotPtr &robot)
std::shared_ptr< class Robot > RobotPtr
Definition Bus.h:19
::IceInternal::ProxyHandle<::IceProxy::armarx::DebugObserverInterface > DebugObserverInterfacePrx
IceUtil::Handle< class RobotUnit > RobotUnitPtr
Definition FTSensor.h:34
::IceInternal::ProxyHandle<::IceProxy::armarx::DebugDrawerInterface > DebugDrawerInterfacePrx
detail::ControlThreadOutputBufferEntry SensorAndControl