Page MenuHomec4science

OncillaL1L2Test.cpp
No OneTemporary

File Metadata

Created
Sat, Nov 9, 14:19

OncillaL1L2Test.cpp

#include <gtest/gtest.h>
#include <liboncilla/nodes/L1L2.h>
#include "liboncilla/Synchronizer.h"
using namespace nemo;
using namespace rci;
using namespace rci::oncilla;
class MockSynchronizer: public ::rci::oncilla::Synchronizer {
public:
MockSynchronizer() :
Synchronizer("Sync") {
}
virtual void ProcessAsyncPrimpl() {
}
virtual void WaitForProcessAsyncPrimpl() {
}
virtual double lastProcessTimeStep() const {
return 0.005;
}
virtual void switchToSynchronizationModeHook(){
}
};
class OncillaL1L2Test: public ::testing::Test {
protected:
OncillaL1L2Test() :
joint(), ja_values(), ji_values(), ja(), ji(), synchr() {
joint = rci::oncilla::L1::Ptr(new L1(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() {
}
rci::oncilla::L1L2::Ptr 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