ZeroMQController.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 <zmq.hpp>
44
46{
47 template <typename NJointTaskspaceController>
49 {
50 public:
52 const armarx::NJointControllerConfigPtr& config,
53 const VirtualRobot::RobotPtr& robot);
54
55 void init();
56
58
59 //overwritten for specific templates, see .cpp
60 std::string
61 getClassName(const Ice::Current& = Ice::emptyCurrent) const final
62 {
63 return "NJointZeroMQTaskspaceUnknownController";
64 }
65
66 void additionalTask() final; // This is where the magic happens
67 void onPublish(const SensorAndControl&,
69 const DebugObserverInterfacePrx&) override; // To log metrics
70
71 private:
72 zmq::context_t context; // ZeroMQ context and socket to receive controller configs
73 zmq::socket_t socket;
74
75 // Logging stuff
76 std::chrono::steady_clock::time_point time_last_packet;
77 double frequency_ms;
78 double latency_ms;
79 };
80} // 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
NJointZeroMQTaskspaceController(const armarx::RobotUnitPtr &robotUnit, const armarx::NJointControllerConfigPtr &config, const VirtualRobot::RobotPtr &robot)
std::string getClassName(const Ice::Current &=Ice::emptyCurrent) const final
int socket_t
Definition httplib.h:226
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