KatanaNode.cpp
Go to the documentation of this file.
1 /*
2  * UOS-ROS packages - Robot Operating System code by the University of Osnabrück
3  * Copyright (C) 2010 University of Osnabrück
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License
7  * as published by the Free Software Foundation; either version 2
8  * of the License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18  *
19  * KatanaNode.cpp
20  *
21  * Created on: 11.12.2010
22  * Author: Martin Günther <mguenthe@uos.de>
23  */
24 
25 #include <katana/KatanaNode.h>
26 
27 namespace katana
28 {
29 
31 {
32  bool simulation;
33  std::string katana_type;
34  ros::NodeHandle pn("~");
36 
37  pn.param("simulation", simulation, false);
38 
39  if (simulation)
40  katana.reset(new SimulatedKatana());
41  else
42  {
43  bool has_katana_type = n.getParam("katana_type", katana_type);
44  if (!has_katana_type)
45  {
46  ROS_ERROR("Parameter katana_type was not set!");
47  exit(-1);
48  }
49 
50  if (katana_type == "katana_300_6m180")
51  katana.reset(new Katana300());
52  else if (katana_type == "katana_400_6m180" || katana_type == "katana_450_6m90a"
53  || katana_type == "katana_450_6m90b")
54  katana.reset(new Katana());
55  else
56  {
57  ROS_ERROR(
58  "Parameter katana_type was set to invalid value: %s; please use one of the following: katana_300_6m180, katana_400_6m180, katana_450_6m90a, katana_450_6m90b", katana_type.c_str());
59  exit(-1);
60  }
61  }
62 }
63 
65 {
66 }
67 
69 {
70  ros::Rate loop_rate(25);
71 
72  JointStatePublisher jointStatePublisher(katana);
73  JointMovementActionController jointMovementActionController(katana);
74  JointTrajectoryActionController jointTrajectoryActionController(katana);
75  KatanaGripperGraspController katanaGripperGraspController(katana);
76 
77  while (ros::ok())
78  {
79  katana->refreshEncoders();
80  jointStatePublisher.update();
81  jointTrajectoryActionController.update();
82 
83  ros::spinOnce();
84  loop_rate.sleep();
85  }
86 
87  return 0;
88 }
89 
90 }
91 
92 int main(int argc, char** argv)
93 {
94  ros::init(argc, argv, "katana");
95  katana::KatanaNode katana_node;
96 
97  katana_node.loop();
98 
99  return 0;
100 }
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
int main(int argc, char **argv)
Definition: KatanaNode.cpp:92
bool param(const std::string &param_name, T &param_val, const T &default_val) const
ROSCPP_DECL bool ok()
bool sleep()
virtual ~KatanaNode()
Definition: KatanaNode.cpp:64
Wrapper class around the KNI (Katana Native Library).
Definition: Katana.h:48
This is the node providing all publishers/services/actions relating to the Katana arm...
Definition: KatanaNode.h:48
bool getParam(const std::string &key, std::string &s) const
katana_type
ROSCPP_DECL void spinOnce()
#define ROS_ERROR(...)


katana
Author(s): Martin Günther
autogenerated on Fri Jun 7 2019 22:06:58