Skip to content

Commit

Permalink
Fix ControlBoardTorqueControlTest
Browse files Browse the repository at this point in the history
  • Loading branch information
xela-95 committed Apr 17, 2024
1 parent a901e0f commit 6c3b5f9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
10 changes: 0 additions & 10 deletions tests/controlboard/ControlBoardPositionDirectControlTest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,6 @@ class ControlBoardPositionDirectFixture : public ::testing::Test
EXPECT_NE(gz::sim::kNullEntity, modelEntity);
model = gz::sim::Model(modelEntity);

std::vector<yarp::dev::gzyarp::ControlBoardDriver*> cbDrivers
= gzyarp::testing::TestHelpers::getDevicesOfType<
yarp::dev::gzyarp::ControlBoardDriver>();
ASSERT_EQ(cbDrivers.size(), 1);
auto devicesKeys = DeviceRegistry::getHandler()->getDevicesKeys();
std::cerr << "Number of Devices: " << devicesKeys.size() << std::endl;
auto cbKey = devicesKeys.at(0);
Expand Down Expand Up @@ -162,13 +158,7 @@ TEST_F(ControlBoardPositionDirectFixture, CheckPositionTrackingUsingPendulumMode
Finalize();

int modeSet{};

int nJoints{};
iPositionDirectControl->getAxes(&nJoints);
std::cerr << "Number of joints: " << nJoints << std::endl;

ASSERT_TRUE(iControlMode->getControlMode(0, &modeSet));
std::cerr << "Control mode set: " << modeSet << std::endl;
ASSERT_TRUE(modeSet == VOCAB_CM_POSITION_DIRECT);

// Setup simulation server, this will call the post-update callbacks.
Expand Down
15 changes: 13 additions & 2 deletions tests/controlboard/ControlBoardTorqueControlTest.cc
Original file line number Diff line number Diff line change
@@ -1,18 +1,27 @@
#include <DeviceRegistry.hh>

#include <gtest/gtest-param-test.h>
#include <gtest/gtest.h>

#include <cmath>
#include <iostream>
#include <memory>
#include <string>

#include <gz/common/Console.hh>
#include <gz/math/Vector3.hh>
#include <gz/sim/Entity.hh>
#include <gz/sim/EntityComponentManager.hh>
#include <gz/sim/EventManager.hh>
#include <gz/sim/Joint.hh>
#include <gz/sim/Link.hh>
#include <gz/sim/Model.hh>
#include <gz/sim/TestFixture.hh>
#include <gz/sim/Types.hh>
#include <gz/sim/Util.hh>
#include <gz/sim/World.hh>
#include <gz/sim/components/JointForceCmd.hh>
#include <sdf/Element.hh>

#include <yarp/dev/IControlMode.h>
#include <yarp/dev/ITorqueControl.h>
Expand Down Expand Up @@ -55,7 +64,10 @@ class ControlBoardTorqueControlFixture : public testing::TestWithParam<std::stri
EXPECT_NE(gz::sim::kNullEntity, modelEntity);
model = gz::sim::Model(modelEntity);

driver = gzyarp::DeviceRegistry::getHandler()->getDevice(deviceScopedName);
auto deviceKeys = gzyarp::DeviceRegistry::getHandler()->getDevicesKeys();
ASSERT_EQ(deviceKeys.size(), 1);
driver = gzyarp::DeviceRegistry::getHandler()->getDevice(deviceKeys[0]);

ASSERT_TRUE(driver != nullptr);
iTorqueControl = nullptr;
ASSERT_TRUE(driver->view(iTorqueControl));
Expand Down Expand Up @@ -95,7 +107,6 @@ class ControlBoardTorqueControlFixture : public testing::TestWithParam<std::stri

// Get SDF model name from test parameter
gz::sim::TestFixture testFixture;
std::string deviceScopedName = "model/single_pendulum/controlboard_plugin_device";
double motorTorque{0.5};
double linkMass{1};
double linkLength{1.0};
Expand Down

0 comments on commit 6c3b5f9

Please sign in to comment.