2.2.4.2. finish_line_detection module

ROS module to detect finish line in landmarks. Publish finish line, count laps and announce completed mission.

class finish_line_detection.AutonomousMissionEnum(value)[source]

Bases: Enum

Enum to describe which Autonomous Mission is currently select.

Table 2.2 Mission IDs

Mission ID

Mission Name

0

Manual Driving

1

Acceleration

2

Skidpad

3

Trackdrive

4

Braketest / EBS Test

5

Inspection

6

Autocross

ACCELERATION = 1
AUTOCROSS = 6
BRAKETEST = 4
INSPECTION = 5
MANUAL_DRIVING = 0
SKIDPAD = 2
TRACKDRIVE = 3
class finish_line_detection.FinishLineDetection[source]

Bases: object

ROS module to detect finish line in global landmarks. Publish finish line, count laps & announce completed mission.

Uses landmarks (big orange cones) estimated by SLAM to detect finish line. Uses vehicle pose estimated by SLAM to count and publish laps when crossing the finish line. Therefore an area with a hysteris around the finish line cones is used to detect when the area is entered and left. When reaching the maximum laps for the respective Autonomous Mission, it is announced via ROS that the mission is completed.

../../_images/finish_line_boxes.svg

Fig. 2.3 Parameters and attributes for finish line search, enter and leave box when staging the vehicle.

mission

Current Autonomous Mission which is being driven.

Type:

AutonomousMissionEnum

big_orange_id

ID which identifies big orange cones.

Type:

int

inside

Indicates whether the vehicle currently is inside or outside the area around the finish line.

Type:

bool

lap_count

Current driven laps, can be negative. This signalizes that the first lap is still driven and the finish line has not been crossed, but will be during the first lap due to the track layout of the Autonomous Mission, e.g. skidpad or trackdrive.

Type:

int

lap_count_publisher

ROS publisher to publish the current lap count.

Type:

rospy.Publusher

finish_line_enter

Polygon representing box to use to detect entering the finish line area. Smaller than finish_line_leave.

Type:

Optional[npt.NDArray]

finish_line_leave

Polygon representing box to use to detect entering the finish line area. Bigger than finish_line_enter.

Type:

Optional[npt.NDArray]

finish_line_marker_publisher

ROS publisher to publish visualization markers to visualize enter and leave box of finish line area.

Type:

rospy.Publisher

finish_line_search_marker_publisher

ROS Publisher to publish visualization markers to visualize search box where the finish line area is searched.

Type:

rospy.Publisher

mission_completed_publisher

ROS Publisher to announce that the mission is completed due to driving the required laps.

Type:

rospy.Publisher

landmark_subscriber

ROS subscriber to receive landmarks to detect finish line. Gets unregistered after detecting the finish line.

Type:

Optional

vehicle_subscriber

ROS subscriber to receive current vehicle pose to detect entering and leaving finish line area to count laps. Gets registered after detecting the finish line.

Type:

Optional

vehicle_x_offset

Number of meters between foremost point of vehicle and rear axle of vehicle. Used to specify search area relative to foremost point of vehicle.

Type:

float

search_box_additional_width

Half of the width of the search box.

Type:

float

search_box_additional_height

Half of the height of the search box.

Type:

float

enter_box_additional_width

Width to add to polygon around detected finish line to use it as box to detect entering the finish line area.

Type:

float

enter_box_additional_height

Height to add to polygon around detected finish line to use it as box to detect entering the finish line area.

Type:

float

leave_box_additional_width

Width to add to polygon around detected finish line to use it as box to detect leaving the finish line area.

Type:

float

leave_box_additional_height

Height to add to polygon around detected finish line to use it as box to detect leaving the finish line area.

Type:

float

max_laps

Laps to be driven for the current Autonomous Mission.

Type:

int

initial_distance

Longitudinal distance between foremost point of vehicle and middle finish line when staging the vehicle.

Type:

float

Initialize finish line detection ROS module.

acceleration()[source]

Run finish line detection when driving acceleration.

Lap count is kept at 0, since first lap is finished when finish line is crossed.

Callback for landmarks estimated by SLAM is set. As soon as the finish line is detected, callback for vehicle pose is set so that finish line detection can count the driven laps.

finish_line_landmark_callback(cone_list: ConeListWithCovariance)[source]

Receive landmarks estimated by SLAM and received via ROS. Generate finish line from them if possible.

Passes cones in search area to function to generate finish line. Unregisters landmark subscriber as soon as finish line has been detected.

Parameters:

cone_list (ConeListWithCovariance) – Landmarks estimated by SLAM.

generate_finish_line(cones: ndarray[Any, dtype[ScalarType]])[source]

Generate finish line from cones in search box if possible.

There need to be atleas four big orange cones and the resulting rectangle has to has atleats a specific size. Publishes enter and leave box representing finish line if finish has been detected.

Parameters:

cones (npt.NDArray) – Big orange cones estimated by SLAM which are in the search box.

generate_finish_line_marker(points: ndarray[Any, dtype[ScalarType]]) Marker[source]

Generate visualization marker representing finish line for given poins.

Parameters:

points (npt.NDArray) – Points representing finish line as polygon. First point will be repeated to close the polyogon.

Returns:

Visualization marker for ROS.

Return type:

Marker

lap_count_vehicle_callback(vehicle_pose: VehiclePose)[source]

Receive vehicle pose and increase lap count if leave box has been left after enter box has been entered before.

Vehicle pose is estimated by SLAM and received via ROS. Publish lap count if increased.

Publish that mission is completed when max laps has been reached.

Parameters:

vehicle_pose (VehiclePose) – Received vehicle pose received via ROS and estimated by SLAM.

map_alignment_callback(msg: MapAlignment)[source]

Receive map alignment estimated by SLAM and received via ROS. Update search box when vehicle is aligned.

Parameters:

msg (MapAlignment) – Map alignment estimated by SLAM.

Publish finish line search box as visualization marker to ROS.

publish_lap_count()[source]

Publish current lap count to ROS.

run()[source]

Run finish line detection by calling the respective function based on the current AS Mission.

skidpad()[source]

Run finish line detection when driving skidpad.

Lap count is set to -1, since first lap is started when intersection has been crossed the first time.

Callback for landmarks estimated by SLAM is set. As soon as the finish line is detected, callback for vehicle pose is set so that finish line detection can count the driven laps.

trackdrive_and_autocross()[source]

Run finish line detection when driving trackdrive or autocross.

Lap count is set to -1, since car is staged before the start & finish line and thus finish line is crossed while driving the first lap.

Callback for landmarks estimated by SLAM is set. As soon as the finish line is detected, callback for vehicle pose is set so that finish line detection can count the driven laps.