Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test for forcetorque plugin #30

Merged
merged 17 commits into from
Aug 11, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions tests/forcetorque/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ target_link_libraries(ForceTorqueTest
add_test(NAME ForceTorqueTest
COMMAND ForceTorqueTest)

set_property(TEST ForceTorqueTest PROPERTY ENVIRONMENT YARP_DATA_DIRS=${YARP_DATA_INSTALL_DIR_FULL})

set(_env_vars)
list(APPEND _env_vars "GZ_SIM_SYSTEM_PLUGIN_PATH=$<TARGET_FILE_DIR:GazeboYarpForceTorque>")

Expand Down
14 changes: 11 additions & 3 deletions tests/forcetorque/ForceTorqueTest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ TEST(ForceTorqueTest, PluginTest)
// Instantiate test fixture
gz::sim::TestFixture fixture("../../../tests/forcetorque/model.sdf");

int iterations = 5000;
int iterations = 1000;
fixture.Server()->Run(/*_blocking=*/true, iterations, /*_paused=*/false);

yarp::os::Property option;
option.put("device","multipleanalogsensorsclient");
option.put("remote","/forcetorque");
option.put("timeout",5.0);
option.put("timeout",1.0);
option.put("local", "/ForceTorqueTest");
yarp::dev::PolyDriver driver;

Expand All @@ -36,7 +36,15 @@ TEST(ForceTorqueTest, PluginTest)
double timestamp;

isixaxis->getSixAxisForceTorqueSensorName(0, sensorName);
isixaxis->getSixAxisForceTorqueSensorMeasure(0, measure, timestamp);
//isixaxis->getSixAxisForceTorqueSensorMeasure(0, measure, timestamp);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
//isixaxis->getSixAxisForceTorqueSensorMeasure(0, measure, timestamp);

If we are not using it, let's remove it.

size_t maxNrOfReadingAttempts = 20;
bool readSuccessful = false;
for (size_t i=0; (i < maxNrOfReadingAttempts) && !readSuccessful ; i++)
{
readSuccessful = isixaxis->getSixAxisForceTorqueSensorMeasure(0, measure, timestamp);
std::this_thread::sleep_for(std::chrono::milliseconds(100));
}
ASSERT_TRUE(readSuccessful);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please avoid mixing tabs and spaces, as it may result in inconsistent rendring (the width of tabs is not constant).

Suggested change
ASSERT_TRUE(readSuccessful);
ASSERT_TRUE(readSuccessful);

//std::cerr << "The measure of FT sensor " << sensorName << " is " << measure.toString() << " at time " << timestamp << std::endl;

EXPECT_NEAR(measure(0), 0.0, 1e-2);
Expand Down