Welcome to ROSMASTER M1 repository
11. Speed limit
Speed limit
1. Course Content
Note: This program runs on a sandbox map; you will need to adjust the program for your personal map.
- Learn the actions the car takes after recognizing speed limit
- Learn the newly emerging key source code
2. Road sign detection
Road sign detection source code path:
xxxxxxxxxx/home/jetson/yahboomcar_auto/src/auto_driver/scripts/auto_drive.py
3. Program Startup
3.1 Startup Command
- Parameter configuration
Parameter path: /home/jetson/yahboomcar_auto/src/auto_driver/config/auto_drive_node.yaml
xxxxxxxxxxturn_radius0.4linear_speed0.13angular_speed-0.55duration2.0response_distance_12900response_distance_2132cooldown_time0.2DEBUG_MODEFalseDEBUG_MODE_2TrueSTART_AutoDriveTrueKp-0.62Ki0.0Kd-0.1max_integral1000.0image_size640 480After modifying parameters, restart the launch file to use the modified parameters
- Start camera + chassis + autonomous driving node (need to run in virtual environment terminal)
xxxxxxxxxxroslaunch auto_driver auto_drive.launch
After successful startup, the display will show but the car will not move, for testing road sign recognition. (If you want the car to move, change the parameter START_AutoDrive in auto_drive_node.yaml to True)

After the program runs, the YOLO recognition screen will be displayed. The car will run centered on the lane lines and perform corresponding actions based on the road signs recognized during driving.
3.2 Car movement after recognizing speed limit
When the program recognizes speed limit, the program will decelerate for 3 seconds then return to normal

The car will decelerate for 3 seconds while driving

The fixed point parking handling function is in the auto_drive.py file. Below is the function that is entered after recognizing speed limit. Users can modify the car's movement after recognizing the road sign themselves.
xxxxxxxxxxdef slow_down(self): rospy.loginfo('Slow down') self.flag = True #Indicates temporary lane line driving self._set_current_speed(linear_x=0.08) time.sleep(3.0) self.flag = False4. Source Code Analysis
4.1、auto_drive.py
YOLO signpost message reception:
xxxxxxxxxxresults = self.sign_detect.get_infer_result(frame, True)annotated_frame = frame.copy()Multiple filtering mechanisms: mainly to prevent continuously recognizing road signs and triggering actions; the action will only be unlocked when different road signs are recognized.
xxxxxxxxxx # If a sign that requires cooldown is detected, start cooldownif detected_sign_requires_cooldown: self.sign_cooldown = True self.last_sign_time = current_time rospy.loginfo(f"Sign detected, starting {self.cooldown_duration}s cooldown") # Check if the repeated sign should be ignoredshould_ignore = Falseif obj.class_name == self.last_sign: should_ignore = TrueEvent queue processing
xxxxxxxxxxdef _event_handling_worker(self): '''Event handling worker thread''' # Sign handling mapping table sign_handlers = { "straight": self.go_straight, "turnright": lambda: self.turn('right'), "turnright_ground": self.do_nothing, "honking": self.car_horn, "sidewalk": self.slow_down, "sidewalk_ground": self.do_nothing, "speedlimit": self.slow_down, "stop": self.stop, "school": self.school, "parkA": self.parking_A, "parkB": self.parking_A, "greenlight": self.go_straight, "redlight": self.red_stop, "yellowlight": self.stop, "out_park": self.out_parking } # Sign enable index mapping sign_enable_map = { "straight": 10, "turnright": 11, "honking": 1, "sidewalk": 6, "sidewalk_ground": 7, "speedlimit": 8, "stop": 9, "school": 5, "parkA": 2, "parkB": 3, "greenlight": 0, "redlight": 4, "yellowlight": 13 } Specific action implementation
xxxxxxxxxxdef slow_down(self): rospy.loginfo('Slow down') self.flag = True self._set_current_speed(linear_x=0.08) time.sleep(3.0) self.flag = False