YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
IVelocityDirectTest.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2025-2025 Istituto Italiano di Tecnologia (IIT)
3 * SPDX-License-Identifier: BSD-3-Clause
4 */
5
6#ifndef IVELOCITYDIRECTTEST_H
7#define IVELOCITYDIRECTTEST_H
8
9#include <memory>
10#include <numeric>
11#include <vector>
12
13#include <yarp/os/Time.h>
16#include <catch2/catch_amalgamated.hpp>
17#include "TestUtils.h"
18
19using namespace yarp::dev;
20using namespace yarp::os;
21
22namespace yarp::dev::tests
23{
25 {
26 REQUIRE(ivdir != nullptr);
27 REQUIRE(icmd != nullptr);
28
29 bool b=false;
30 size_t ax=0;
31
32 b = ivdir->getAxes(ax);
33 CHECK(b);
34 REQUIRE(ax != 0);
35
36 for (size_t i = 0; i < ax; i++)
37 {
39 CHECK(b);
40 wait_safe(); // Allow some time for the command to take effect
41
43 b = icmd->getControlMode(i, mode_ret);
44 CHECK(b);
46 }
47
48 {
49 double ref = 12;
50 double ref_check = 12;
51 auto refs = std::vector<double>(ax);
52 auto refs_check = std::vector<double>(ax);
53 auto joints = std::vector<int>(ax);
54 std::iota(joints.begin(), joints.end(), 0);
55
56 b = ivdir->setRefVelocity(0, ref);
57 CHECK(b);
58 wait_safe(); // Allow some time for the command to take effect
59
60 b = ivdir->getRefVelocity(0, ref);
61 CHECK(b);
62 CHECK(ref == ref_check);
63
64 std::iota(refs.begin(), refs.end(), 1.0);
65 std::iota(refs_check.begin(), refs_check.end(), 1.0);
66
67 b = ivdir->setRefVelocity(refs);
68 CHECK(b);
69 wait_safe(); // Allow some time for the command to take effect
70
71 b = ivdir->getRefVelocity(refs);
72 CHECK(b);
74
75 std::iota(refs.begin(), refs.end(), 10.0);
76 std::iota(refs_check.begin(), refs_check.end(), 10.0);
77
78 b = ivdir->setRefVelocity(joints, refs);
79 CHECK(b);
80 wait_safe(); // Allow some time for the command to take effect
81
82 b = ivdir->getRefVelocity(joints, refs);
83 CHECK(b);
85 }
86 }
87}
88
89#endif
Interface for setting control mode in control board.
virtual yarp::dev::ReturnValue getControlMode(int j, yarp::dev::ControlModeEnum &mode)=0
Get the current control mode.
virtual yarp::dev::ReturnValue setControlMode(int j, yarp::dev::SelectableControlModeEnum mode)=0
Set the current control mode.
Interface for control boards implementing direct velocity control.
A mini-server for performing network communication in the background.
bool vectors_equal(const std::vector< double > &a, const std::vector< double > &b)
Definition TestUtils.cpp:23
void wait_safe(const double seconds)
Definition TestUtils.cpp:17
void exec_iVelocityDirect_test_1(IVelocityDirect *ivdir, IControlMode *icmd)
For streams capable of holding different kinds of content, check what they actually have.
An interface to the operating system, including Port based communication.
Definition OSTestMsg.cpp:13