PainterUtils.cpp
Go to the documentation of this file.
00001 #include <string>
00002 #include <ros/ros.h>
00003 #include <portrait_painter/PainterUtils.h>
00004 #include <portrait_robot_msgs/alubsc_status_msg.h>
00005 #include <tf/tf.h>
00006 #include <tf/transform_listener.h>
00007 #include <ee_cart_imped_action/ee_cart_imped_arm.hh>
00008 #include <ee_cart_imped_msgs/EECartImpedGoal.h>
00009 
00010 using namespace std;
00011 using namespace portrait_painter;
00012 
00014 void portrait_painter::sendStatus(string message, ros::ServiceClient client) {
00015         if (client.exists()) {
00016                 portrait_robot_msgs::alubsc_status_msg status;
00017                 status.request.ID = NODE_ID;
00018                 status.request.message = message;
00019                 client.call(status);
00020         }
00021 }
00022 
00023 ros::ServiceClient portrait_painter::getMessageClient(ros::NodeHandle n) {
00024         return n.serviceClient<portrait_robot_msgs::alubsc_status_msg>(
00025                         "/alubsc/status_msg");
00026 }
00027 
00028 // returns the right Gripper position in /torso_lift_link
00029 tf::Vector3 portrait_painter::getGripperPosition() {
00030         bool success = false;
00031 
00032         tf::Vector3 res(0, 0, 0);
00033         tf::TransformListener listener;
00034 
00035         tf::StampedTransform transform;
00036         while (!success) {
00037                 try {
00038                         listener.lookupTransform("/torso_lift_link",
00039                                         "/r_gripper_tool_frame", ros::Time(0), transform);
00040                         res[0] = transform.getOrigin().x();
00041                         res[1] = transform.getOrigin().y();
00042                         res[2] = transform.getOrigin().z();
00043                         success = true;
00044                 } catch (tf::TransformException& ex) {
00045 
00046                 }
00047         }
00048         return res;
00049 }
00050 
00051 void portrait_painter::moveGripperToInitialPos() {
00052         // Action Client
00053         EECartImpedArm arm("r_arm_cart_imped_controller");
00054 
00055         // Trajectory
00056         ee_cart_imped_msgs::EECartImpedGoal traj;
00057         tf::Quaternion o = tf::createQuaternionFromRPY(0, 0, 0);
00058         EECartImpedArm::addTrajectoryPoint(traj, 0.5, -0.5, 0.5, o.x(), o.y(),
00059                         o.z(), o.w(), 0, 0, 0, 30, 30, 30, false, false, false, false,
00060                         false, false, 2, "/torso_lift_link");
00061         arm.startTrajectory(traj);
00062 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines


portrait_painter
Author(s): Niklas Meinzer, Ina Baumgarten
autogenerated on Wed Dec 26 2012 16:00:43