YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
robotAction.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>
8#include <yarp/sig/Vector.h>
9
10#include <string>
11#include <vector>
12#include <deque>
13
14#ifndef ROBOT_ACTION_H
15#define ROBOT_ACTION_H
16
25
26// ******************** ACTION_FRAME CLASS
27// This is a frame of an action.
28// it contains: a counter, a time, a list of encoder values and a tag.
30{
31public:
32 size_t counter=0;
33 double time=0.0;
34 std::vector<double> q_joints;
35
36public:
38 action_frame(const action_frame& as);
41};
42
43// ******************** ACTION CLASS
44// This is an action. It has a name and a sequence of action frames.
46{
47public:
48 std::string action_name;
49 std::string controller_name;
51 bool forever;
52 double speed_factor = 1.0;
53 std::vector<double> m_tolerances;
54 std::deque<action_frame> action_frames_vector;
55
57
58 void clear();
59 void print();
60 bool openFile(std::string filename, size_t njoints, double timestep=-1);
61 size_t get_njoints();
62
63 //Re-interpolates the action frames with the given constant time step
64 void interpolate_action_frames(double timestep);
65
66private:
67 //internal use. Called by openFile
68 bool parseCommandLineFixTime(std::string command_line, size_t n_joints, size_t wallcount, double wallTime);
69 bool parseCommandLineVarTime(std::string command_line, size_t n_joints);
70
71 //At time t1, joints have position q1. At time t2>t1, joints have position q2.
72 //This function computes the value of joints q, at time t1<t<t2.
73 std::vector<double> interpolate_joints(const std::vector<double>& q1, const std::vector<double>& q2, double t1, double t2, double t);
74};
75
76#endif
contains the definition of a Vector type
void interpolate_action_frames(double timestep)
std::string action_name
Definition robotAction.h:48
size_t get_njoints()
size_t current_frame
Definition robotAction.h:50
double speed_factor
Definition robotAction.h:52
bool openFile(std::string filename, size_t njoints, double timestep=-1)
std::vector< double > m_tolerances
Definition robotAction.h:53
std::string controller_name
Definition robotAction.h:49
std::deque< action_frame > action_frames_vector
Definition robotAction.h:54
action_frame & operator=(const action_frame &as)
std::vector< double > q_joints
Definition robotAction.h:34
size_t counter
Definition robotAction.h:32
action_status_enum
Definition robotAction.h:18
@ ACTION_STOP
Definition robotAction.h:22
@ ACTION_IDLE
Definition robotAction.h:19
@ ACTION_RESET
Definition robotAction.h:23
@ ACTION_START
Definition robotAction.h:20
@ ACTION_RUNNING
Definition robotAction.h:21