src
jsk_teleop_joy
plugin
environment_plane_modeling_client.py
Go to the documentation of this file.
1
from
jsk_teleop_joy.joy_plugin
import
JSKJoyPlugin
2
from
jsk_rviz_plugins.msg
import
OverlayMenu
3
from
std_srvs.srv
import
Empty
4
5
import
rospy
6
7
class
EnvironmentPlaneModelingClient
(
JSKJoyPlugin
):
8
def
__init__
(self, name, args):
9
JSKJoyPlugin.__init__(self, name, args)
10
self.
menu_pub
= rospy.Publisher(
"/overlay_menu"
, OverlayMenu)
11
self.
menus
= [
12
[
"Append Pre-defined Polygon"
, self.
appendPreDefinedPolygon
],
13
[
"Register Current GridMap"
, self.
registerCurrentGridMap
],
14
[
"Clear Environment"
, self.
clearEnvironment
],
15
[
"Exit"
, self.
exit
]]
16
self.
clear_maps_srv
= rospy.ServiceProxy(
17
self.
getArg
(
"clear_maps"
,
"/env_server/clear_maps"
), Empty)
18
self.
register_current_map_srv
= rospy.ServiceProxy(
19
self.
getArg
(
"register_current_map"
,
"/env_server/register_to_hisotry"
), Empty)
20
self.
register_completed_map_srv
= rospy.ServiceProxy(
21
self.
getArg
(
"register_completed_map"
,
"/env_server/register_completion_to_hisotry"
), Empty)
22
self.
current_index
= 0
23
def
joyCB
(self, status, history):
24
# self.pub.publish(status.orig_msg)
25
if
history.new(status,
'up'
):
26
self.
upCursor
()
27
elif
history.new(status,
'down'
):
28
self.
downCursor
()
29
#publish menu anyway
30
if
history.new(status,
'cross'
):
31
self.
publishMenu
(close=
True
)
32
rospy.sleep(0.2)
33
self.
manager
.forceToPluginMenu(publish_menu=
False
)
34
elif
history.new(status,
'circle'
):
35
# call the function
36
func = self.
menus
[self.
current_index
][1]
37
func()
38
else
:
39
self.
publishMenu
()
40
def
downCursor
(self):
41
if
self.
current_index
== len(self.
menus
) - 1:
42
self.
current_index
= 0
43
else
:
44
self.
current_index
= self.
current_index
+ 1
45
def
upCursor
(self):
46
if
self.
current_index
== 0:
47
self.
current_index
= len(self.
menus
) - 1
48
else
:
49
self.
current_index
= self.
current_index
- 1
50
def
exit
(self):
#same to cross button
51
self.
publishMenu
(close=
True
)
52
rospy.sleep(0.2)
53
self.
manager
.forceToPluginMenu(publish_menu=
False
)
54
def
registerCurrentGridMap
(self):
55
try
:
56
self.
register_current_map_srv
()
57
except
rospy.ServiceException
as
e:
58
rospy.logfatal(
"failed to register current map: %s"
% (e))
59
def
appendPreDefinedPolygon
(self):
60
try
:
61
self.
register_completed_map_srv
()
62
except
rospy.ServiceException
as
e:
63
rospy.logfatal(
"failed to register completed current map: %s"
% (e))
64
def
clearEnvironment
(self):
65
try
:
66
self.
clear_maps_srv
()
67
except
rospy.ServiceException
as
e:
68
rospy.logfatal(
"failed to clear_map: %s"
% (e))
69
def
publishMenu
(self, close=False):
70
menu = OverlayMenu()
71
menu.menus = [m[0]
for
m
in
self.
menus
]
72
menu.current_index = self.
current_index
73
menu.title = self.
name
74
if
close:
75
menu.action = OverlayMenu.ACTION_CLOSE
76
self.
menu_pub
.publish(menu)
77
jsk_teleop_joy.plugin.environment_plane_modeling_client.EnvironmentPlaneModelingClient.register_completed_map_srv
register_completed_map_srv
Definition:
environment_plane_modeling_client.py:20
jsk_teleop_joy.plugin.environment_plane_modeling_client.EnvironmentPlaneModelingClient.current_index
current_index
Definition:
environment_plane_modeling_client.py:22
jsk_teleop_joy.plugin.environment_plane_modeling_client.EnvironmentPlaneModelingClient.downCursor
def downCursor(self)
Definition:
environment_plane_modeling_client.py:40
jsk_teleop_joy.joy_plugin.JSKJoyPlugin.name
name
Definition:
joy_plugin.py:7
jsk_teleop_joy.plugin.environment_plane_modeling_client.EnvironmentPlaneModelingClient.registerCurrentGridMap
def registerCurrentGridMap(self)
Definition:
environment_plane_modeling_client.py:54
jsk_teleop_joy.plugin.environment_plane_modeling_client.EnvironmentPlaneModelingClient
Definition:
environment_plane_modeling_client.py:7
jsk_teleop_joy.joy_plugin.JSKJoyPlugin.getArg
def getArg(self, key, default=None)
Definition:
joy_plugin.py:19
jsk_teleop_joy.joy_plugin.JSKJoyPlugin.manager
manager
Definition:
joy_plugin.py:9
jsk_teleop_joy.joy_plugin
Definition:
joy_plugin.py:1
jsk_teleop_joy.plugin.environment_plane_modeling_client.EnvironmentPlaneModelingClient.clearEnvironment
def clearEnvironment(self)
Definition:
environment_plane_modeling_client.py:64
jsk_teleop_joy.joy_plugin.JSKJoyPlugin
Definition:
joy_plugin.py:5
jsk_teleop_joy.plugin.environment_plane_modeling_client.EnvironmentPlaneModelingClient.exit
def exit(self)
Definition:
environment_plane_modeling_client.py:50
jsk_teleop_joy.plugin.environment_plane_modeling_client.EnvironmentPlaneModelingClient.publishMenu
def publishMenu(self, close=False)
Definition:
environment_plane_modeling_client.py:69
jsk_teleop_joy.plugin.environment_plane_modeling_client.EnvironmentPlaneModelingClient.upCursor
def upCursor(self)
Definition:
environment_plane_modeling_client.py:45
jsk_teleop_joy.plugin.environment_plane_modeling_client.EnvironmentPlaneModelingClient.menus
menus
Definition:
environment_plane_modeling_client.py:11
jsk_teleop_joy.plugin.environment_plane_modeling_client.EnvironmentPlaneModelingClient.menu_pub
menu_pub
Definition:
environment_plane_modeling_client.py:10
jsk_teleop_joy.plugin.environment_plane_modeling_client.EnvironmentPlaneModelingClient.register_current_map_srv
register_current_map_srv
Definition:
environment_plane_modeling_client.py:18
jsk_teleop_joy.plugin.environment_plane_modeling_client.EnvironmentPlaneModelingClient.appendPreDefinedPolygon
def appendPreDefinedPolygon(self)
Definition:
environment_plane_modeling_client.py:59
jsk_teleop_joy.plugin.environment_plane_modeling_client.EnvironmentPlaneModelingClient.clear_maps_srv
clear_maps_srv
Definition:
environment_plane_modeling_client.py:16
jsk_teleop_joy.plugin.environment_plane_modeling_client.EnvironmentPlaneModelingClient.__init__
def __init__(self, name, args)
Definition:
environment_plane_modeling_client.py:8
jsk_teleop_joy.plugin.environment_plane_modeling_client.EnvironmentPlaneModelingClient.joyCB
def joyCB(self, status, history)
Definition:
environment_plane_modeling_client.py:23
jsk_teleop_joy
Author(s): Ryohei Ueda
autogenerated on Wed Jan 24 2024 04:05:49