-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdrive.py
More file actions
35 lines (20 loc) · 734 Bytes
/
drive.py
File metadata and controls
35 lines (20 loc) · 734 Bytes
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
#!/usr/bin/env python
# ROS
import rospy
from std_msgs.msg import Float32
from std_msgs.msg import String
pub_setVelocity = rospy.Publisher('/motor/CmdSetVelocity', Float32, queue_size=10)
pub_setEvent = rospy.Publisher('/motor/CmdSetEvent', String, queue_size=10)
def command(command):
[driveData, eventData] = command.split(" : ")
print(driveData)
print(eventData)
[velocity, velocityValue] = driveData.split("=")
pub_setEvent.publish(eventData)
pub_setVelocity.publish(float(velocityValue))
def driveStraight():
pub_setVelocity.publish(float(velocityValue))
if __name__ == '__main__':
rospy.init_node('node_drive', anonymous=True)
command("vel=1.2 : dist=1")
rospy.spin()