short.py
Go to the documentation of this file.
00001 #
00002 # Copyright (c) 2009, Georgia Tech Research Corporation
00003 # All rights reserved.
00004 # 
00005 # Redistribution and use in source and binary forms, with or without
00006 # modification, are permitted provided that the following conditions are met:
00007 #     * Redistributions of source code must retain the above copyright
00008 #       notice, this list of conditions and the following disclaimer.
00009 #     * Redistributions in binary form must reproduce the above copyright
00010 #       notice, this list of conditions and the following disclaimer in the
00011 #       documentation and/or other materials provided with the distribution.
00012 #     * Neither the name of the Georgia Tech Research Corporation nor the
00013 #       names of its contributors may be used to endorse or promote products
00014 #       derived from this software without specific prior written permission.
00015 # 
00016 # THIS SOFTWARE IS PROVIDED BY GEORGIA TECH RESEARCH CORPORATION ''AS IS'' AND
00017 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00018 # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00019 # DISCLAIMED. IN NO EVENT SHALL GEORGIA TECH BE LIABLE FOR ANY DIRECT, INDIRECT,
00020 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
00021 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
00022 # OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00023 # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
00024 # OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
00025 # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00026 #
00027 
00028 # Author: Advait Jain
00029 
00030 
00031 import math, numpy as np
00032 import m3.rt_proxy as m3p
00033 import m3.component_factory as m3f
00034 import m3.toolbox as m3t
00035 import m3.arm
00036 
00037 THETA_GC = 5
00038 THETA = 3
00039 
00040 def safeop_things(proxy):
00041     robot_name = 'm3humanoid_bimanual_mr1'
00042     chain_names = ['m3arm_ma1', 'm3arm_ma2']
00043     dynamatics_nms = ['m3dynamatics_ma1', 'm3dynamatics_ma2']
00044 
00045     proxy.make_safe_operational(robot_name)
00046     for c in chain_names:
00047         proxy.make_safe_operational(c)
00048     for d in dynamatics_nms:
00049         proxy.make_safe_operational(d)
00050 
00051 
00052 proxy = m3p.M3RtProxy()
00053 proxy.start()
00054 
00055 pwr_nm = 'm3pwr_pwr003'
00056 pwr = m3f.create_component(pwr_nm)
00057 proxy.publish_command(pwr)
00058 
00059 joint_names = ['m3joint_ma1_j0', 'm3joint_ma1_j1', 'm3joint_ma1_j2', 'm3joint_ma1_j3', 'm3joint_ma1_j4', 'm3joint_ma1_j5', 'm3joint_ma1_j6']
00060 
00061 comp_list = []
00062 stiff_list = [0.2, 0.67, 1., 0.7, 0.75, 0.5, 0.5]
00063 for i, c in enumerate(joint_names):
00064     comp = m3f.create_component(c)
00065     comp_list.append(comp)
00066     proxy.publish_command(comp)
00067     if i < 5:
00068         comp.set_control_mode(THETA_GC)
00069     else:
00070         comp.set_control_mode(THETA)
00071     comp.set_stiffness(stiff_list[i])
00072     comp.set_slew_rate_proportion(1.)
00073 
00074 # safeop_things must be after make_operational_all.
00075 proxy.make_operational_all()
00076 safeop_things(proxy)
00077 
00078 #ma1 = m3.arm.M3Arm('m3arm_ma1')
00079 #proxy.subscribe_status(ma1)
00080 
00081 proxy.step()
00082 proxy.step()
00083 
00084 raw_input('Hit ENTER to power on')
00085 pwr.set_motor_power_on()
00086 
00087 proxy.step()
00088 proxy.step()
00089 
00090 raw_input('Hit ENTER to move the joint')
00091 q = [0., 0., 0., 90., 0., 0., 0.]
00092 q = np.radians(q)
00093 
00094 for i, c in enumerate(comp_list):
00095     c.set_theta_rad(q[i])
00096 
00097 proxy.step()
00098 proxy.step()
00099 
00100 raw_input('Hit ENTER to stop')
00101 proxy.stop()
00102 
00103 
00104 
00105 
00106 
00107 
00108 
00109 
00110 
00111 #-------------- older code ---------------
00112 
00113 ##Force safe-op of robot, etc are present
00114 #types=['m3humanoid','m3hand','m3gripper']
00115 #for t in types:
00116 #    cc = proxy.get_available_components(t)
00117 #    for ccc in cc:
00118 #        print 'ccc:', ccc
00119 #        proxy.make_safe_operational(ccc)
00120 #
00121 #
00122 ##Force safe-op of chain so that gravity terms are computed
00123 #chain=None
00124 #if len(joint_names)>0:
00125 #    for j in joint_names:
00126 #        chain_name=m3t.get_joint_chain_name(j)
00127 #        print 'chain_name:', chain_name
00128 #        if chain_name!="":
00129 #            proxy.make_safe_operational(chain_name)
00130 #
00131 #            #Force safe-op of chain so that gravity terms are computed
00132 #            dynamatics_name = m3t.get_chain_dynamatics_component_name(chain_name)
00133 #            print 'dynamatics_name:', dynamatics_name
00134 #            if dynamatics_name != "":
00135 #                proxy.make_safe_operational(dynamatics_name)
00136 #
00137 #
00138 #
00139 ##Force safe-op of robot so that gravity terms are computed
00140 #robot_name = m3t.get_robot_name()
00141 #print 'robot_name:', robot_name
00142 #if robot_name != "":
00143 #    proxy.make_safe_operational(robot_name)
00144 
00145 
00146 
00147 


hrl_cody_arms
Author(s): Advait Jain, Advisor: Prof. Charlie Kemp, Lab: Healthcare Robotics Lab
autogenerated on Wed Nov 27 2013 12:11:49