GripperSetpointFactory_Test.cpp
Go to the documentation of this file.
00001 #include <iostream>
00002 #include <gtest/gtest.h>
00003 #include <boost/shared_ptr.hpp>
00004 #include <boost/make_shared.hpp>
00005 #include <boost/lexical_cast.hpp>
00006 #include "robot_instance/RobotInstanceFactory.h"
00007 #include "robot_instance/GripperSetpointFactory.h"
00008 #include <ros/package.h>
00009 
00010 using namespace std;
00011 
00012 class GripperSetpointFactoryTest : public ::testing::Test
00013 {
00014 protected:
00015     virtual void SetUp()
00016     {
00017         packagePath      = ros::package::getPath("robot_instance");
00018         configPath       = packagePath + "/test/config";
00019         configSafetyPath = packagePath + "/test/configSafety";
00020         fileName         = "TestRobotInstance.xml";
00021         instance         = RobotInstanceFactory::createRobotInstanceFromFile(configPath, configSafetyPath, fileName);
00022 
00023         gripperSetpointMap = boost::make_shared<GripperSetpointMap>();
00024     }
00025 
00026     virtual void TearDown()
00027     {
00028     }
00029 
00030     string packagePath, configPath, configSafetyPath, fileName;
00031     RobotInstancePtr instance;
00032     GripperSetpointMapPtr gripperSetpointMap;
00033 };
00034 
00035 TEST_F(GripperSetpointFactoryTest, FromFile)
00036 {
00037     string setpointFile = instance->configurationSafetyBasePath + instance->COMMAND_PATH + instance->mechanismSetpointMap["r2/right_leg/gripper/joint0"];
00038 
00039     GripperSetpointFactory::fromFile(setpointFile, gripperSetpointMap);
00040 
00041     EXPECT_EQ(3, gripperSetpointMap->size());
00042 
00043     GripperSetpoint setpoint = gripperSetpointMap->operator[]("handrail");
00044     EXPECT_FLOAT_EQ(0.50, setpoint.jawPosition);
00045     EXPECT_FLOAT_EQ(0.03, setpoint.jawPositionDelta);
00046     EXPECT_FLOAT_EQ(111,  setpoint.expectedLoad);
00047     EXPECT_FLOAT_EQ(10,   setpoint.expectedLoadDelta);
00048 
00049     setpoint = gripperSetpointMap->operator[]("seattrack");
00050     EXPECT_FLOAT_EQ(0.22, setpoint.jawPosition);
00051     EXPECT_FLOAT_EQ(0.03, setpoint.jawPositionDelta);
00052     EXPECT_FLOAT_EQ(111,  setpoint.expectedLoad);
00053     EXPECT_FLOAT_EQ(10,   setpoint.expectedLoadDelta);
00054 
00055     setpoint = gripperSetpointMap->operator[]("closed");
00056     EXPECT_FLOAT_EQ(0.0,  setpoint.jawPosition);
00057     EXPECT_FLOAT_EQ(0.03, setpoint.jawPositionDelta);
00058     EXPECT_FLOAT_EQ(289,  setpoint.expectedLoad);
00059     EXPECT_FLOAT_EQ(10,   setpoint.expectedLoadDelta);
00060 }
00061 
00062 int main(int argc, char** argv)
00063 {
00064     testing::InitGoogleTest(&argc, argv);
00065     return RUN_ALL_TESTS();
00066 }


robot_instance
Author(s):
autogenerated on Sat Jun 8 2019 20:43:12