test_executive_functions.cpp
Go to the documentation of this file.
00001 /*********************************************************************
00002  * Software License Agreement (BSD License)
00003  * 
00004  *  Copyright (c) 2008, Willow Garage, Inc.
00005  *  All rights reserved.
00006  * 
00007  *  Redistribution and use in source and binary forms, with or without
00008  *  modification, are permitted provided that the following conditions
00009  *  are met:
00010  * 
00011  *   * Redistributions of source code must retain the above copyright
00012  *     notice, this list of conditions and the following disclaimer.
00013  *   * Redistributions in binary form must reproduce the above
00014  *     copyright notice, this list of conditions and the following
00015  *     disclaimer in the documentation and/or other materials provided
00016  *     with the distribution.
00017  *   * Neither the name of Willow Garage nor the names of its
00018  *     contributors may be used to endorse or promote products derived
00019  *     from this software without specific prior written permission.
00020  * 
00021  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00022  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00023  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00024  *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00025  *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00026  *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00027  *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00028  *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00029  *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00030  *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00031  *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00032  *  POSSIBILITY OF SUCH DAMAGE.
00033  *
00034  * $Id$
00035  *
00036  *********************************************************************/
00037 
00038 /* Author: Wim Meeussen */
00039 
00040 #include <door_msgs/Door.h>
00041 #include <ros/node.h>
00042 #include <gtest/gtest.h>
00043 #include <door_handle_detector/door_functions.h>
00044 #include "pr2_doors_actions/executive_functions.h"
00045 
00046 using namespace ros;
00047 using namespace std;
00048 using namespace door_handle_detector;
00049 
00050 
00051 
00052 
00053 int g_argc;
00054 char** g_argv;
00055 
00056 class TestEKF : public testing::Test
00057 {
00058 public:
00059   door_msgs::Door my_door_1, my_door_2;
00060 
00061 protected:
00063   TestEKF()
00064   {
00065     my_door_1.frame_p1.x = 1.0;
00066     my_door_1.frame_p1.y = -0.5;
00067     my_door_1.frame_p2.x = 1.0;
00068     my_door_1.frame_p2.y = 0.5;
00069     my_door_1.door_p1.x = 1.0;
00070     my_door_1.door_p1.y = -0.5;
00071     my_door_1.door_p2.x = 1.0;
00072     my_door_1.door_p2.y = 0.5;
00073     my_door_1.normal.x = 1.0;
00074     my_door_1.normal.y = 0.0;
00075     my_door_1.normal.z = 0.0;
00076     my_door_1.rot_dir = door_msgs::Door::ROT_DIR_COUNTERCLOCKWISE;
00077     my_door_1.hinge = door_msgs::Door::HINGE_P2;
00078     my_door_1.header.frame_id = "base_footprint";
00079     
00080     my_door_2.frame_p1.x = -0.198;
00081     my_door_2.frame_p1.y = -1.08;
00082     my_door_2.frame_p2.x = 0.76;
00083     my_door_2.frame_p2.y = -0.82;
00084     my_door_2.door_p1.x = -0.08;
00085     my_door_2.door_p1.y = -1.12;
00086     my_door_2.door_p2.x = 0.70;
00087     my_door_2.door_p2.y = -0.87;
00088     my_door_2.normal.x = 0.29;
00089     my_door_2.normal.y = -0.95;
00090     my_door_2.normal.z = 0.0;
00091     my_door_2.rot_dir = door_msgs::Door::ROT_DIR_COUNTERCLOCKWISE;
00092     my_door_2.hinge = door_msgs::Door::HINGE_P2;
00093     my_door_2.header.frame_id = "base_footprint";
00094   }
00095   
00096 
00098   ~TestEKF()
00099   {}
00100 };
00101 
00102 
00103 
00104 
00105 TEST_F(TestEKF, test)
00106 {
00107   tf::Stamped<tf::Pose> pose;
00108 
00109   pose = getRobotPose(my_door_2, 0.6);
00110   cout << "pose = " << pose.getOrigin()[0] << ", "  <<pose.getOrigin()[1] << ", " <<pose.getOrigin()[2] << endl;
00111 
00112   pose = getGripperPose(my_door_2, M_PI/4.0, 0.4);
00113   cout << "door = " << my_door_2 << endl;
00114   cout << "pose = " << pose.getOrigin()[0] << ", "  <<pose.getOrigin()[1] << ", " <<pose.getOrigin()[2] << endl;
00115 
00116   pose = getRobotPose(my_door_1, 0.7);
00117   ASSERT_TRUE(pose.getOrigin()[0] == 0.3);
00118   ASSERT_TRUE(pose.getOrigin()[1] == 0.0);
00119   ASSERT_TRUE(pose.getOrigin()[2] == 0.0);
00120   SUCCEED();
00121 }
00122 
00123 
00124 
00125 
00126 int main(int argc, char** argv)
00127 {
00128   testing::InitGoogleTest(&argc, argv);
00129   g_argc = argc;
00130   g_argv = argv;
00131   return RUN_ALL_TESTS();
00132 }


pr2_doors_actions
Author(s): Wim Meeussen
autogenerated on Wed Dec 11 2013 14:17:44