-
Notifications
You must be signed in to change notification settings - Fork 63
Expand file tree
/
Copy pathgripper_node.py
More file actions
executable file
·59 lines (47 loc) · 1.27 KB
/
gripper_node.py
File metadata and controls
executable file
·59 lines (47 loc) · 1.27 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/env python
'''
# File Name : gripper_node.py
# Author : Kiru Park, Mainly refered from Joey Song's pump_node.py
# Version : V1.0
# Date : 24 May, 2017
# Modified Date : 24 May, 2017
# Description : This documents is for uarm ROS Library and ROS package
'''
# All libraries needed to import
# Import system library
import rospy
import sys
from std_msgs.msg import String
# raise error
def raiseError():
print 'ERROR: Input Incorrect'
print 'ERROR: Input off / low / 0 or on / high / 1'
# main exection function
def execute():
# define publisher and its topic
pub = rospy.Publisher('gripper_str_control',String,queue_size = 10)
rospy.init_node('gripper_node',anonymous = True)
rate = rospy.Rate(10)
# process different inputs
if len(sys.argv) == 2:
data_input = sys.argv[1]
# control pump on
if data_input.lower() == 'on' or data_input == '1' or data_input.lower() == 'high':
pub.publish('on')
# control pump off
elif data_input.lower() == 'off' or data_input == '0' or data_input.lower() == 'low':
pub.publish('off')
else:
raiseError()
else:
raiseError()
rate.sleep()
# main function
if __name__ == '__main__':
try:
execute()
except:
print '=========================================='
print 'ERROR: exectuion error'
raiseError()
pass