irex_demo_noteaching.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 
00003 # Software License Agreement (BSD License)
00004 #
00005 # Copyright (c) 2013, Tokyo Opensource Robotics Kyokai Association
00006 # All rights reserved.
00007 #
00008 # Redistribution and use in source and binary forms, with or without
00009 # modification, are permitted provided that the following conditions
00010 # are met:
00011 #
00012 #  * Redistributions of source code must retain the above copyright
00013 #    notice, this list of conditions and the following disclaimer.
00014 #  * Redistributions in binary form must reproduce the above
00015 #    copyright notice, this list of conditions and the following
00016 #    disclaimer in the documentation and/or other materials provided
00017 #    with the distribution.
00018 #  * Neither the name of Tokyo Opensource Robotics Kyokai Association. nor the
00019 #    names of its contributors may be used to endorse or promote products
00020 #    derived from this software without specific prior written permission.
00021 #
00022 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00023 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00024 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00025 # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00026 # COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00027 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00028 # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00029 # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00030 # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00031 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00032 # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00033 # POSSIBILITY OF SUCH DAMAGE.
00034 #
00035 # Author: Isaac Isao Saito
00036 
00037 #%Tag(FULLTEXT)%
00038 
00039 import os
00040 from subprocess import check_call
00041 
00042 import actionlib_msgs.msg
00043 from geometry_msgs.msg import Pose, PoseStamped, Point, Quaternion
00044 from moveit_commander import MoveGroupCommander, conversions
00045 from rospkg import RosPack
00046 import roslib
00047 import rospy
00048 import std_msgs.msg
00049 from tf.transformations import quaternion_from_euler
00050 #roslib.load_manifest("denso_pendant_publisher")
00051 #roslib.load_manifest("actionlib_msgs")
00052 
00053 rospy.init_node("test_vs060_moveit")
00054 
00055 g_runnable = False
00056 g_prev_status = None
00057 
00058 arm = MoveGroupCommander("manipulator")
00059 running_pub = rospy.Publisher("/irex_demo_running", std_msgs.msg.Bool);
00060 #cancel_pub = rospy.Publisher("/arm_controller/follow_joint_trajectory/cancel", actionlib_msgs.msg.GoalID);
00061 cancel_pub = rospy.Publisher("/move_group/cancel", actionlib_msgs.msg.GoalID);
00062 
00063 # Get paths for files used later.
00064 _rospack = RosPack()
00065 SCENE_FILE = _rospack.get_path('vs060') + '/model/irex_model.scene'
00066 _path_rosroot = rospy.get_ros_root()
00067 _len_cut = len(_path_rosroot) - len('/share/ros')  # This is used to get ros root path /opt/%DISTRO% path.
00068 _path_rosroot_top = _path_rosroot[:_len_cut]
00069 LOAD_SCENE_PROG = _path_rosroot_top + '/lib/vs060/publish_scene_from_text'
00070 
00071 print 'SCENE_FILE=', SCENE_FILE
00072 print 'LOAD_SCENE_PROG=', LOAD_SCENE_PROG
00073 
00074 def demo() :
00075     # load scene
00076     global g_runnable
00077     running_pub.publish(std_msgs.msg.Bool(g_runnable))
00078     check_call([LOAD_SCENE_PROG, SCENE_FILE])
00079     for p in [[ 0.35, -0.35, 0.4],
00080               [ 0.6,  0.0, 0.4],
00081               [ 0.35,  0.35, 0.4],
00082               [ 0.6,  0.0, 0.2],
00083               [ 0.4,  0.0, 0.8]]:
00084         running_pub.publish(std_msgs.msg.Bool(g_runnable))
00085         if g_runnable:
00086             print "set_pose_target(", p, ")"
00087             pose = PoseStamped(header = rospy.Header(stamp = rospy.Time.now(), frame_id = '/BASE'),
00088                                pose = Pose(position = Point(*p),
00089                                            orientation = Quaternion(*quaternion_from_euler(1.57, 0, 1.57, 'sxyz'))))
00090 
00091             arm.set_pose_target(pose)
00092             arm.go() or arm.go() or rospy.logerr("arm.go fails")
00093             rospy.sleep(1)
00094             if rospy.is_shutdown():
00095                 return
00096 
00097 if __name__ == "__main__":
00098     while not rospy.is_shutdown():
00099         demo()
00100 #%EndTag(FULLTEXT)%


vs060
Author(s): Ryohei Ueda
autogenerated on Thu Jun 6 2019 20:15:26