carla-simulator / carla

Open-source simulator for autonomous driving research.
http://carla.org
MIT License
11.28k stars 3.65k forks source link

Carla physics updates independant of fixed delta seconds #8316

Open 00Dan00 opened 4 hours ago

00Dan00 commented 4 hours ago

I am using the cloned carla version of 0.9.15 with Windows 11

Okay the issue is that using delta seconds of 0.1 my speed is the same at each tick as when using a value of 1.0. This is the code to reproduce, just use delta seconds of 1.0 instead of 0.1 on the second execute. Can someone explain why that is since I thought advancing the simulation by 0.1 10 times should give me the same results as advancing the simulation by 1.0 1 time. Also if I print the position after it's the same for both.

`import carla

def get_speed(vehicle): vel = vehicle.get_velocity() return 3.6 * ((vel.x2 + vel.y2 + vel.z2) 0.5)

def get_acceleration(vehicle): acc = vehicle.get_acceleration() return 3.6 * ((acc.x2 + acc.y2 + acc.z2) 0.5)

client = carla.Client('localhost', 2000) client.set_timeout(10.0)

world = client.get_world() settings = world.get_settings() settings.synchronous_mode = True settings.fixed_delta_seconds = 1.0 # 1.0 world.apply_settings(settings)

world = client.get_world() blueprint_library = world.get_blueprint_library() vehicle_bp = blueprint_library.filter('model3')[0]

spawn_points = world.get_map().get_spawn_points() vehicle = world.spawn_actor(vehicle_bp, spawn_points[0])

def get_simulation_time(world): snapshot = world.get_snapshot() return snapshot.timestamp.elapsed_seconds # Returns time in seconds

for _ in range(20): # let vehicle settle world.tick()

sim_time = get_simulation_time(world) vehicle.apply_control(carla.VehicleControl(throttle=0.5))

for _ in range(10): print(f"speed: {get_speed(vehicle)}, acceleration. {get_acceleration(vehicle)}") world.tick()

print("sim time passed", get_simulation_time(world) - sim_time) print(vehicle.get_location()) vehicle.destroy()`

so even tho my delta seconds are different and the time passed in the sim is different with different delta values, the speed and position are the same for all delta second values? How does that make any sense?

00Dan00 commented 4 hours ago

speed: 0.0, acceleration. 0.0 speed: 0.0023601035821462332, acceleration. 0.005900258850591793 speed: 0.005942367436371702, acceleration. 0.008955659531342992 speed: 0.004318828419316067, acceleration. 0.004058847791337838 speed: 0.0024789275402805756, acceleration. 0.0045997521568065134 speed: 0.0010964698624638491, acceleration. 0.00345614409396254 speed: 0.0008930511347715243, acceleration. 0.000508546888534781 speed: 0.0005362701373069897, acceleration. 0.000891952473268492 speed: 3.0986886161098326, acceleration. 7.746721534159592 speed: 6.359394870746378, acceleration. 8.151765889666153 sim time passed 10.0 Location(x=-64.266655, y=24.472057, z=0.001444)


speed: 0.0, acceleration. 0.0 speed: 0.0023601035821462332, acceleration. 0.023601035402367174 speed: 0.005942367436371702, acceleration. 0.03582263812537197 speed: 0.004318828419316067, acceleration. 0.016235391165351352 speed: 0.0024789275402805756, acceleration. 0.018399008627226054 speed: 0.0010964698624638491, acceleration. 0.01382457637585016 speed: 0.0008930511347715243, acceleration. 0.002034187554139124 speed: 0.0005362701373069897, acceleration. 0.003567809893073968 speed: 3.0986886161098326, acceleration. 30.98688613663837 speed: 6.359394870746378, acceleration. 32.60706355866461 sim time passed 1.0000000149011612 Location(x=-64.266655, y=24.472057, z=0.001444)