66TURN_NONE = 1
77TURN_LEFT = 2
88TURN_HAZARD = 3
9- TURN_AROUND = 4
109# For message format, see
1110# https://github.com/astuff/astuff_sensor_msgs/blob/3.3.0/pacmod_msgs/msg/PacmodCmd.msg
1211
@@ -48,19 +47,20 @@ def cleanup(self):
4847 def get_dir_distress (self ):
4948 pass
5049
51- def update (self ):
50+ def update (self , Allstate ):
5251 """Run in a loop"""
5352 # TODO: Implement your control loop here
5453 # You will need to publish a PacmodCmd() to /pacmod/as_rx/turn_cmd. Read the documentation to see
5554 # what the data in the message indicates.
5655 #self.turn_cmd = PacmodCmd()
5756 # TODO change to actual direction in Part 2
58- if self .turn_cmd .ui16_cmd == TURN_NONE :
59- self .turn_cmd .ui16_cmd = TURN_LEFT
60- elif self .turn_cmd .ui16_cmd == TURN_LEFT :
61- self .turn_cmd .ui16_cmd = TURN_RIGHT
62- else :
63- self .turn_cmd .ui16_cmd = TURN_NONE
57+ if Allstate .intent .intent == "HALTING" :
58+ if self .turn_cmd .ui16_cmd == TURN_NONE :
59+ self .turn_cmd .ui16_cmd = TURN_LEFT
60+ elif self .turn_cmd .ui16_cmd == TURN_LEFT :
61+ self .turn_cmd .ui16_cmd = TURN_RIGHT
62+ else :
63+ self .turn_cmd .ui16_cmd = TURN_NONE
6464 self .turn_blink_pub .publish (self .turn_cmd )
6565
6666 pass
@@ -97,7 +97,7 @@ def accel_callback(self, msg):
9797 rospy .loginfo (f"Output: { msg .output } (Final Output to Vehicle)" )
9898 rospy .loginfo ("---------------------------\n " )
9999
100- def run_ros_loop (node ):
100+ def run_ros_loop (node , Allstate ):
101101 """Executes the event loop of a node using ROS. `node` should support
102102 rate(), initialize(), cleanup(), update(), and done(). You should not modify
103103 this code.
@@ -111,7 +111,7 @@ def run_ros_loop(node):
111111 termination_reason = "undetermined"
112112 try :
113113 while not rospy .is_shutdown () and not node .done () and node .healthy ():
114- node .update ()
114+ node .update (node , Allstate )
115115 rate .sleep ()
116116 if node .done ():
117117 termination_reason = "Node done"
0 commit comments