carla-simulator / ros-bridge

ROS bridge for CARLA Simulator
MIT License
522 stars 422 forks source link

question about carla_waypoint_publisher #206

Closed atinfinity closed 4 years ago

atinfinity commented 4 years ago

System information (version)

Detailed description

I tried to use carla_waypoint_publisher. I think that carla_waypoint_publisher publish unintended waypoint. Is this intended behavier?

Case1

At first time, I don't set initial pose using RViz. But, carla_waypoint_publisher published waypoint.

Screenshot from 2019-11-13 09-22-07

Case2

I set initial pose and goal using RViz. But, carla_waypoint_publisher published unintended waypoint. (red line: Goal, green path: published waypoint)

Screenshot from 2019-11-13 09-29-07

Screenshot from 2019-11-13 09-35-14

Steps to reproduce

Case1

$ ./CarlaUE4.sh -windowed -ResX=160 -ResY=120
$ roslaunch carla_ros_bridge carla_ros_bridge_with_example_ego_vehicle.launch
$ roslaunch carla_waypoint_publisher carla_waypoint_publisher.launch

Case2

$ ./CarlaUE4.sh -windowed -ResX=160 -ResY=120
$ roslaunch carla_ros_bridge carla_ros_bridge_with_example_ego_vehicle.launch
$ roslaunch carla_waypoint_publisher carla_waypoint_publisher.launch

And,

fpasch commented 4 years ago

That's intended behavior. See in code: Initially the first spawn_point is used.

atinfinity commented 4 years ago

@fpasch Thank you for your reply.

See in code: Initially the first spawn_point is used.

In this case, start and goal are same position. So, I think that carla_waypoint_publisher should not generate many waypoints.

Currently carla_waypoint_publisher add offset to calculate a route from the current location to goal. Is there the reason for this offset? https://github.com/carla-simulator/ros-bridge/blob/28d4ef607e07d217b873e35aee768d0a11b1bfa5/carla_waypoint_publisher/src/carla_waypoint_publisher/carla_waypoint_publisher.py#L77

I made simple validation code.

import carla
from agents.navigation.global_route_planner import GlobalRoutePlanner
from agents.navigation.global_route_planner_dao import GlobalRoutePlannerDAO

host = "127.0.0.1"
port = 2000

carla_client = carla.Client(host=host, port=port)
carla_client.set_timeout(2)
world = carla_client.get_world()

for actor in world.get_actors():
    if actor.attributes.get('role_name') == 'ego_vehicle':
        ego_vehicle = actor
        break

location = ego_vehicle.get_location()
print(location)

map = world.get_map()
dao = GlobalRoutePlannerDAO(map)
grp = GlobalRoutePlanner(dao)
grp.setup()

z_offset = 2.0
start = location
end   = carla.Location(location.x, location.y, location.z + z_offset)
route = grp.trace_route(start, end)
print("number of waypoint = {}".format(len(route)))

In this code, GlobalRoutePlanner generated 274 points(this value depends on current location and map). I changed z_offset to zero, GlobalRoutePlanner generated 1 point.

As a result, I think that this is a problem how to set goal in carla_waypoint_publisher.

fpasch commented 4 years ago

That offset was added because there were issues with spawning into the ground. That might be solved with newer CARLA versions.

Although you might be right, this is currently more a "feature" than a bug. Because for demo purposes, the car should start driving by default.

What exactly do you want to achieve? Maybe it would make sense the add the goal to the launch file. (Similar to the ego vehicle spawn point, that can be specified here.