Skip to content

Commit 696945b

Browse files
committed
Add server to suppress realtime monitoring
of - suppress_body_avoidance - suppress_collision_avoidance - suppress_contact_safety - suppress_cuff_interaction - suppress_gravity_compensation - suppress_hand_overwrench_safety
1 parent aea70d9 commit 696945b

File tree

3 files changed

+146
-0
lines changed

3 files changed

+146
-0
lines changed

CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ generate_dynamic_reconfigure_options(
2222
cfg/PositionFFJointTrajectoryActionServer.cfg
2323
cfg/GripperActionServer.cfg
2424
cfg/HeadActionServer.cfg
25+
cfg/SuppressRealtimeMonitoringServer.cfg
2526
)
2627

2728
add_dependencies(${PROJECT_NAME}_gencfg baxter_core_msgs_generate_messages_py)
+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#!/usr/bin/env python
2+
3+
# Copyright (c) 2016, Kentaro Wada
4+
# All rights reserved.
5+
#
6+
# Redistribution and use in source and binary forms, with or without
7+
# modification, are permitted provided that the following conditions are met:
8+
#
9+
# 1. Redistributions of source code must retain the above copyright notice,
10+
# this list of conditions and the following disclaimer.
11+
# 2. Redistributions in binary form must reproduce the above copyright
12+
# notice, this list of conditions and the following disclaimer in the
13+
# documentation and/or other materials provided with the distribution.
14+
# 3. Neither the name of the Kentaro Wada nor the names of its
15+
# contributors may be used to endorse or promote products derived from
16+
# this software without specific prior written permission.
17+
#
18+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21+
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
22+
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23+
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24+
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25+
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26+
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27+
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28+
# POSSIBILITY OF SUCH DAMAGE.
29+
30+
from dynamic_reconfigure.parameter_generator_catkin import ParameterGenerator
31+
from dynamic_reconfigure.parameter_generator_catkin import bool_t
32+
33+
34+
PKG = 'baxter_interface'
35+
NAME = 'SuppressRealtimeMonitoringServer'
36+
37+
38+
gen = ParameterGenerator()
39+
40+
arms = ['left', 'right']
41+
42+
params = [
43+
'suppress_body_avoidance',
44+
'suppress_collision_avoidance',
45+
'suppress_contact_safety',
46+
'suppress_cuff_interaction',
47+
'suppress_gravity_compensation',
48+
'suppress_hand_overwrench_safety',
49+
]
50+
51+
for arm in arms:
52+
for param in params:
53+
gen.add(
54+
arm + '_' + param, bool_t, 0,
55+
param.capitalize().replace('_', ' ') + '.',
56+
False,
57+
)
58+
59+
exit(gen.generate(PKG, '', NAME))
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
#!/usr/bin/env python
2+
3+
# Copyright (c) 2016, Kentaro Wada
4+
# All rights reserved.
5+
#
6+
# Redistribution and use in source and binary forms, with or without
7+
# modification, are permitted provided that the following conditions are met:
8+
#
9+
# 1. Redistributions of source code must retain the above copyright notice,
10+
# this list of conditions and the following disclaimer.
11+
# 2. Redistributions in binary form must reproduce the above copyright
12+
# notice, this list of conditions and the following disclaimer in the
13+
# documentation and/or other materials provided with the distribution.
14+
# 3. Neither the name of the Kentaro Wada nor the names of its
15+
# contributors may be used to endorse or promote products derived from
16+
# this software without specific prior written permission.
17+
#
18+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21+
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
22+
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23+
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24+
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25+
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26+
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27+
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28+
# POSSIBILITY OF SUCH DAMAGE.
29+
30+
import os
31+
32+
from dynamic_reconfigure.server import Server
33+
import rospy
34+
from std_msgs.msg import Empty
35+
36+
from baxter_interface.cfg import SuppressRealtimeMonitoringServerConfig
37+
38+
39+
class SuppressRealtimeMonitoringServer(object):
40+
41+
arms = ['left', 'right']
42+
43+
params = [
44+
'suppress_body_avoidance',
45+
'suppress_collision_avoidance',
46+
'suppress_contact_safety',
47+
'suppress_cuff_interaction',
48+
'suppress_gravity_compensation',
49+
'suppress_hand_overwrench_safety',
50+
]
51+
52+
def __init__(self):
53+
# Initialize config and set dynamic parameter server
54+
self.config = {}
55+
self.dynparam_server = Server(
56+
SuppressRealtimeMonitoringServerConfig, self._dynparam_cb)
57+
# Initialize config and publishers
58+
self.publishers = {}
59+
for arm in self.arms:
60+
for param in self.params:
61+
key = arm + '_' + param
62+
self.publishers[key] = rospy.Publisher(
63+
os.path.join('/robot/limb', arm, param), Empty,
64+
queue_size=1)
65+
# Set timer with 10Hz
66+
# and it's enough because 5Hz is requested for supression
67+
self.timer = rospy.Timer(
68+
rospy.Duration(1.0 / 10), self.suppress_timer_cb)
69+
70+
def _dynparam_cb(self, config, level):
71+
for arm in self.arms:
72+
for param in self.params:
73+
key = arm + '_' + param
74+
self.config[key] = config[key]
75+
return config
76+
77+
def suppress_timer_cb(self, event):
78+
for key, pub in self.publishers.items():
79+
if self.config[key]:
80+
pub.publish(Empty())
81+
82+
83+
if __name__ == '__main__':
84+
rospy.init_node('suppress_realtime_monitoring_server')
85+
server = SuppressRealtimeMonitoringServer()
86+
rospy.spin()

0 commit comments

Comments
 (0)