Skip to content

Commit 8e35ab0

Browse files
authored
Updated to add speed sub
1 parent 4a1401b commit 8e35ab0

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

cart_planning/scripts/local_planner.py

+7
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ def __init__(self):
6767
# Allow nodes to make stop requests
6868
self.stop_sub = rospy.Subscriber('/stop', Stop, self.stop_callback, queue_size=10)
6969

70+
# Allows changes in speed
71+
self.set_speed_sub = rospy.Subscriber('/speed', Float32, self.speed_callback)
72+
7073
# Allow the sharing of the current staus of the vehicle driving
7174
self.vehicle_state_pub = rospy.Publisher('/vehicle_state', VehicleState, queue_size=10, latch=True)
7275

@@ -116,6 +119,10 @@ def stop_callback(self, msg):
116119
self.stop_requests[str(msg.sender_id.data).lower()] = [msg.stop, msg.distance]
117120
rospy.loginfo(str(msg.sender_id.data).lower() + " requested stop: " + str(msg.stop) + " with distance: " + str(msg.distance))
118121

122+
def speed_callback(self, msg):
123+
self.global_speed = msg.data / 3.6
124+
rospy.loginfo("Speed changed to " + str (self.global_speed))
125+
119126
def vel_callback(self, msg):
120127
if msg.data < 1.0:
121128
self.cur_speed = 1.8 # Magic number however this is roughly the observed speed in realtime

0 commit comments

Comments
 (0)