Page MenuHomec4science

OncillaL1L2Test.cpp
No OneTemporary

File Metadata

Created
Thu, Nov 14, 02:38

OncillaL1L2Test.cpp

#include <gtest/gtest.h>
#include "liboncilla/OncillaL1L2.h"
#include "liboncilla/OncillaSynchronizer.h"
using namespace nemo;
using namespace rci;
using namespace rci::oncilla;
class MockSynchronizer: public OncillaSynchronizer {
public:
MockSynchronizer() :
OncillaSynchronizer("Sync") {
}
virtual void processAsync() {
}
virtual void waitForProcessAsync() {
}
virtual void registerTrunkNode(rci::oncilla::OncillaTrunkPtr) {
}
virtual void registerL0Node(rci::oncilla::Oncilla::Leg,
rci::oncilla::OncillaL0Ptr) {
}
virtual void registerL1Node(rci::oncilla::Oncilla::Leg,
rci::oncilla::OncillaL1Ptr) {
}
virtual void registerL2Node(rci::oncilla::Oncilla::Leg,
rci::oncilla::OncillaL2Ptr) {
}
virtual void registerL3Node(rci::oncilla::Oncilla::Leg,
rci::oncilla::OncillaL3Ptr) {
}
virtual void registerL4Node(rci::oncilla::Oncilla::Leg,
rci::oncilla::OncillaL4Ptr) {
}
virtual double latestProcessLoopDurationPrimpl() const {
return 0.005;
}
virtual void switchToSynchronizationModeHook(){
}
};
class OncillaL1L2Test: public ::testing::Test {
protected:
OncillaL1L2Test() :
joint(), ja_values(), ji_values(), ja(), ji(), synchr() {
joint = OncillaL1Ptr(new OncillaL1L2(synchr, "FooBar"));
ja_values = RealVector(dim(1), 1.234);
ji_values = RealVector(dim(2), 1.234);
ji_values[1] = 2.345;
ja = JointAngles::fromRad(ja_values);
ji = JointImpedancePtr(new JointImpedance(ji_values));
}
virtual ~OncillaL1L2Test() {
}
OncillaL1Ptr joint;
RealVector ja_values, ji_values;
JointAnglesPtr ja;
JointImpedancePtr ji;
MockSynchronizer synchr;
};
TEST_F(OncillaL1L2Test, testInitialialState)
{
EXPECT_NO_THROW(joint->getLastPositionCommand());
EXPECT_EQ(0.0,joint->getLastPositionCommand()->rad());
}
TEST_F(OncillaL1L2Test, testPositionCommand)
{
EXPECT_NO_THROW(joint->getLastPositionCommand());
EXPECT_EQ(0.0,joint->getLastPositionCommand()->rad());
joint->setJointPosition(ja);
EXPECT_EQ(1.234, joint->getLastPositionCommand()->rad());
}

Event Timeline