YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
controlThread.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2024 Istituto Italiano di Tecnologia (IIT)
3 * SPDX-License-Identifier: BSD-3-Clause
4 */
5
6#include <yarp/os/Log.h>
7#include <yarp/os/LogStream.h>
10#include <yarp/sig/Vector.h>
11
12#include <string>
13#include <cmath>
14#include <mutex>
15
16#include "robotDriver.h"
17#include "robotAction.h"
18#include "controlClock.h"
19
20#ifndef CONTROL_THREAD
21#define CONTROL_THREAD
22
24{
25private:
26 std::mutex m_mtx;
27 std::string m_module_name;
29 yarp::os::BufferedPort<yarp::os::Bottle> m_port_command_joints;
30
31 action_class *m_current_action = nullptr;
32 robotDriver *m_current_driver=nullptr;
34
35 //if set to true, the system will halt if home position is halted.
36 //otherwise it will continue after the timeout expires
37 bool m_home_position_strict_check_enabled = false;
38 double m_home_position_tolerance = 2.0;
39 double m_home_position_timeout = 2.0;
40
41public:
44
46 bool action_stop();
47 bool action_print();
48 bool action_reset();
49 bool action_forever();
50 bool action_start();
51 bool action_change(action_class *action, robotDriver *driver);
52 bool action_getname(std::string& name);
53 bool action_setSpeedFactor(double factor = 1);
54 bool action_resample(double value);
55
56 ControlThread(std::string name, double period);
58 bool threadInit() override;
59 void run() override;
60
61 void setPositionTolerance(double tolerance);
62 void setPositionTimeout(double timeloops);
63 void setPositionStrictCheck(bool enable);
64
65private:
66 bool execute_joint_command(int frame_id);
67 void compute_and_send_command(int frame_id);
68};
69
70#endif
contains the definition of a Vector type
bool threadInit() override
Initialization method.
bool action_getname(std::string &name)
void setPositionStrictCheck(bool enable)
bool m_enable_execute_joint_command
void run() override
Loop function.
action_status_enum getStatus()
bool action_resample(double value)
bool action_setSpeedFactor(double factor=1)
void setPositionTolerance(double tolerance)
bool action_change(action_class *action, robotDriver *driver)
ControlClock m_clock
void setPositionTimeout(double timeloops)
A mini-server for performing network communication in the background.
An abstraction for a periodic thread.
action_status_enum
Definition robotAction.h:18
@ ACTION_IDLE
Definition robotAction.h:19