5 imp.find_module(
"actionlib")
7 import roslib; roslib.load_manifest(
'jsk_teleop_joy')
10 from jsk_rviz_plugins.msg
import OverlayMenu
11 from jsk_teleop_joy.joy_pose_6d
import JoyPose6D
12 from jsk_interactive_marker.srv
import GetTransformableMarkerPose
13 from jsk_interactive_marker.srv
import SetPose
14 from geometry_msgs.msg
import PoseStamped
15 from std_srvs.srv
import Empty
21 return all([getattr(pose1.position, attr) == getattr(pose2.position, attr)
for attr
in [
"x",
"y",
"z"]])
and all ([getattr(pose1.orientation, attr) == getattr(pose2.orientation, attr)
for attr
in [
"x",
"y",
"z",
"w"]])
27 circle: execute footstep 29 triangle: stack footstep (only used in stack mode) 30 start: toggle footstep marker mode (single -> continuous -> stack) 33 use_tf [Boolean, default: True]: update marker pose using tf 34 publish_pose : forced False 35 frame_id [String, default: map]: frame_id of publishing pose, this is overwritten by parameter, ~frame_id 36 pose [String, default: pose]: topic name for publishing pose 37 set_pose [String, default: set_pose]: topic name for setting pose by topic 40 args[
'publish_pose'] =
False 41 JoyPose6D.__init__(self, name, args)
42 self.
pose_pub = rospy.Publisher(self.getArg(
'pose',
'pose'), PoseStamped)
44 self.
use_tf = self.getArg(
'use_tf',
True)
48 self.
pub = rospy.Publisher(
"joy_footstep_menu", OverlayMenu)
52 rospy.wait_for_service(
'/footstep_marker/reset_marker')
54 rospy.wait_for_service(
'/footstep_marker/toggle_footstep_marker_mode')
56 rospy.wait_for_service(
'/footstep_marker/execute_footstep')
58 rospy.wait_for_service(
'/footstep_marker/get_footstep_marker_pose')
60 rospy.wait_for_service(
'/footstep_marker/stack_marker_pose')
65 if marker_pose !=
None:
68 def joyCB(self, status, history):
69 now = rospy.Time.from_sec(time.time())
70 latest = history.latest()
76 if status.up
and not latest.up:
77 self.
menu.current_index = (self.
menu.current_index - 1) % len(self.
menu.menus)
79 elif status.down
and not latest.down:
80 self.
menu.current_index = (self.
menu.current_index + 1) % len(self.
menu.menus)
82 elif status.circle
and not latest.circle:
83 self.
menu.action = OverlayMenu.ACTION_CLOSE
84 if self.
menu.current_index == self.
menu.menus.index(
"Yes"):
87 except rospy.ServiceException
as e:
88 rospy.logwarn(
"Execute Footsteps failed: %s", e)
91 elif status.cross
and not latest.cross:
92 self.
menu.action = OverlayMenu.ACTION_CLOSE
100 JoyPose6D.joyCB(self, status, history)
101 if status.circle
and not latest.circle:
102 self.
menu = OverlayMenu()
103 self.
menu.title =
"Execute Footsteps?" 104 self.
menu.menus = [
"Yes",
"No"]
105 self.
menu.current_index = 1
107 elif status.cross
and not latest.cross:
110 if marker_pose !=
None:
114 self.
pre_pose.pose.orientation.w = 1
115 elif status.triangle
and not latest.triangle:
118 elif status.start
and not latest.start:
128 if (now - self.
prev_time).to_sec() > 1 / 30.0:
139 marker_pose = self.tf_listener.transformPose(self.frame_id, marker_pose)
141 except rospy.ServiceException
as e:
142 rospy.logwarn(
"Failed to get initial marker pose: %s", e)
145 rospy.logwarn(
"Failed to lookup tf: %s", e)