ucar 84e7bb3908 feat: add visual line-following task há 1 mês atrás
..
config 84e7bb3908 feat: add visual line-following task há 1 mês atrás
launch 84e7bb3908 feat: add visual line-following task há 1 mês atrás
scripts 84e7bb3908 feat: add visual line-following task há 1 mês atrás
srv 84e7bb3908 feat: add visual line-following task há 1 mês atrás
.gitignore 84e7bb3908 feat: add visual line-following task há 1 mês atrás
CMakeLists.txt 84e7bb3908 feat: add visual line-following task há 1 mês atrás
README.md 84e7bb3908 feat: add visual line-following task há 1 mês atrás
package.xml 84e7bb3908 feat: add visual line-following task há 1 mês atrás

README.md

traffic_line_task

This package owns the competition phase that starts after navigation has stopped at the LED sign point. It does not start a camera or base driver.

Route policy:

  • STOP and NONE: remain stationary and keep recognising.
  • LEFT or RIGHT: execute the calibrated first junction maneuver, reacquire the lane, then finish after the final lane has continuously disappeared.
  • STRAIGHT: enter the centre route, use odometry only to arm the expected second-junction region, drive straight for a configured duration after confirmed lane loss, trigger its fixed right maneuver, then continue following until the final lane has continuously disappeared.

With use_finish_distance_limits: false, odometry does not terminate either finish segment. Final lane loss stops the vehicle immediately and is confirmed for finish_lane_loss_confirm_time before entering FINISHED. A stable lane that returns during confirmation resumes the same segment. Junction maneuvers still retain their calibrated odometry limits and safety checks.

On FINISHED, the state machine publishes 任务完成 exactly once on /speech_command/announce. The separately started speech_command node owns the actual TTS playback; this package never starts a second speech node.

For endpoint inspection, stop_after_second_maneuver: true makes the state machine enter FINISHED immediately after that fixed right maneuver and keeps line following disabled. Set it back to false after the turn endpoint has been verified.

Route distances live in config/traffic_line_task.yaml. The state machine reports CONFIG_INVALID and cannot move if any required value is zero or negative.

Route-distance calibration

The calibration node only reads /odom; it never opens the camera, starts the base driver, or publishes /cmd_vel. Start it beside the already-running base:

source ~/ucar_ws/devel/setup.bash
roslaunch traffic_line_task route_distance_calibration.launch

At the beginning of one segment, reset the measurement, move the vehicle with the same low-speed maneuver or line-follow controller that will be used in the task, and then mark the endpoint. For example:

rosservice call /route_distance_calibrator/reset "{}"
rosservice call /route_distance_calibrator/mark \
  "label: 'first_left_turn_distance_m'"

The response contains path distance and accumulated yaw. Repeat the segment at least three times and put a conservative repeatable value in config/traffic_line_task.yaml. Valid labels are exactly the seven distance keys in that file.

The single-boundary fallback remains implemented by line_follow_debug.py. If no valid lane target remains, this state machine disables line control, stops in place, and waits up to two seconds for a stable target before entering FAULT.

After calibration, start the already-shared camera and base driver, stop every other /cmd_vel source, and run:

source ~/ucar_ws/devel/setup.bash
roslaunch traffic_line_task traffic_line_task.launch

Monitor:

rostopic echo /traffic_line_task/state
rostopic echo /traffic_line_task/segment_distance

Abort or reset:

rosservice call /traffic_line_task/abort "{}"
rosservice call /traffic_line_task/reset "{}"