preset_reconfigure.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 # coding: utf-8
3 
4 # Copyright 2019 RT Corporation
5 #
6 # Licensed under the Apache License, Version 2.0 (the "License");
7 # you may not use this file except in compliance with the License.
8 # You may obtain a copy of the License at
9 #
10 # http://www.apache.org/licenses/LICENSE-2.0
11 #
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
17 
18 import roslib
19 import rospy
20 import dynamic_reconfigure.client
21 from std_msgs.msg import UInt8
22 
24  def __init__( self ):
25  rospy.loginfo("Wait reconfig server...")
26  self.joint_list = [
27  {"control":"/crane_x7/crane_x7_control","joint":"crane_x7_shoulder_fixed_part_pan_joint"}, \
28  {"control":"/crane_x7/crane_x7_control","joint":"crane_x7_shoulder_revolute_part_tilt_joint"}, \
29  {"control":"/crane_x7/crane_x7_control","joint":"crane_x7_upper_arm_revolute_part_twist_joint"}, \
30  {"control":"/crane_x7/crane_x7_control","joint":"crane_x7_upper_arm_revolute_part_rotate_joint"}, \
31  {"control":"/crane_x7/crane_x7_control","joint":"crane_x7_lower_arm_fixed_part_joint"}, \
32  {"control":"/crane_x7/crane_x7_control","joint":"crane_x7_lower_arm_revolute_part_joint"}, \
33  {"control":"/crane_x7/crane_x7_control","joint":"crane_x7_wrist_joint"}, \
34  {"control":"/crane_x7/crane_x7_control","joint":"crane_x7_gripper_finger_a_joint"}, \
35  ]
36 
37 
38  self.preset_init = []
39  for i in range(len(self.joint_list)):
40  self.preset_init.append( { "p_gain": 800, "i_gain": 0, "d_gain": 0 } )
41 
42 
43  self.preset_1 = [
44  { "name":"crane_x7_shoulder_fixed_part_pan_joint", "p_gain": 10, "i_gain": 0, "d_gain": 0 },\
45  { "name":"crane_x7_shoulder_revolute_part_tilt_joint", "p_gain": 10, "i_gain": 0, "d_gain": 0 },\
46  { "name":"crane_x7_upper_arm_revolute_part_twist_joint", "p_gain": 10, "i_gain": 0, "d_gain": 0 },\
47  { "name":"crane_x7_upper_arm_revolute_part_rotate_joint", "p_gain": 10, "i_gain": 0, "d_gain": 0 },\
48  { "name":"crane_x7_lower_arm_fixed_part_joint", "p_gain": 10, "i_gain": 0, "d_gain": 0 },\
49  { "name":"crane_x7_lower_arm_revolute_part_joint", "p_gain": 10, "i_gain": 0, "d_gain": 0 },\
50  { "name":"crane_x7_wrist_joint", "p_gain": 10, "i_gain": 0, "d_gain": 0 },\
51  { "name":"crane_x7_gripper_finger_a_joint", "p_gain": 10, "i_gain": 0, "d_gain": 0 },\
52  ]
53 
54 
55  self.preset_2 = [
56  { "name":"crane_x7_shoulder_fixed_part_pan_joint", "p_gain": 400, "i_gain": 0, "d_gain": 0 },\
57  { "name":"crane_x7_shoulder_revolute_part_tilt_joint", "p_gain": 400, "i_gain": 0, "d_gain": 0 },\
58  { "name":"crane_x7_upper_arm_revolute_part_twist_joint", "p_gain": 400, "i_gain": 0, "d_gain": 0 },\
59  { "name":"crane_x7_upper_arm_revolute_part_rotate_joint", "p_gain": 400, "i_gain": 0, "d_gain": 0 },\
60  { "name":"crane_x7_lower_arm_fixed_part_joint", "p_gain": 400, "i_gain": 0, "d_gain": 0 },\
61  { "name":"crane_x7_lower_arm_revolute_part_joint", "p_gain": 400, "i_gain": 0, "d_gain": 0 },\
62  { "name":"crane_x7_wrist_joint", "p_gain": 400, "i_gain": 0, "d_gain": 0 },\
63  { "name":"crane_x7_gripper_finger_a_joint", "p_gain": 400, "i_gain": 0, "d_gain": 0 },\
64  ]
65 
66 
67  self.preset_3 = [
68  { "name":"crane_x7_shoulder_fixed_part_pan_joint", "p_gain": 5, "i_gain": 0, "d_gain": 0 },\
69  { "name":"crane_x7_shoulder_revolute_part_tilt_joint", "p_gain": 5, "i_gain": 0, "d_gain": 0 },\
70  { "name":"crane_x7_upper_arm_revolute_part_twist_joint", "p_gain": 5, "i_gain": 0, "d_gain": 0 },\
71  { "name":"crane_x7_upper_arm_revolute_part_rotate_joint", "p_gain": 5, "i_gain": 0, "d_gain": 0 },\
72  { "name":"crane_x7_lower_arm_fixed_part_joint", "p_gain": 1, "i_gain": 0, "d_gain": 0 },\
73  { "name":"crane_x7_lower_arm_revolute_part_joint", "p_gain": 1, "i_gain": 0, "d_gain": 0 },\
74  { "name":"crane_x7_wrist_joint", "p_gain": 1, "i_gain": 0, "d_gain": 0 },\
75  { "name":"crane_x7_gripper_finger_a_joint", "p_gain": 1, "i_gain": 0, "d_gain": 0 },\
76  ]
77 
78 
79  self.preset_4 = [
80  { "name":"crane_x7_shoulder_fixed_part_pan_joint", "p_gain": 800, "i_gain": 0, "d_gain": 0 },\
81  { "name":"crane_x7_shoulder_revolute_part_tilt_joint", "p_gain": 800, "i_gain": 0, "d_gain": 0 },\
82  { "name":"crane_x7_upper_arm_revolute_part_twist_joint", "p_gain": 800, "i_gain": 0, "d_gain": 0 },\
83  { "name":"crane_x7_upper_arm_revolute_part_rotate_joint", "p_gain": 800, "i_gain": 0, "d_gain": 0 },\
84  { "name":"crane_x7_lower_arm_fixed_part_joint", "p_gain": 800, "i_gain": 0, "d_gain": 0 },\
85  { "name":"crane_x7_lower_arm_revolute_part_joint", "p_gain": 800, "i_gain": 0, "d_gain": 0 },\
86  { "name":"crane_x7_wrist_joint", "p_gain": 800, "i_gain": 0, "d_gain": 0 },\
87  { "name":"crane_x7_gripper_finger_a_joint", "p_gain": 800, "i_gain": 0, "d_gain": 0 },\
88  ]
89 
90 
91  self.preset_list = []
92  self.preset_list.append( self.preset_init )
93  self.preset_list.append( self.preset_1 )
94  self.preset_list.append( self.preset_2 )
95  self.preset_list.append( self.preset_3 )
96  self.preset_list.append( self.preset_4 )
97 
98  self.reconfigure = []
99  for joint in self.joint_list:
100  self.reconfigure.append( {"client":dynamic_reconfigure.client.Client( joint["control"]+"/"+joint["joint"],timeout=10 ), \
101  "joint:":joint["joint"]} )
102  rospy.loginfo("Wait sub...")
103  self.subscribe = rospy.Subscriber("preset_gain_no", UInt8, self.preset_no_callback)
104  rospy.loginfo("Init finished.")
105 
106 
107  def preset_no_callback(self, no):
108  joint_no = 0
109  for conf in self.reconfigure:
110  conf["client"].update_configuration( {"position_p_gain":self.preset_list[no.data][joint_no]["p_gain"],"position_i_gain":self.preset_list[no.data][joint_no]["i_gain"],"position_d_gain":self.preset_list[no.data][joint_no]["d_gain"]} )
111  joint_no = joint_no + 1
112 
113 
114 if __name__ == '__main__':
115  rospy.init_node('preset_reconfigure')
117  rospy.spin()
preset_reconfigure.PRESET_RECONFIGURE.preset_4
preset_4
プリセット定義 - 4 未設定。モノを掴んだ時や、アームの形状を変えた時に設定してみてください ###
Definition: preset_reconfigure.py:79
preset_reconfigure.PRESET_RECONFIGURE.preset_2
preset_2
プリセット定義 - 2 PゲインをInitial parametersの半分にする ###
Definition: preset_reconfigure.py:55
preset_reconfigure.PRESET_RECONFIGURE.preset_init
preset_init
プリセット定義 - 0.Initial parameters ###
Definition: preset_reconfigure.py:38
preset_reconfigure.PRESET_RECONFIGURE.__init__
def __init__(self)
Definition: preset_reconfigure.py:24
preset_reconfigure.PRESET_RECONFIGURE.preset_1
preset_1
プリセット定義 - 1 脱力状態 ###
Definition: preset_reconfigure.py:43
preset_reconfigure.PRESET_RECONFIGURE.preset_3
preset_3
プリセット定義 - 3 ティーチングサンプル用のPIDゲイン ###
Definition: preset_reconfigure.py:67
preset_reconfigure.PRESET_RECONFIGURE.joint_list
joint_list
Definition: preset_reconfigure.py:26
preset_reconfigure.PRESET_RECONFIGURE.reconfigure
reconfigure
Definition: preset_reconfigure.py:98
preset_reconfigure.PRESET_RECONFIGURE.preset_list
preset_list
プリセットデータリスト ###
Definition: preset_reconfigure.py:91
preset_reconfigure.PRESET_RECONFIGURE.subscribe
subscribe
Definition: preset_reconfigure.py:103
preset_reconfigure.PRESET_RECONFIGURE.preset_no_callback
def preset_no_callback(self, no)
Definition: preset_reconfigure.py:107
preset_reconfigure.PRESET_RECONFIGURE
Definition: preset_reconfigure.py:23


crane_x7_control
Author(s): Hiroyuki Nomura , Geoffrey Biggs
autogenerated on Mon Oct 2 2023 02:39:30