YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
IVelocityControlTest.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2023-2023 Istituto Italiano di Tecnologia (IIT)
3 * SPDX-License-Identifier: BSD-3-Clause
4 */
5
6#ifndef IVELOCITYCONTROLTEST_H
7#define IVELOCITYCONTROLTEST_H
8
9#include <memory>
10#include <numeric>
11
14#include <yarp/os/Time.h>
15#include <catch2/catch_amalgamated.hpp>
16
17using namespace yarp::dev;
18using namespace yarp::os;
19
20namespace yarp::dev::tests
21{
23 {
24 REQUIRE(ivel != nullptr);
25 REQUIRE(icmd != nullptr);
26
27 bool b;
28 int ax;
29
30 b = ivel->getAxes(&ax);
31 CHECK(b);
32 REQUIRE(ax > 0);
33
34 for (size_t i = 0; i< ax; i++)
35 {
37 CHECK(b);
38 }
39
40 const double ref_test=1.123;
41 double ref=0;
42 b = ivel->setRefAcceleration(0, ref_test);
43 CHECK(b);
44 b = ivel->getRefAcceleration(0, &ref);
45 CHECK(b);
46 CHECK(fabs(ref-ref_test)<0.001);
47
48 b = ivel->velocityMove(0, ref_test);
49 CHECK(b);
51 b = ivel->getRefVelocity(0,&ref);
52 CHECK(b);
53 CHECK(fabs(ref - ref_test) < 0.001);
54
55 b = ivel->stop();
56 CHECK(b);
57 }
58
60 {
61 REQUIRE(ivel != nullptr);
62 REQUIRE(icmd != nullptr);
63
64 bool b;
65 int ax;
66 b = ivel->getAxes(&ax);
67 CHECK(b);
68 REQUIRE(ax > 0);
69
70 double ref = 0;
71 auto refs = std::vector<double>(ax);
72
73 for (size_t i = 0; i < ax; i++)
74 {
76 //CHECK(b); //this will fail
77 }
78
79 b = ivel->setRefAcceleration(0, ref);
80 CHECK(!b);
81 b = ivel->getRefAcceleration(0, &ref);
82 CHECK(!b);
83 b = ivel->setRefAccelerations( refs.data());
84 CHECK(!b);
85 b = ivel->getRefAccelerations( refs.data());
86 CHECK(!b);
87
88 b = ivel->velocityMove(0, ref);
89 //CHECK(!b); //this is streaming, it will return true always
90
91 b = ivel->getRefVelocity(0, &ref);
92 CHECK(!b);
93 b = ivel->getRefVelocities(refs.data());
94 CHECK(!b);
95
96 b = ivel->stop();
97 CHECK(!b);
98 }
99}
100
101#endif
constexpr yarp::conf::vocab32_t VOCAB_CM_VELOCITY
Interface for setting control mode in control board.
virtual bool setControlMode(const int j, const int mode)=0
Set the current control mode.
Interface for control boards implementing velocity control.
A mini-server for performing network communication in the background.
void exec_iVelocityControl_test_unimplemented_interface(IVelocityControl *ivel, IControlMode *icmd)
void exec_iVelocityControl_test_1(IVelocityControl *ivel, IControlMode *icmd)
For streams capable of holding different kinds of content, check what they actually have.
void delay(double seconds)
Wait for a certain number of seconds.
Definition Time.cpp:111
An interface to the operating system, including Port based communication.