test_base_controller.cpp
Go to the documentation of this file.
1 
2 #include <pr2_mechanism_controllers/base_controller.h>
3 #include <hardware_interface/hardware_interface.h>
5 #include <urdf/parser.h>
6 #include <ros/node.h>
7 
8 
9 int main( int argc, char** argv )
10 {
11  if(argc != 3)
12  {
13  printf("Usage: %s <robot_xml> <controller_xml>\n",argv[0]);
14  exit(-1);
15  }
16  printf("robot file:: %s, controller file:: %s\n",argv[1],argv[2]);
17 
18 
19  /*********** Create the robot model ****************/
20  pr2_mechanism::Robot *robot_model = new pr2_mechanism::Robot;
21  controller::BaseControllerNode bc;
22  HardwareInterface hw(0);
23  robot_model->hw_ = &hw;
24 
25 
26  /*********** Initialize ROS ****************/
27  ros::init(argc,argv);
28 
29  /*********** Load the robot model and state file ************/
30  char *xml_robot_file = argv[1];
31  TiXmlDocument xml(xml_robot_file); // Load robot description
32  xml.LoadFile();
33  TiXmlElement *root = xml.FirstChildElement("robot");
34  urdf::normalizeXml(root);
35  robot_model->initXml(root);
36  pr2_mechanism_model::RobotState *robot_state = new pr2_mechanism_model::RobotState(robot_model, &hw);
37 
38 
39  /*********** Load the controller file ************/
40  #error Broken because the base controller does not have initXml anymore
41  char *xml_control_file = argv[2];
42  TiXmlDocument xml_control(xml_control_file); // Load robot description
43  xml_control.LoadFile();
44  TiXmlElement *root_control = xml_control.FirstChildElement("controllers");
45  TiXmlElement *root_controller = root_control->FirstChildElement("controller");
46  //bc.initXml(robot_state,root_controller);
47 
48 
49  /************ Testing the odometry calculations themselves ******************/
50 /* NEWMAT::Matrix A(16,3);
51 
52  A.Row(1) << 10 << 8.95 << 0.05;
53  A.Row(2) << 0 << -2 << 0;
54  A.Row(3) << 1 << -0.1 << 0.01;
55  A.Row(4) << 2 << 1.1 << 0;
56 
57  A.Row(5) << 3 << 2 << -0.05;
58  A.Row(6) << 4 << 3 << 0.01;
59  A.Row(7) << 5 << 4.1 << 0.05;
60  A.Row(8) << -1 << -2 << 0.025;
61 
62  A.Row(9) << 6.15 << 5.05 << 0.01;
63  A.Row(10) << 6.985 << 6.02 << 0.01;
64  A.Row(11) << 8.01 << 8.05 << -0.05;
65  A.Row(12) << 9.03 << 8.1 << -0.01;
66 
67  A.Row(13) << -8.03 << -9.1 << 0.01;
68  A.Row(14) << -10.03 << -13.1 << 0.05;
69  A.Row(15) << -15.03 << -16.1 << -0.015;
70  A.Row(16) << -16.03 << -17.1 << -0.01;
71 
72  NEWMAT::Matrix B(16,1);
73  B << 1.1 << 1 << 1.1 << 1.15 << 0.95 << 0.99 << 0.98 << 0.95 << 1.05 << 1.1 << 1.05 << 1 << 1.13 << 0.995 << 1.035 << 1.08;
74  NEWMAT::Matrix xfit(3,1);
75 
76  xfit = bc.c_->iterativeLeastSquares(A,B,"Gaussian",10);
77  cout << "done" << xfit << endl;
78 */
79 
80  delete robot_model;
81  delete robot_state;
82 }
83 
84 
85 
86 
87 
88 
89 /*class BaseControllerTest : public testing::Test {
90  protected:
91  virtual void SetUp() {
92  }
93 
94  // virtual void TearDown() {}
95 
96  Queue<int> q0_;
97  Queue<int> q1_;
98  Queue<int> q2_;
99 };
100 
101 
102 TEST (BaseControllerTests, constructionDestruction)
103 {
104  controller::BaseController *bc = new controller::BaseController();
105  delete bc;
106 }
107 
108 TEST (BaseControllerTests, loadXML)
109 {
110  pr2_mechanism::Robot *robot = new pr2_mechanism::Robot("r2d2");
111  controller::BaseController bc;
112 
113  const string xml_controller_file = "controller_base.xml";
114  const string xml_robot_file = "pr2_base.xml"
115 
116  TiXmlDocument xml(xml_robot_file); // Load robot description
117  xml.LoadFile();
118  TiXmlElement *root = xml.FirstChildElement("robot");
119  robot->initXml(root);
120 }
121 
122 int main(int argc, char **argv)
123 {
124  testing::InitGoogleTest(&argc, argv);
125  return RUN_ALL_TESTS();
126 }
127 */
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
int main(int argc, char **argv)


pr2_mechanism_controllers
Author(s): Sachin Chita, John Hsu, Melonee Wise
autogenerated on Mon Jun 10 2019 14:26:33