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
17
enum
action_status_enum
18
{
19
ACTION_IDLE
= 0,
20
ACTION_START
= 1,
21
ACTION_RUNNING
= 2,
22
ACTION_STOP
= 3,
23
ACTION_RESET
= 4
24
};
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.
29
class
action_frame
30
{
31
public
:
32
size_t
counter
=0;
33
double
time
=0.0;
34
std::vector<double>
q_joints
;
35
36
public
:
37
action_frame
();
38
action_frame
(
const
action_frame
& as);
39
action_frame
&
operator=
(
const
action_frame
& as);
40
~action_frame
();
41
};
42
43
// ******************** ACTION CLASS
44
// This is an action. It has a name and a sequence of action frames.
45
class
action_class
46
{
47
public
:
48
std::string
action_name
;
49
std::string
controller_name
;
50
size_t
current_frame
;
51
bool
forever
;
52
double
speed_factor
= 1.0;
53
std::deque<action_frame>
action_frames_vector
;
54
55
action_class
();
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
65
private
:
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
LogStream.h
Log.h
Vector.h
contains the definition of a Vector type
action_class
Definition
robotAction.h:46
action_class::interpolate_action_frames
void interpolate_action_frames(double timestep)
Definition
robotAction.cpp:222
action_class::action_name
std::string action_name
Definition
robotAction.h:48
action_class::action_class
action_class()
Definition
robotAction.cpp:61
action_class::get_njoints
size_t get_njoints()
Definition
robotAction.cpp:46
action_class::current_frame
size_t current_frame
Definition
robotAction.h:50
action_class::speed_factor
double speed_factor
Definition
robotAction.h:52
action_class::openFile
bool openFile(std::string filename, size_t njoints, double timestep=-1)
Definition
robotAction.cpp:95
action_class::clear
void clear()
Definition
robotAction.cpp:53
action_class::controller_name
std::string controller_name
Definition
robotAction.h:49
action_class::action_frames_vector
std::deque< action_frame > action_frames_vector
Definition
robotAction.h:53
action_class::print
void print()
Definition
robotAction.cpp:66
action_class::forever
bool forever
Definition
robotAction.h:51
action_frame
Definition
robotAction.h:30
action_frame::~action_frame
~action_frame()
Definition
robotAction.cpp:41
action_frame::operator=
action_frame & operator=(const action_frame &as)
Definition
robotAction.cpp:29
action_frame::q_joints
std::vector< double > q_joints
Definition
robotAction.h:34
action_frame::counter
size_t counter
Definition
robotAction.h:32
action_frame::time
double time
Definition
robotAction.h:33
action_frame::action_frame
action_frame()
Definition
robotAction.cpp:18
action_status_enum
action_status_enum
Definition
robotAction.h:18
ACTION_STOP
@ ACTION_STOP
Definition
robotAction.h:22
ACTION_IDLE
@ ACTION_IDLE
Definition
robotAction.h:19
ACTION_RESET
@ ACTION_RESET
Definition
robotAction.h:23
ACTION_START
@ ACTION_START
Definition
robotAction.h:20
ACTION_RUNNING
@ ACTION_RUNNING
Definition
robotAction.h:21
YARP
3.11.100+20250603.4+gitaa77f8b5c
src
commands
yarpActionsPlayer
robotAction.h
Generated on Wed Jun 4 2025 02:39:57 for YARP by
1.9.8