stick.cpp
Go to the documentation of this file.
00001 #include <ros/ros.h>
00002 #include <kdl/frames.hpp>
00003 #include <arm_navigation_msgs/CollisionObject.h>
00004 #include <arm_navigation_msgs/Shape.h>
00005 
00006 int main(int argc, char** argv) {
00007   
00008   ros::init(argc, argv, "vertical_stick");
00009 
00010   ros::NodeHandle nh("~");
00011 
00012   ros::Publisher object_in_map_pub_;
00013   object_in_map_pub_  = nh.advertise<arm_navigation_msgs::CollisionObject>("collision_object", 10);
00014   
00015   XmlRpc::XmlRpcValue val1;
00016   double rad,length;
00017   bool rpy,quatern;
00018   /*nh.getParam("rpy",val1); 
00019   rpy=(bool)val1;
00020   nh.getParam("quaternion",val1); 
00021   quatern=(bool)val1;
00022   ROS_ERROR_STREAM("RPY "<<rpy);*/
00023   
00024   nh.param<bool>("rpy", rpy, false);
00025   nh.param<bool>("quaternion", quatern, false);
00026   nh.param<double>("radius", rad, 0.01);
00027   nh.param<double>("length", rad, 0.01);
00028   
00029   double tx,ty,tz,qx,qy,qz,qw;
00030   
00031   nh.param<double>("posicion_x", tx, 0.01);
00032   ROS_WARN_STREAM("posicion_x: "<<tx); 
00033   
00034   nh.param<double>("posicion_y", ty, 0.01);
00035   ROS_WARN_STREAM("posicion_y: "<<ty); 
00036   
00037   nh.param<double>("posicion_z", tz, 0.01);
00038   ROS_WARN_STREAM("posicion_z: "<<tz); 
00039   
00040   if(quatern){
00041           nh.param<double>("rotacion_x", qx, 0.01);
00042           ROS_WARN_STREAM("rotacion_x: "<<qx); 
00043           
00044           nh.param<double>("rotacion_y", qy, 0.01);
00045           ROS_WARN_STREAM("rotacion_y: "<<qy); 
00046           
00047           nh.param<double>("rotacion_z", qz, 0.01);
00048           ROS_WARN_STREAM("rotacion_z: "<<qz); 
00049           
00050           nh.param<double>("rotacion_w", qw, 0.01);
00051           ROS_WARN_STREAM("rotacion_w: "<<qw); 
00052   }
00053   else if(rpy)
00054   {
00055         double r,p,y;
00056           nh.param<double>("roll", r, 0.01);
00057           ROS_WARN_STREAM("Roll: "<<r); 
00058           
00059           nh.param<double>("pitch", p, 0.01);
00060           ROS_WARN_STREAM("Pitch: "<<p); 
00061           
00062           nh.param<double>("yaw", y, 0.01);
00063           ROS_WARN_STREAM("Yaw: "<<y); 
00064           
00065           KDL::Rotation handRotation= KDL::Rotation::RPY(r,p,y);
00066       handRotation.GetQuaternion(qx,qy,qz,qw);
00067       ROS_WARN_STREAM("rotacion_x: "<<qx); 
00068       ROS_WARN_STREAM("rotacion_y: "<<qy); 
00069       ROS_WARN_STREAM("rotacion_z: "<<qz); 
00070       ROS_WARN_STREAM("rotacion_w: "<<qw); 
00071   }
00072   
00073   std::string name_frame;
00074   nh.param<std::string>("name_obstacle", name_frame, "loool");
00075   ROS_WARN_STREAM("name_obstacle: "<<name_frame);   
00076 
00077   //add the cylinder into the collision space
00078   arm_navigation_msgs::CollisionObject cylinder_object;
00079   cylinder_object.id = "/"+name_frame;
00080   cylinder_object.operation.operation = arm_navigation_msgs::CollisionObjectOperation::ADD;
00081   cylinder_object.header.frame_id = "/world";
00082   cylinder_object.header.stamp = ros::Time::now();
00083   arm_navigation_msgs::Shape object;
00084   object.type = arm_navigation_msgs::Shape::CYLINDER;
00086 // the origin of each shape is considered at the shape's center
00087 
00088 // for sphere
00089 // radius := dimensions[0]
00090 
00091 //for cylinder
00092 // radius := dimensions[0]
00093 // length := dimensions[1]
00094 // the length is along the Z axis
00095 
00096 // for box
00097 // size_x := dimensions[0]
00098 // size_y := dimensions[1]
00099 // size_z := dimensions[2]
00100 
00101   object.dimensions.resize(2);
00102   object.dimensions[0] = rad;
00103   object.dimensions[1] = length;
00104   geometry_msgs::Pose pose;
00105   pose.position.x = tx;
00106   pose.position.y = ty;
00107   pose.position.z = tz;
00108   pose.orientation.x = qx;
00109   pose.orientation.y = qy;
00110   pose.orientation.z = qz;
00111   pose.orientation.w = qw;
00112   cylinder_object.shapes.push_back(object);
00113   cylinder_object.poses.push_back(pose);
00114 
00115   object_in_map_pub_.publish(cylinder_object);
00116 
00117   ROS_INFO("Should have published");
00118   ros::Duration(5.0).sleep();
00119   ros::shutdown();
00120 }


iri_wam_arm_navigation
Author(s): IRI Robotics Lab, Ivan Rojas (ivan.rojas.j@gmail.com)
autogenerated on Fri Dec 6 2013 22:32:00