set_goals.cpp
Go to the documentation of this file.
00001 /*
00002  * Software License Agreement (Modified BSD License)
00003  *
00004  *  Copyright (c) 2011, PAL Robotics, S.L.
00005  *  All rights reserved.
00006  *
00007  *  Redistribution and use in source and binary forms, with or without
00008  *  modification, are permitted provided that the following conditions
00009  *  are met:
00010  *
00011  *   * Redistributions of source code must retain the above copyright
00012  *     notice, this list of conditions and the following disclaimer.
00013  *   * Redistributions in binary form must reproduce the above
00014  *     copyright notice, this list of conditions and the following
00015  *     disclaimer in the documentation and/or other materials provided
00016  *     with the distribution.
00017  *   * Neither the name of PAL Robotics, S.L. nor the names of its
00018  *     contributors may be used to endorse or promote products derived
00019  *     from this software without specific prior written permission.
00020  *
00021  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00022  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00023  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00024  *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00025  *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00026  *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00027  *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00028  *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00029  *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00030  *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00031  *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00032  *  POSSIBILITY OF SUCH DAMAGE.
00033  */
00034 
00037 #include "motion_adaption/motion_adaption.h"
00038 
00039 
00040 void MotionAdaption::setGoals()
00041 {
00042 
00043   ros::Time publish_time = ros::Time::now();
00044    std::vector<tf::StampedTransform> tf_transforms(6);
00045  
00046 
00047   tf::StampedTransform out_tf;
00048   // torso goal
00049   tf_torso_goal_.setOrigin(tf::Vector3(0.0, 0.0, 0.0));
00050   //quat_.setRPY(M_PI, M_PI/2, 0);
00051   quat_.setRPY(torso_goal_rot_vec_[0], torso_goal_rot_vec_[1], torso_goal_rot_vec_[2]);
00052   tf_torso_goal_.setRotation(quat_);
00053   //tf_broadcaster_.sendTransform(tf::StampedTransform(tf_torso_goal_, ros::Time::now(), "/ref_frame", "/torso_goal"));
00054    out_tf = tf_torso_goal_;
00055    out_tf.stamp_ = publish_time;
00056    out_tf.frame_id_ = "/ref_frame"; 
00057    out_tf.child_frame_id_ = "/torso_goal";
00058    tf_transforms[0] = out_tf;
00059   
00060   // head goal
00061   tf_head_goal_.setOrigin(tf::Vector3(0.0, 0.0, 0.0));
00062   //quat_.setRPY(M_PI, M_PI/2, 0);
00063   quat_.setRPY(head_goal_rot_vec_[0], head_goal_rot_vec_[1], head_goal_rot_vec_[2]);
00064   tf_head_goal_.setRotation(quat_);
00065   internal_tf.setTransform(tf::StampedTransform(tf_head_goal_, calc_time, "/head_adapted", "/head_goal"));
00066   internal_tf.lookupTransform("/ref_frame", "/head_goal", ros::Time(0), out_tf);
00067   //tf_broadcaster_.sendTransform(tf::StampedTransform(out_tf, ros::Time::now(),  "/ref_frame", "/head_goal"));
00068    out_tf.stamp_ = publish_time;
00069    out_tf.frame_id_ = "/ref_frame"; 
00070    out_tf.child_frame_id_ = "/head_goal";
00071    tf_transforms[1] = out_tf;
00072   
00073   // right elbow goal
00074   tf_r_elbow_goal_.setOrigin(btVector3(0.0, 0.0, 0.0));
00075   //quat_.setRPY(M_PI, 0.0, M_PI);
00076   quat_.setRPY(r_elbow_goal_rot_vec_[0], r_elbow_goal_rot_vec_[1], r_elbow_goal_rot_vec_[2]);
00077   tf_r_elbow_goal_.setRotation(quat_);
00078   internal_tf.setTransform(tf::StampedTransform(tf_r_elbow_goal_, calc_time, "/r_elbow_adapted", "/r_elbow_goal"));
00079   internal_tf.lookupTransform("/ref_frame", "/r_elbow_goal", ros::Time(0), out_tf);
00080  // tf_broadcaster_.sendTransform(tf::StampedTransform(out_tf, ros::Time::now(),  "/ref_frame", "/r_elbow_goal"));
00081    out_tf.stamp_ = publish_time;
00082    out_tf.frame_id_ = "/ref_frame"; 
00083    out_tf.child_frame_id_ = "/r_elbow_goal";
00084    tf_transforms[2] = out_tf;
00085 
00086   // left elbow goal  
00087   tf_l_elbow_goal_.setOrigin(btVector3(0.0, 0.0, 0.0));
00088   //quat_.setRPY(0.0, M_PI, 0.0);
00089   quat_.setRPY(l_elbow_goal_rot_vec_[0], l_elbow_goal_rot_vec_[1], l_elbow_goal_rot_vec_[2]);
00090   tf_l_elbow_goal_.setRotation(quat_);
00091   internal_tf.setTransform(tf::StampedTransform(tf_l_elbow_goal_, calc_time, "/l_elbow_adapted", "/l_elbow_goal"));
00092   internal_tf.lookupTransform("/ref_frame", "/l_elbow_goal", ros::Time(0), out_tf);
00093   //tf_broadcaster_.sendTransform(tf::StampedTransform(out_tf, ros::Time::now(),  "/ref_frame", "/l_elbow_goal"));
00094    out_tf.stamp_ = publish_time;
00095    out_tf.frame_id_ = "/ref_frame"; 
00096    out_tf.child_frame_id_ = "/l_elbow_goal";
00097    tf_transforms[3] = out_tf;  
00098 
00099   // right hand goal
00100   tf_r_hand_goal_.setOrigin(btVector3(0.0, 0.0, 0.0));
00101   //quat_.setRPY(0.0, M_PI/2, 0.0);
00102   quat_.setRPY(r_hand_goal_rot_vec_[0], r_hand_goal_rot_vec_[1], r_hand_goal_rot_vec_[2]);
00103   tf_r_hand_goal_.setRotation(quat_);
00104  // tf_broadcaster_.sendTransform(tf::StampedTransform(tf_r_hand_goal_, ros::Time::now(), "/r_hand_adapted", "/r_hand_goal"));
00105   internal_tf.setTransform(tf::StampedTransform(tf_r_hand_goal_, calc_time,  "/r_hand_adapted", "/r_hand_goal"));
00106   internal_tf.lookupTransform("/ref_frame", "/r_hand_goal", ros::Time(0), out_tf);
00107   //tf_broadcaster_.sendTransform(tf::StampedTransform(out_tf, ros::Time::now(),  "/ref_frame", "/r_hand_goal"));
00108    out_tf.stamp_ = publish_time;
00109    out_tf.frame_id_ = "/ref_frame"; 
00110    out_tf.child_frame_id_ = "/r_hand_goal";
00111    tf_transforms[4] = out_tf;
00112 
00113    // left hand goal
00114   tf_l_hand_goal_.setOrigin(btVector3(0.0, 0.0, 0.0));
00115   //quat_.setRPY(0.0, -M_PI/2, 0.0);
00116   quat_.setRPY(l_hand_goal_rot_vec_[0], l_hand_goal_rot_vec_[1], l_hand_goal_rot_vec_[2]);
00117   tf_l_hand_goal_.setRotation(quat_);
00118   //tf_broadcaster_.sendTransform(tf::StampedTransform(tf_l_hand_goal_, ros::Time::now(),  "/l_hand_adapted", "/l_hand_goal"));
00119   internal_tf.setTransform(tf::StampedTransform(tf_l_hand_goal_, calc_time,  "/l_hand_adapted", "/l_hand_goal"));
00120   internal_tf.lookupTransform("/ref_frame", "/l_hand_goal", ros::Time(0), out_tf);
00121   // tf_broadcaster_.sendTransform(tf::StampedTransform(out_tf, ros::Time::now(),  "/ref_frame", "/l_hand_goal"));
00122    out_tf.stamp_ = publish_time;
00123    out_tf.frame_id_ = "/ref_frame"; 
00124    out_tf.child_frame_id_ = "/l_hand_goal";
00125    tf_transforms[5] = out_tf;  
00126 
00127 
00128    tf_broadcaster_.sendTransform(tf_transforms);
00129 
00130    /* un-comment this part to published unscaled but aligned transforms
00131   
00132   tf_broadcaster_.sendTransform(tf::StampedTransform(tf_torso_aligned_, ros::Time::now(),
00133   "/ref_frame", "/torso_aligned"));
00134   tf_broadcaster_.sendTransform(tf::StampedTransform(tf_usr_head_, ros::Time::now(),
00135   "/torso_aligned", "/tf_usr_head"));
00136   tf_broadcaster_.sendTransform(tf::StampedTransform(tf_usr_r_shoulder_, ros::Time::now(),
00137   "/torso_aligned", "/tf_usr_r_shoulder"));
00138   tf_broadcaster_.sendTransform(tf::StampedTransform(tf_usr_r_elbow_, ros::Time::now(),
00139   "/torso_aligned", "/tf_usr_r_elbow"));
00140   tf_broadcaster_.sendTransform(tf::StampedTransform(tf_usr_r_hand_, ros::Time::now(),
00141   "/torso_aligned", "/tf_usr_r_hand"));
00142   tf_broadcaster_.sendTransform(tf::StampedTransform(tf_usr_l_shoulder_, ros::Time::now(),
00143   "/torso_aligned", "/tf_usr_l_shoulder"));
00144   tf_broadcaster_.sendTransform(tf::StampedTransform(tf_usr_l_elbow_, ros::Time::now(),
00145   "/torso_aligned", "/tf_usr_l_elbow"));
00146   tf_broadcaster_.sendTransform(tf::StampedTransform(tf_usr_l_hand_, ros::Time::now(),
00147   "/torso_aligned", "/tf_usr_l_hand"));
00148   */
00149 }


motion_adaption
Author(s): Marcus Liebhardt
autogenerated on Mon Jan 6 2014 11:39:55