test_move_around_torus.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 #
00003 # Copyright 2017 Fraunhofer Institute for Manufacturing Engineering and Automation (IPA)
00004 #
00005 # Licensed under the Apache License, Version 2.0 (the "License");
00006 # you may not use this file except in compliance with the License.
00007 # You may obtain a copy of the License at
00008 #
00009 #   http://www.apache.org/licenses/LICENSE-2.0
00010 #
00011 # Unless required by applicable law or agreed to in writing, software
00012 # distributed under the License is distributed on an "AS IS" BASIS,
00013 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014 # See the License for the specific language governing permissions and
00015 # limitations under the License.
00016 
00017 
00018 import time
00019 
00020 import rospy
00021 import actionlib
00022 
00023 from geometry_msgs.msg import Pose
00024 from cob_cartesian_controller.msg import CartesianControllerAction, CartesianControllerGoal
00025 from cob_cartesian_controller.msg import Profile
00026 
00027 from simple_script_server.simple_script_server import simple_script_server
00028 
00029 import simple_cartesian_interface as sci
00030 import twist_controller_config as tcc
00031 
00032 from tf.transformations import *
00033 '''
00034 Test precondition!
00035 
00036 MANIPULABILITY: 0.1 lambda_max, 0.005 w_threshold
00037 DYN_TASK_READJ
00038 CA mit k_H_CA = -20.0
00039 
00040 JLA mit k_H_JLA = -1.0
00041 
00042 START FROM HOME_POSITION
00043 
00044 Torus with Radius 0.25 should be placed here (world frame / e.g. odom combined):  
00045     pose.position.x = 0.25
00046     pose.position.y = -0.60
00047     pose.position.z = 0.95
00048 
00049 '''
00050 
00051 class MoveLin(object):
00052     
00053     def __init__(self, world, profile, rpy=(1.571, -0.0004, -0.0114,)): # keep ee orientation as started
00054         self._world = world
00055         self._profile = profile
00056         self._rpy = rpy
00057         
00058     def move(self, title, pos=[0.0, 0.0, 0.0], rpy=None, hold_duration=None):
00059         rospy.loginfo(title)
00060         if rpy is not None: 
00061             self._rpy = rpy
00062         pose = sci.gen_pose(pos, self._rpy)
00063         success = sci.move_lin(pose, self._world, self._profile)
00064         if hold_duration is not None: 
00065             time.sleep(hold_duration)
00066         return success
00067     
00068 def move_around_torus():
00069     world = "odom_combined"
00070     profile = Profile()
00071     profile.vel = 0.2
00072     profile.accl = 0.1
00073     profile.profile_type = Profile.SINOID
00074     
00075     ml = MoveLin(world, profile)
00076 
00077     ml.move('Move out of singularity', [-0.094, -0.987, 0.93])
00078     ml.move('Move to center of torus', [-0.09, -0.607, 0.93])
00079     ml.move('Move through torus', [0.558, -0.614, 0.93])
00080     ml.move('Move to torso', [0.56, -0.25, 0.93], hold_duration=0.3)    
00081     ml.move('Move away from torso', [0.56, -0.69, 0.93], hold_duration=0.3)    
00082     ml.move('1st) Move to center of torus (front)', [0.45, -0.66, 0.94], hold_duration=0.3)
00083     ml.move('2nd time for safety. Move to center of torus (front)', [0.45, -0.66, 0.94], hold_duration=0.3)
00084     ml.move('Move through torus (behind)', [-0.09, -0.607, 0.93], hold_duration=0.3)
00085     ml.move('Move through torus again (front)', [0.558, -0.607, 0.93], hold_duration=0.3)
00086     ml.move('Move up', [0.558, -0.607, 1.4], hold_duration=0.3)
00087     ml.move('Move down to center of torus', [0.558, -0.607, 0.93], hold_duration=0.3)   
00088     ml.move('1st) Move down', [0.558, -0.607, 0.5], hold_duration=0.4) # leave some time for self-reconfig
00089     ml.move('2nd) Move down', [0.558, -0.607, 0.5], hold_duration=0.4) # leave some time for self-reconfig
00090     ml.move('3rd) Move down', [0.558, -0.607, 0.5], hold_duration=0.4) # leave some time for self-reconfig
00091     ml.move('Move up to center of torus', [0.558, -0.607, 0.93], hold_duration=0.3)
00092     ml.move('Move through torus again (behind)', [-0.09, -0.607, 0.93], hold_duration=0.3)
00093     
00094 
00095 def init_dyn_recfg():
00096     cli = tcc.TwistControllerReconfigureClient()
00097     cli.init()
00098     
00099     cli.set_config_param(tcc.DAMP_METHOD, tcc.TwistController_MANIPULABILITY)
00100     cli.set_config_param(tcc.LAMBDA_MAX, 0.1)
00101     cli.set_config_param(tcc.W_THRESH, 0.05)
00102     cli.set_config_param(tcc.SOLVER, tcc.TwistController_STACK_OF_TASKS)
00103     cli.set_config_param(tcc.K_H, 1.0)
00104     
00105     cli.set_config_param(tcc.CONSTR_CA, tcc.TwistController_CA)
00106     cli.set_config_param(tcc.K_H_CA, -1.9)
00107     cli.set_config_param(tcc.DAMP_CA, 0.000001)
00108     cli.set_config_param(tcc.ACTIV_THRESH_CA, 0.1)
00109     
00110     cli.set_config_param(tcc.CONSTR_JLA, tcc.TwistController_JLA)
00111     cli.set_config_param(tcc.K_H_JLA, -1.0)
00112     cli.set_config_param(tcc.DAMP_JLA, 0.00001)
00113     cli.set_config_param(tcc.ACTIV_THRESH_JLA, 10.0)
00114     
00115     cli.set_config_param(tcc.KIN_EXT, tcc.TwistController_NO_EXTENSION)
00116     cli.set_config_param(tcc.KEEP_DIR, True)
00117     cli.set_config_param(tcc.ENF_VEL_LIM, True)
00118     cli.set_config_param(tcc.ENF_POS_LIM, True)
00119     
00120     cli.update()
00121     
00122     time.sleep(1.0)
00123     
00124     cli.set_config_param(tcc.K_H_CA, -2.0)
00125     cli.update()
00126     
00127     cli.close()
00128 
00129 
00130 if __name__ == '__main__':
00131     rospy.init_node('test_move_around_torus')
00132     
00133     action_name = rospy.get_namespace()+'cartesian_trajectory_action'
00134     client = actionlib.SimpleActionClient(action_name, CartesianControllerAction)
00135     rospy.logwarn("Waiting for ActionServer: %s", action_name)
00136     client.wait_for_server()
00137     rospy.logwarn("...done")
00138     
00139     init_dyn_recfg()
00140     
00141     sss = simple_script_server()
00142     sss.move("arm_right", "home")
00143     
00144     move_around_torus()


cob_cartesian_controller
Author(s): Christoph Mark
autogenerated on Thu Jun 6 2019 21:19:40