22 #include <robottestingframework/dll/Plugin.h>
23 #include <robottestingframework/TestAssert.h>
25 #include <yarp/os/Time.h>
27 #include "FtSensorTest.h"
30 using namespace robottestingframework;
31 using namespace yarp::os;
32 using namespace yarp::sig;
37 FtSensorTest::FtSensorTest() : yarp::robottestingframework::TestCase(
"FtSensorTest") {
40 FtSensorTest::~FtSensorTest() { }
42 bool FtSensorTest::setup(yarp::os::Property &configuration) {
44 if(configuration.check(
"name"))
45 setName(configuration.find(
"name").asString());
47 ROBOTTESTINGFRAMEWORK_ASSERT_ERROR_IF_FALSE(configuration.check(
"portname"),
48 "Missing 'portname' parameter");
49 portname = configuration.find(
"portname").asString();
51 ROBOTTESTINGFRAMEWORK_ASSERT_ERROR_IF_FALSE(port.open(
"/iCubTest/FTsensor"),
52 "opening port, is YARP network working?");
54 ROBOTTESTINGFRAMEWORK_TEST_REPORT(Asserter::format(
"connecting from %s to %s\n",
55 port.getName().c_str(), portname.c_str()));
57 ROBOTTESTINGFRAMEWORK_ASSERT_ERROR_IF_FALSE(Network::connect(portname, port.getName()),
58 Asserter::format(
"could not connect to remote port %s, FT sensor unavailable",
63 void FtSensorTest::tearDown() {
65 Network::disconnect(portname, port.getName());
69 void FtSensorTest::run() {
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");
74 ROBOTTESTINGFRAMEWORK_TEST_FAIL_IF_FALSE(readSensor->size() == 6,
"sensor has 6 values");
Check if a FT sensor port is correctly publishing a vector with 6 values.