YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
IEncodersTimedTest.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT)
3 * SPDX-License-Identifier: BSD-3-Clause
4 */
5
6#ifndef IENCODERSTIMEDTEST_H
7#define IENCODERSTIMEDTEST_H
8
10#include <catch2/catch_amalgamated.hpp>
11
12using namespace yarp::dev;
13using namespace yarp::os;
14
15namespace yarp::dev::tests
16{
18 {
19 REQUIRE(ienc !=nullptr);
20
21 bool b;
22
23 int ax=0;
24 b = ienc->getAxes(&ax);
25 CHECK(b);
26 REQUIRE (ax > 0);
27
28 double* test_encs = new double [ax];
29 double* test_times = new double[ax];
30 b = ienc->getEncoders(test_encs);
31 //CHECK(b); //this is streaming, it will return true if data is arrived in time
32 b = ienc->getEncoderSpeeds(test_encs);
33 //CHECK(b); //this is streaming, it will return true if data is arrived in time
35 //CHECK(b); //this is streaming, it will return true if data is arrived in time
37 //CHECK(b); //this is streaming, it will return true if data is arrived in time
38
39 for (size_t i=0; i< ax; i++)
40 {
41 double val=0;
42 double time=0;
43 b = ienc->getEncoder(i,&val);
44 //CHECK(b); //this is streaming, it will return true if data is arrived in time
45 b = ienc->getEncoderSpeed(i, &val);
46 //CHECK(b); //this is streaming, it will return true if data is arrived in time
47 b = ienc->getEncoderAcceleration(i, &val);
48 //CHECK(b); //this is streaming, it will return true if data is arrived in time
49 b = ienc->getEncoderTimed(i, &val, &time);
50 //CHECK(b); //this is streaming, it will return true if data is arrived in time
51 }
52
53 double val=0;
54 b = ienc->resetEncoder(val);
55 CHECK(b);
56 b = ienc->resetEncoders();
57 CHECK(b);
58 b = ienc->setEncoder(0,val);
59 CHECK(b);
60 b = ienc->setEncoders(test_encs);
61 CHECK(b);
62
63 delete[] test_encs;
64 delete[] test_times;
65 }
66}
67
68#endif
Control board, extend encoder interface with timestamps.
virtual bool getEncodersTimed(double *encs, double *time)=0
Read the instantaneous acceleration of all axes.
virtual bool getEncoderTimed(int j, double *encs, double *time)=0
Read the instantaneous acceleration of all axes.
virtual bool getEncoderSpeed(int j, double *sp)=0
Read the istantaneous speed of an axis.
virtual bool getEncoderAccelerations(double *accs)=0
Read the instantaneous acceleration of all axes.
virtual bool setEncoder(int j, double val)=0
Set the value of the encoder for a given joint.
virtual bool getEncoder(int j, double *v)=0
Read the value of an encoder.
virtual bool resetEncoder(int j)=0
Reset encoder, single joint.
virtual bool getAxes(int *ax)=0
Get the number of controlled axes.
virtual bool setEncoders(const double *vals)=0
Set the value of all encoders.
virtual bool getEncoders(double *encs)=0
Read the position of all axes.
virtual bool getEncoderSpeeds(double *spds)=0
Read the instantaneous speed of all axes.
virtual bool getEncoderAcceleration(int j, double *spds)=0
Read the instantaneous acceleration of an axis.
virtual bool resetEncoders()=0
Reset encoders.
A mini-server for performing network communication in the background.
void exec_iEncodersTimed_test_1(IEncodersTimed *ienc)
For streams capable of holding different kinds of content, check what they actually have.
An interface to the operating system, including Port based communication.