Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include <katana/KatanaNode.h>
00026
00027 namespace katana
00028 {
00029
00030 KatanaNode::KatanaNode()
00031 {
00032 bool simulation;
00033 std::string katana_type;
00034 ros::NodeHandle pn("~");
00035 ros::NodeHandle n;
00036
00037 pn.param("simulation", simulation, false);
00038
00039 if (simulation)
00040 katana.reset(new SimulatedKatana());
00041 else
00042 {
00043 bool has_katana_type = n.getParam("katana_type", katana_type);
00044 if (!has_katana_type)
00045 {
00046 ROS_ERROR("Parameter katana_type was not set!");
00047 exit(-1);
00048 }
00049
00050 if (katana_type == "katana_300_6m180")
00051 katana.reset(new Katana300());
00052 else if (katana_type == "katana_400_6m180" || katana_type == "katana_450_6m90a"
00053 || katana_type == "katana_450_6m90b")
00054 katana.reset(new Katana());
00055 else
00056 {
00057 ROS_ERROR(
00058 "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());
00059 exit(-1);
00060 }
00061 }
00062 }
00063
00064 KatanaNode::~KatanaNode()
00065 {
00066 }
00067
00068 int KatanaNode::loop()
00069 {
00070 ros::Rate loop_rate(25);
00071
00072 JointStatePublisher jointStatePublisher(katana);
00073 JointMovementActionController jointMovementActionController(katana);
00074 JointTrajectoryActionController jointTrajectoryActionController(katana);
00075 KatanaGripperGraspController katanaGripperGraspController(katana);
00076
00077 while (ros::ok())
00078 {
00079 katana->refreshEncoders();
00080 jointStatePublisher.update();
00081 jointTrajectoryActionController.update();
00082
00083 ros::spinOnce();
00084 loop_rate.sleep();
00085 }
00086
00087 return 0;
00088 }
00089
00090 }
00091
00092 int main(int argc, char** argv)
00093 {
00094 ros::init(argc, argv, "katana");
00095 katana::KatanaNode katana_node;
00096
00097 katana_node.loop();
00098
00099 return 0;
00100 }