-
Notifications
You must be signed in to change notification settings - Fork 6
/
demo_robot_safe.py
31 lines (25 loc) · 991 Bytes
/
demo_robot_safe.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import rospy
import moveit_commander
from std_msgs.msg import Float64MultiArray
from shadow_teleop.srv import *
def main():
rospy.init_node('shadow_safe_mode_teleop')
mgi = moveit_commander.MoveGroupCommander("right_hand")
rospy.sleep(1)
while not rospy.is_shutdown():
joints_msg = rospy.wait_for_message("/teleop_outputs_joints", Float64MultiArray)
goal = joints_msg.data
start = mgi.get_current_joint_values()
# collision check and manipulate
csl_client = rospy.ServiceProxy('CheckSelfCollision', checkSelfCollision)
try:
shadow_pos = csl_client(start, goal)
if shadow_pos.result:
rospy.loginfo("Move Done!")
else:
rospy.logwarn("Failed to move!")
except rospy.ServiceException as exc:
rospy.logwarn("Service did not process request: " + str(exc))
rospy.loginfo("Next one please ---->")
if __name__ == "__main__":
main()