test_ethercat_drivers.cpp
Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2013, Shadow Robot Company, All rights reserved.
00003  * 
00004  * This library is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU Lesser General Public
00006  * License as published by the Free Software Foundation; either
00007  * version 3.0 of the License, or (at your option) any later version.
00008  * 
00009  * This library is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00012  * Lesser General Public License for more details.
00013  * 
00014  * You should have received a copy of the GNU Lesser General Public
00015  * License along with this library.
00016  */
00017 
00024 #include <stdint.h>
00025 #include "sr_ronex_external_protocol/Ronex_Protocol_0x02000001_GIO_00.h"
00026 #include <ros_ethercat_hardware/ethercat_hardware.h>
00027 #include "sr_ronex_drivers/ronex_utils.hpp"
00028 #include "sr_ronex_drivers/sr_board_mk2_gio.hpp"
00029 #include "sr_ronex_hardware_interface/mk2_gio_hardware_interface.hpp"
00030 #include <ros_ethercat_model/robot_state.hpp>
00031 #include <ros/ros.h>
00032 #include <gtest/gtest.h>
00033 #include <tinyxml.h>
00034 
00035 using namespace std;
00036 using namespace ronex;
00037 
00038 TEST(RonexEthercatDrivers, build_name )
00039 {
00040   string expected = "/ronex/general_io/beautiful_ronex";
00041   string result = build_name("general_io", "beautiful_ronex");
00042   int res = expected.compare(result);
00043   ASSERT_EQ(0, res);
00044 }
00045 
00046 TEST(RonexEthercatDrivers, constructor )
00047 {
00048   const uint32_t serial = 55662211;
00049 
00050   EtherCAT_FMMU_Config fmmu(0);
00051   EtherCAT_PD_Config pdcfg(0);
00052   EtherCAT_SlaveHandler sh(0, 0, 0, serial,EC_FixedStationAddress( (uint16_t) 0 ), &fmmu, &pdcfg, 0);
00053 
00054   SrBoardMk2GIO sbm;
00055 
00056   int add = 0;
00057   sbm.construct( &sh, add );
00058 
00059   ros::NodeHandle nh;
00060   string xml_string;
00061   nh.getParam("robot_description", xml_string);
00062   TiXmlDocument urdf_xml;
00063   urdf_xml.Parse(xml_string.c_str());
00064   TiXmlElement *root = urdf_xml.FirstChildElement("robot");
00065   ros_ethercat_model::RobotState hw(root);
00066 
00067   int retsbm = sbm.initialize( static_cast<hardware_interface::HardwareInterface*>(&hw) );
00068   ASSERT_EQ(0, retsbm);
00069 }
00070 
00071 int main(int argc, char **argv)
00072 {
00073   ros::init(argc, argv, "test_ethercat_drivers_test");
00074   testing::InitGoogleTest(&argc, argv);
00075   return RUN_ALL_TESTS();
00076 }
00077 
00078 /* For the emacs weenies in the crowd.
00079 Local Variables:
00080 c-basic-offset: 2
00081 End:
00082 */


sr_ronex_drivers
Author(s): Ugo Cupcic, Toni Oliver, Mark Pitchless
autogenerated on Fri Aug 28 2015 13:12:23