ucla-mobility / OpenCDA

A generalized framework for prototyping full-stack cooperative driving automation applications under CARLA+SUMO.
Other
988 stars 197 forks source link

float() argument must be a string or a number, not 'LineString' in single_intersection_town6_carla file #210

Closed SExpert12 closed 1 year ago

SExpert12 commented 1 year ago

I am working in Carla simulator. I required specific scenario for my simulation. So I have tried to run file named single_intersection_town06_carla and it it showing me error like "float() argument must be a string or a number, not 'LineString'". I traced the error and I found that in the file named core/map/map_manager.py the input is actually linestring. But I am not able to understand that how to solve this as shapely polygon and boundary function of polygon are completely new to me. How to resolve this error? Here I have written the same function of the file map_manager.py: def associate_lane_tl(self, mid_lane): """ Given the waypoints for a certain lane, find the traffic light that influence it.

    Parameters
    ----------
    mid_lane : np.ndarray
        The middle line of the lane.
    Returns
    -------
    associate_tl_id : str
        The associated traffic light id.
    """
    associate_tl_id = ''

    for tl_id, tl_content in self.traffic_light_info.items():

        trigger_poly = tl_content['corners']
        print("\n\n corners",tl_content['corners'])
        print("\n\n trigger_poly",trigger_poly) # printing values
        print(type(trigger_poly))
        # use Path to do fast computation

        trigger_path = Path(float(trigger_poly.boundary))

        print("trigger_path",type(trigger_poly.boundary))

        # check if any point in the middle line inside the trigger area
        check_array = trigger_path.contains_points(mid_lane[:, :2])

        if check_array.any():
            associate_tl_id = tl_id
    return associate_tl_id

LinestringError

DerrickXuNu commented 1 year ago

Hi, this is probably caused by the Shapely version. What is your Shapely version?

SExpert12 commented 1 year ago

Name: shapely Version: 2.0.1

DerrickXuNu commented 1 year ago

Yes, this is the reason. Please stick to the shapely version appeared in the requirement.txt

SExpert12 commented 1 year ago

Okay. But then I am getting problem with other packages.