sr_arm_commander.py
Go to the documentation of this file.
1 #!/usr/bin/python
2 # Copyright 2019 Shadow Robot Company Ltd.
3 #
4 # This program is free software: you can redistribute it and/or modify it
5 # under the terms of the GNU General Public License as published by the Free
6 # Software Foundation version 2 of the License.
7 #
8 # This program is distributed in the hope that it will be useful, but WITHOUT
9 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11 # more details.
12 #
13 # You should have received a copy of the GNU General Public License along
14 # with this program. If not, see <http://www.gnu.org/licenses/>.
15 
16 from sr_robot_commander import SrRobotCommander
17 from geometry_msgs.msg import PoseStamped, Pose
18 from rospy import get_rostime
19 import rospy
20 from tf import TransformerROS
21 
22 
23 class SrArmCommander(SrRobotCommander):
24  """
25  Commander class for arm
26  """
27 
28  def __init__(self, name="right_arm", set_ground=True):
29  """
30  Initialize object
31  @param name - name of the MoveIt group
32  @param set_ground - sets the ground plane in moveit for planning
33  """
34  try:
35  super(SrArmCommander, self).__init__(name)
36  except Exception as e:
37  # TODO(@dg-shadow): Raise SrRobotCommanderException here. Not doing
38  # now as no time to check for and repair unforseen consequences.
39  rospy.logerr("Couldn't initialise robot commander - is there an arm running?: " + str(e))
41  return
42 
43  if set_ground:
44  self.set_ground()
45 
46  def arm_found(self):
47  return self._move_group_commander is not None
48 
49  def set_ground(self, height=0.1, z_position=-0.1):
50  """
51  Sets a plane for the ground.
52  @param height - specifies the height of the plane
53  @param z_position - position in z to place the plane. Should not collide with the robot.
54  """
55 
56  pose = PoseStamped()
57  pose.pose.position.x = 0
58  pose.pose.position.y = 0
59  pose.pose.position.z = z_position - (height/2.0)
60  pose.pose.orientation.x = 0
61  pose.pose.orientation.y = 0
62  pose.pose.orientation.z = 0
63  pose.pose.orientation.w = 1
64  pose.header.stamp = get_rostime()
65  pose.header.frame_id = self._robot_commander.get_root_link()
66  self._planning_scene.add_box("ground", pose, (3, 3, height))
67 
69  return self._move_group_commander.get_pose_reference_frame()
def __init__(self, name="right_arm", set_ground=True)
def set_ground(self, height=0.1, z_position=-0.1)


sr_robot_commander
Author(s): Andriy Petlovanyy
autogenerated on Wed Oct 14 2020 04:05:30