test_cart_twist.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 TwistStamped
00038 from geometry_msgs.msg import Twist
00039 import tf
00040 import tf.transformations as tf_trans
00041 import sys
00042 from hrl_pr2_arms.pr2_controller_switcher import ControllerSwitcher
00043 from tabletop_pushing.srv import *
00044 
00045 def initialPose(ctrl_switcher):
00046         ctrl_switcher.carefree_switch('r', '%s_cart', '$(find hrl_pr2_arms)/params/j_transpose_params_low.yaml')
00047 
00048         rospy.sleep(1.0)
00049         rospy.loginfo('initializing the test node')
00050         pub = rospy.Publisher('r_cart/command_pose', PoseStamped)
00051 
00052         rospy.loginfo('Finally Publishing')
00053         pose = PoseStamped()
00054         pose.header.frame_id = '/torso_lift_link'
00055         pose.header.stamp = rospy.Time(0)
00056         pose.pose.position.x = 0.3
00057         pose.pose.position.y = 0
00058         pose.pose.position.z = 0.2
00059         pose.pose.orientation.x = 0 
00060         pose.pose.orientation.y = 0 
00061         pose.pose.orientation.z = 0 
00062         pose.pose.orientation.w = 1 
00063         pub.publish(pose)
00064         rospy.sleep(4.0) 
00065         # pub.publish(pose)
00066         # rospy.sleep(4.0) 
00067 
00068 class TestNode:
00069     def move(self):
00070             # this is for robot_mechanism_controllers/CartesianTwistController
00071         ctrl_switcher = ControllerSwitcher()
00072         initialPose(ctrl_switcher) 
00073         rospy.loginfo('create the controller')
00074         ctrl_switcher.carefree_switch('r', '%s_cart', '$(find visual_servo)/params/rmc_cartTwist_params.yaml')
00075         rospy.sleep(0.5)
00076         pub = rospy.Publisher('r_cart/command', Twist)
00077         rospy.loginfo('created the publisher obj')
00078         pose = Twist()
00079         pose.linear.x = 0.00
00080         pose.linear.y = 0.00
00081         pose.linear.z = -.05
00082         pose.angular.x = 0.1
00083         pose.angular.y = 0.1
00084         pose.angular.z = 0.1
00085         while not rospy.is_shutdown():
00086                 rospy.loginfo('Publishing following message: %s'%pose)
00087                 pub.publish(pose)
00088                 rospy.sleep(2.0) 
00089   
00090 if __name__ == '__main__':
00091     try:
00092         rospy.init_node('test_node', log_level=rospy.DEBUG)
00093         node = TestNode()
00094         node.move()
00095     except rospy.ROSInterruptException: pass


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