-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontrolrp.py
More file actions
45 lines (31 loc) · 943 Bytes
/
controlrp.py
File metadata and controls
45 lines (31 loc) · 943 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
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/env python
#from __future__ import print_function
import roslib
import sys
import rospy
from std_msgs.msg import Float64
from std_msgs.msg import String
from sensor_msgs.msg import LaserScan
class motor_control:
speed=0
def __init__(self):
print('aaaaa')
self.rate = rospy.Rate(10)
self.timer_to_sending_data=0
self.speed = rospy.Publisher('/commands/motor/speed', Float64, queue_size=1)
self.position = rospy.Publisher('/commands/servo/position', Float64, queue_size=1)
rospy.Subscriber('/scan',LaserScan,self.callback)
while not rospy.is_shutdown():
self.speed_value=1200
self.position_value=0.5
self.speed.publish(self.speed_value)
self.position.publish(self.position_value)
self.rate.sleep()
def callback(self):
print(" call back ")
def main(args):
rospy.init_node('motor_control',anonymous=True)
motor_control()
rospy.spin()
if __name__=='__main__':
main(sys.argv)