YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
FrameTransformClient.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT)
3 * SPDX-License-Identifier: LGPL-2.1-or-later
4 */
5
6#ifndef YARP_DEV_FRAMETRANSFORMCLIENT_H
7#define YARP_DEV_FRAMETRANSFORMCLIENT_H
8
9
11#include <yarp/os/Network.h>
13#include <yarp/os/Semaphore.h>
14#include <yarp/os/Time.h>
15
16#include <yarp/sig/Vector.h>
17
23#include <yarp/dev/PolyDriver.h>
24
27#include <mutex>
30
33#include <mutex>
34
35#define DEFAULT_THREAD_PERIOD 20 //ms
36const int MAX_PORTS = 5;
37
56{
57private:
58 enum class ConnectionType {DISCONNECTED = 0, DIRECT, INVERSE, UNDIRECT, IDENTITY};
59
60 FrameTransformClient::ConnectionType priv_getConnectionType(const std::string &target_frame, const std::string &source_frame, std::string* commonAncestor);
61
62 bool priv_canExplicitTransform(const std::string& target_frame_id, const std::string& source_frame_id) const;
63 bool priv_getChainedTransform(const std::string &target_frame_id, const std::string &source_frame_id, yarp::sig::Matrix &transform) const;
64
65protected:
66
68 std::string m_local_name;
69 std::mutex m_rpc_mutex;
70
71 //ports to broadcast stuff...
79 std::vector<broadcast_port_t*> m_array_of_ports;
80
81 //enum to generate tf diagrams
90
91 //new stuff
96
97
98public:
101
102public:
103 // DeviceDriver methods
104 bool open(yarp::os::Searchable& config) override;
105 bool close() override;
106 bool read(yarp::os::ConnectionReader& connection) override;
107
108 //IFrameTransform
109 yarp::dev::ReturnValue allFramesAsString(std::string &all_frames) override;
110 yarp::dev::ReturnValue canTransform(const std::string &target_frame, const std::string &source_frame, bool& exists) override;
111 yarp::dev::ReturnValue clear() override;
112 yarp::dev::ReturnValue frameExists(const std::string &frame_id, bool& exists) override;
113 yarp::dev::ReturnValue getAllFrameIds(std::vector< std::string > &ids) override;
114 yarp::dev::ReturnValue getParent(const std::string &frame_id, std::string &parent_frame_id) override;
115 yarp::dev::ReturnValue getTransform(const std::string &target_frame_id, const std::string &source_frame_id, yarp::sig::Matrix &transform) override;
116 yarp::dev::ReturnValue setTransform(const std::string &target_frame_id, const std::string &source_frame_id, const yarp::sig::Matrix &transform) override;
117 yarp::dev::ReturnValue setTransformStatic(const std::string &target_frame_id, const std::string &source_frame_id, const yarp::sig::Matrix &transform) override;
118 yarp::dev::ReturnValue deleteTransform(const std::string &target_frame_id, const std::string &source_frame_id) override;
119 yarp::dev::ReturnValue transformPoint(const std::string &target_frame_id, const std::string &source_frame_id, const yarp::sig::Vector &input_point, yarp::sig::Vector &transformed_point) override;
120 yarp::dev::ReturnValue transformPose(const std::string &target_frame_id, const std::string &source_frame_id, const yarp::sig::Vector &input_pose, yarp::sig::Vector &transformed_pose) override;
121 yarp::dev::ReturnValue transformQuaternion(const std::string &target_frame_id, const std::string &source_frame_id, const yarp::math::Quaternion &input_quaternion, yarp::math::Quaternion &transformed_quaternion) override;
122 yarp::dev::ReturnValue waitForTransform(const std::string &target_frame_id, const std::string &source_frame_id, const double &timeout) override;
123
124 //PeriodicThread
125 bool threadInit() override;
126 void threadRelease() override;
127 void run() override;
128
129 //extra
130 bool priv_generate_view();
132};
133
134#endif // YARP_DEV_FRAMETRANSFORMCLIENT_H
define control board standard interfaces
const int MAX_PORTS
contains the definition of a Vector type
This class is the parameters parser for class FrameTransformClient.
frameTransformClient: A client to manage FrameTransforms for a robot (For more information,...
yarp::dev::ReturnValue getParent(const std::string &frame_id, std::string &parent_frame_id) override
Get the parent of a frame.
yarp::dev::IFrameTransformStorageUtils * m_ift_util
yarp::dev::ReturnValue transformQuaternion(const std::string &target_frame_id, const std::string &source_frame_id, const yarp::math::Quaternion &input_quaternion, yarp::math::Quaternion &transformed_quaternion) override
Transform a quaternion into the target frame.
std::string priv_get_matrix_as_text(yarp::math::FrameTransform *t)
void threadRelease() override
Release method.
yarp::dev::ReturnValue setTransformStatic(const std::string &target_frame_id, const std::string &source_frame_id, const yarp::sig::Matrix &transform) override
Register a static transform between two frames.
yarp::dev::ReturnValue deleteTransform(const std::string &target_frame_id, const std::string &source_frame_id) override
Deletes a transform between two frames.
show_transforms_in_diagram_t m_show_transforms_in_diagram
yarp::dev::ReturnValue getTransform(const std::string &target_frame_id, const std::string &source_frame_id, yarp::sig::Matrix &transform) override
Get the transform between two frames.
yarp::dev::ReturnValue getAllFrameIds(std::vector< std::string > &ids) override
Gets a vector containing all the registered frames.
void run() override
Loop function.
yarp::dev::IFrameTransformStorageSet * m_ift_set
bool open(yarp::os::Searchable &config) override
Open the DeviceDriver.
yarp::dev::ReturnValue canTransform(const std::string &target_frame, const std::string &source_frame, bool &exists) override
Test if a transform exists.
bool close() override
Close the DeviceDriver.
yarp::dev::ReturnValue waitForTransform(const std::string &target_frame_id, const std::string &source_frame_id, const double &timeout) override
Block until a transform from source_frame_id to target_frame_id is possible or it times out.
std::vector< broadcast_port_t * > m_array_of_ports
yarp::dev::ReturnValue transformPoint(const std::string &target_frame_id, const std::string &source_frame_id, const yarp::sig::Vector &input_point, yarp::sig::Vector &transformed_point) override
Transform a point into the target frame.
yarp::dev::ReturnValue clear() override
Removes all the registered transforms.
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
yarp::robotinterface::Robot m_robot
bool threadInit() override
Initialization method.
yarp::dev::ReturnValue frameExists(const std::string &frame_id, bool &exists) override
Check if a frame exists.
yarp::os::Port m_rpc_InterfaceToUser
yarp::dev::ReturnValue allFramesAsString(std::string &all_frames) override
Creates a debug string containing the list of all registered frames.
yarp::dev::IFrameTransformStorageGet * m_ift_get
yarp::dev::ReturnValue setTransform(const std::string &target_frame_id, const std::string &source_frame_id, const yarp::sig::Matrix &transform) override
Register a transform between two frames.
yarp::dev::ReturnValue transformPose(const std::string &target_frame_id, const std::string &source_frame_id, const yarp::sig::Vector &input_pose, yarp::sig::Vector &transformed_pose) override
Transform a Stamped Pose into the target frame.
Interface implemented by all device drivers.
Transform Interface.
An interface for reading from a network connection.
An abstraction for a periodic thread.
Interface implemented by all objects that can read themselves from the network, such as Bottle object...
Definition PortReader.h:24
A mini-server for network communication.
Definition Port.h:46
A base class for nested structures that can be searched.
Definition Searchable.h:31
A class for a Matrix.
Definition Matrix.h:39
enum FrameTransformClient::broadcast_port_t::format_t format