preset_pid_gain_example.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 rospy
19 import moveit_commander
20 
21 from std_msgs.msg import UInt8
22 
23 def preset_pid_gain(pid_gain_no):
24  # サーボモータのPIDゲインをプリセットする
25  # プリセットの内容はsciurus7_control/scripts/preset_reconfigure.pyに書かれている
26  # Presets the PID gains of the servo motor
27  # The presets are written in sciurus7_control/scripts/preset_reconfigure.py
28  print("PID Gain Preset. No." + str(pid_gain_no))
29  preset_no = UInt8()
30  preset_no.data = pid_gain_no
31  pub_preset.publish(preset_no)
32  # Waits until the PID gain is set
33  rospy.sleep(1) # PIDゲインがセットされるまで待つ
34 
35 
36 def main():
37  rospy.init_node("preset_pid_gain_example")
38  arm = moveit_commander.MoveGroupCommander("r_arm_group")
39  arm.set_max_velocity_scaling_factor(0.1)
40 
41  # サーボモータのPIDゲインをプリセット
42  # Presets the PID gain of the servo motor
44 
45  # SRDFに定義されている"r_arm_init_pose"の姿勢にする
46  # Moves the robot the the "r_arm_init_pose" pose defined in the SRDF
47  print("set named target : r_arm_init_pose")
48  arm.set_named_target("r_arm_init_pose")
49  arm.go()
50 
51  # サーボモータのPIDゲインをプリセット
52  # Pゲインが小さくなるので、Sciurus17の右手を人間の手で動かすことが可能
53  # Presets the PID gain of the servo motor
54  # You can move the Sciurus17's right arm because the P gain decreases
56 
57  # 動作確認のため数秒間待つ
58  # Waits a couple seconds for operation confirmation
59  sleep_seconds = 10
60  for i in range(sleep_seconds):
61  print( str(sleep_seconds-i) + " counts left.")
62  rospy.sleep(1)
63  # 安全のため、現在の右手先姿勢を目標姿勢に変更する
64  # Updates the target pose to the current pose for safety reasons
65  arm.set_pose_target(arm.get_current_pose())
66  arm.go()
67 
68  # サーボモータのPIDゲインをプリセット
69  # Presets the PID gain of the servo motor
71 
72  print("set named target : r_arm_init_pose")
73  arm.set_named_target("r_arm_init_pose")
74  arm.go()
75 
76  print("done")
77 
78 
79 if __name__ == '__main__':
80  # PIDゲインプリセット用のPublisher
81  # The Publisher for the PID gain presets
82  pub_preset = rospy.Publisher("preset_gain_no", UInt8, queue_size=1)
83 
84  try:
85  if not rospy.is_shutdown():
86  main()
87  except rospy.ROSInterruptException:
88  pass
preset_pid_gain_example.main
def main()
Definition: preset_pid_gain_example.py:36
preset_pid_gain_example.preset_pid_gain
def preset_pid_gain(pid_gain_no)
Definition: preset_pid_gain_example.py:23


sciurus17_examples
Author(s): Daisuke Sato , Hiroyuki Nomura
autogenerated on Fri Aug 2 2024 08:37:20