test_cart_pose.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 # Software License Agreement (BSD License)
00003 #
00004 #  Copyright (c) 2011, Georgia Institute of Technology
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 the Georgia Institute of Technology nor the names of
00018 #     its 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 import roslib; roslib.load_manifest('tabletop_pushing')
00035 import rospy
00036 from geometry_msgs.msg import PoseStamped
00037 from geometry_msgs.msg import Pose
00038 from geometry_msgs.msg import TwistStamped
00039 import tf
00040 import tf.transformations as tf_trans
00041 import sys
00042 from hrl_pr2_arms.pr2_controller_switcher import ControllerSwitcher
00043 
00044 class TestNode:
00045      def talk(self):
00046         # pub = rospy.Publisher('command', PoseStamped)
00047         isStamped = True;
00048         if (isStamped):
00049             rospy.loginfo('created the controller')
00050             ctrl_swtch = ControllerSwitcher()
00051             # note: more smooth but see some jerking robot_mechanism_controllers/JTCartesianControllers
00052             ctrl_swtch.carefree_switch('r', '%s_cart', '$(find hrl_pr2_arms)/params/j_transpose_params_low.yaml')
00053 
00054             # note: very jerky... pr2_manipulation_controllers/JTTaskControllers
00055             # ctrl_swtch.carefree_switch('r', '%s_cart', '$(find hrl_pr2_arms)/params/j_transpose_task_params_high.yaml')
00056             # ctrl_swtch.carefree_switch('r', '%s_cart', '$(find tabletop_pushing)/params/j_transpose_params_high.yaml')
00057 
00058             rospy.sleep(1.0)
00059 
00060             rospy.loginfo('initializing the test node')
00061             pub = rospy.Publisher('r_cart/command_pose', PoseStamped)
00062 
00063             rospy.loginfo('Finally Publishing')
00064             pose = PoseStamped()
00065             pose.header.frame_id = '/torso_lift_link'
00066             pose.header.stamp = rospy.Time(0)
00067             pose.pose.position.x = 0.1
00068             pose.pose.position.y = -0.2
00069             pose.pose.position.z = -0.2
00070             pose.pose.orientation.x = 0.5
00071             pose.pose.orientation.y = 0.5
00072             pose.pose.orientation.z = 0.5
00073             pose.pose.orientation.w = 0.5 
00074             while not rospy.is_shutdown():
00075                 pose.pose.position.x = pose.pose.position.x + 0.025
00076                 rospy.loginfo('Publishing following message: %s'%pose)
00077                 pub.publish(pose)
00078                 rospy.sleep(0.5) 
00079        
00080         else:
00081             
00082             # note: Does not work (wiki says it takes in Geomtry_msgs/Pose, but when you run it, there is some conflict)
00083             # Robot_mechanism_controllers/CartesianPoseControllers
00084             rospy.loginfo('created the controller')
00085             ctrl_swtch = ControllerSwitcher()
00086             ctrl_swtch.carefree_switch('r', '%s_cart', '$(find tabletop_pushing)/params/rmc_cartPose_params.yaml')
00087             rospy.sleep(1.0)
00088 
00089             rospy.loginfo('initializing the test node')
00090             pub = rospy.Publisher('r_cart/command', Pose)
00091 
00092             rospy.loginfo('Finally Publishing')
00093             pose = Pose()
00094             pose.position.x = 0.3
00095             pose.position.y = -0.2
00096             pose.position.z = -0.20
00097             pose.orientation.x = 0.7071
00098             pose.orientation.y = 0 
00099             pose.orientation.z = 0 
00100             pose.orientation.w = 0.7071 
00101             while not rospy.is_shutdown():
00102                 pose.position.x = pose.position.x + 0.05
00103                 rospy.loginfo('Publishing following message: %s'%pose)
00104                 pub.publish(pose)
00105                 rospy.sleep(0.5) 
00106 
00107 
00108 
00109 
00110 
00111 if __name__ == '__main__':
00112     try:
00113         rospy.init_node('test_node', log_level=rospy.DEBUG)
00114         node = TestNode()
00115         node.talk()
00116     except rospy.ROSInterruptException: pass


visual_servo
Author(s): Stephan Lee
autogenerated on Wed Nov 27 2013 11:44:03