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::deque<action_frame> action_frames_vector;
54
56
57 void clear();
58 void print();
59 bool openFile(std::string filename, size_t njoints, double timestep=-1);
60 size_t get_njoints();
61
62 //Re-interpolates the action frames with the given constant time step
63 void interpolate_action_frames(double timestep);
64
65private:
66 //internal use. Called by openFile
67 bool parseCommandLineFixTime(std::string command_line, size_t n_joints, size_t wallcount, double wallTime);
68 bool parseCommandLineVarTime(std::string command_line, size_t n_joints);
69
70 //At time t1, joints have position q1. At time t2>t1, joints have position q2.
71 //This function computes the value of joints q, at time t1<t<t2.
72 std::vector<double> interpolate_joints(const std::vector<double>& q1, const std::vector<double>& q2, double t1, double t2, double t);
73};
74
75#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::string controller_name
Definition robotAction.h:49
std::deque< action_frame > action_frames_vector
Definition robotAction.h:53
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