icub-test
Loading...
Searching...
No Matches
Public Member Functions
FtSensorTest Class Reference

Check if a FT sensor port is correctly publishing a vector with 6 values. More...

#include <FtSensorTest.h>

Inherits yarp::robottestingframework::TestCase.

Public Member Functions

virtual bool setup (yarp::os::Property &configuration)
 
virtual void tearDown ()
 
virtual void run ()
 

Detailed Description

Check if a FT sensor port is correctly publishing a vector with 6 values.

No further check on the content of the vector is done.

Accepts the following parameters:

Parameter name Type Units Default Value Required Description Notes
name string - "FtSensorTest" No The name of the test. -
portname string - - Yes The yarp port name of the FT sensor to test. -

Definition at line 41 of file FtSensorTest.h.

Constructor & Destructor Documentation

◆ FtSensorTest()

FtSensorTest::FtSensorTest ( )

Definition at line 37 of file FtSensorTest.cpp.

37 : yarp::robottestingframework::TestCase("FtSensorTest") {
38}

◆ ~FtSensorTest()

FtSensorTest::~FtSensorTest ( )
virtual

Definition at line 40 of file FtSensorTest.cpp.

40{ }

Member Function Documentation

◆ run()

void FtSensorTest::run ( )
virtual

Definition at line 69 of file FtSensorTest.cpp.

69 {
70 ROBOTTESTINGFRAMEWORK_TEST_REPORT("Reading FT sensors...");
71 Vector *readSensor = port.read();
72 ROBOTTESTINGFRAMEWORK_TEST_FAIL_IF_FALSE(readSensor, "could not read FT data from sensor");
73
74 ROBOTTESTINGFRAMEWORK_TEST_FAIL_IF_FALSE(readSensor->size() == 6, "sensor has 6 values");
75}

◆ setup()

bool FtSensorTest::setup ( yarp::os::Property &  configuration)
virtual

Definition at line 42 of file FtSensorTest.cpp.

42 {
43 // initialization goes here ...
44 if(configuration.check("name"))
45 setName(configuration.find("name").asString());
46
47 ROBOTTESTINGFRAMEWORK_ASSERT_ERROR_IF_FALSE(configuration.check("portname"),
48 "Missing 'portname' parameter");
49 portname = configuration.find("portname").asString();
50
51 ROBOTTESTINGFRAMEWORK_ASSERT_ERROR_IF_FALSE(port.open("/iCubTest/FTsensor"),
52 "opening port, is YARP network working?");
53
54 ROBOTTESTINGFRAMEWORK_TEST_REPORT(Asserter::format("connecting from %s to %s\n",
55 port.getName().c_str(), portname.c_str()));
56
57 ROBOTTESTINGFRAMEWORK_ASSERT_ERROR_IF_FALSE(Network::connect(portname, port.getName()),
58 Asserter::format("could not connect to remote port %s, FT sensor unavailable",
59 portname.c_str()));
60 return true;
61}

◆ tearDown()

void FtSensorTest::tearDown ( )
virtual

Definition at line 63 of file FtSensorTest.cpp.

63 {
64 // finalization goes here ...
65 Network::disconnect(portname, port.getName());
66 port.close();
67}

The documentation for this class was generated from the following files: