simple_joints_move.cpp
Go to the documentation of this file.
00001 #include <ros/ros.h>
00002 #include <iri_wam_common_msgs/joints_move.h>
00003 #include <actionlib/client/simple_action_client.h>
00004 
00005 
00006 class RobotArm
00007 {
00008 private:
00009   // Action client for the joint trajectory action 
00010   // used to trigger the arm movement action
00011   ros::NodeHandle n;
00012   ros::ServiceClient client;
00013   std::string srv_name_;
00014 
00015 public:
00017   RobotArm():srv_name_("/iri_wam_controller/joints_move")
00018   {
00019     client = n.serviceClient<iri_wam_common_msgs::joints_move>(this->srv_name_.c_str());
00020   }
00021 
00023   ~RobotArm()
00024   {
00025   }
00026 
00028   bool startJointsMove(iri_wam_common_msgs::joints_move srv)
00029   {
00030           if (!this->client.call(srv))
00031           {
00032                   ROS_ERROR("Failed to call service %s", this->srv_name_.c_str());
00033                   return false;
00034           }
00035         return true;
00036   }
00037 
00039   //  (0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0)
00040   iri_wam_common_msgs::joints_move armAtHomePosition()
00041   {
00042     //our Joints move position variable
00043     iri_wam_common_msgs::joints_move srv;
00044     srv.request.joints.resize(7);
00045     srv.request.velocities.resize(7);
00046     srv.request.accelerations.resize(7);
00047     srv.request.joints[0] = 0.0;
00048     srv.request.joints[1] = 0.0;
00049     srv.request.joints[2] = 0.0;
00050     srv.request.joints[3] = 0.0;
00051     srv.request.joints[4] = 0.0;
00052     srv.request.joints[5] = 0.0;
00053     srv.request.joints[6] = 0.0;
00054     srv.request.velocities[0] = 0.0;
00055     srv.request.velocities[1] = 0.0;
00056     srv.request.velocities[2] = 0.0;
00057     srv.request.velocities[3] = 0.0;
00058     srv.request.velocities[4] = 0.0;
00059     srv.request.velocities[5] = 0.0;
00060     srv.request.velocities[6] = 0.0;
00061     srv.request.accelerations[0] = 0.0;
00062     srv.request.accelerations[1] = 0.0;
00063     srv.request.accelerations[2] = 0.0;
00064     srv.request.accelerations[3] = 0.0;
00065     srv.request.accelerations[4] = 0.0;
00066     srv.request.accelerations[5] = 0.0;
00067     srv.request.accelerations[6] = 0.0;
00068 
00069     return srv;
00070   }
00071 
00072   iri_wam_common_msgs::joints_move armAtInitialPosition()
00073   {
00074     //our Joints move position variable
00075     iri_wam_common_msgs::joints_move srv;
00076     srv.request.joints.resize(7);
00077     srv.request.velocities.resize(7);
00078     srv.request.accelerations.resize(7);
00079     srv.request.joints[0] = 0.0;
00080     srv.request.joints[1] = 0.0;
00081     srv.request.joints[2] = 0.0;
00082     srv.request.joints[3] = 2.0;
00083     srv.request.joints[4] = 0.0;
00084     srv.request.joints[5] = 0.0;
00085     srv.request.joints[6] = 0.0;
00086     srv.request.velocities[0] = 0.0;
00087     srv.request.velocities[1] = 0.0;
00088     srv.request.velocities[2] = 0.0;
00089     srv.request.velocities[3] = 0.0;
00090     srv.request.velocities[4] = 0.0;
00091     srv.request.velocities[5] = 0.0;
00092     srv.request.velocities[6] = 0.0;
00093     srv.request.accelerations[0] = 0.0;
00094     srv.request.accelerations[1] = 0.0;
00095     srv.request.accelerations[2] = 0.0;
00096     srv.request.accelerations[3] = 0.0;
00097     srv.request.accelerations[4] = 0.0;
00098     srv.request.accelerations[5] = 0.0;
00099     srv.request.accelerations[6] = 0.0;
00100 
00101     return srv;
00102   }
00103  
00104 };
00105 
00106 int main(int argc, char** argv)
00107 {
00108   // Init the ROS node
00109   ros::init(argc, argv, "robot_driver");
00110 
00111   RobotArm arm;
00112 
00113   // Start the trajectory
00114   arm.startJointsMove(arm.armAtHomePosition());
00115   arm.startJointsMove(arm.armAtInitialPosition());
00116   
00117 }
00118 


iri_wam_controller
Author(s): galenya
autogenerated on Fri Dec 6 2013 20:08:29