code: def test_vehicle_friction_volume(self):
      print("TestVehicleFriction.test_vehicle_friction_volume")
  
      self.client.load_world("Town05_Opt", False)
      # workaround: give time to UE4 to clean memory after loading (old assets)
      time.sleep(5)
  
      bp_vehicles = self.world.get_blueprint_library().filter(
          "*charger_2020"
      )
  
      value_vol_friction = 5.0
      friction_bp = self.world.get_blueprint_library().find(
          "static.trigger.friction"
      )
      friction_bp.set_attribute("friction", str(value_vol_friction))
      extent = carla.Location(300.0, 4500.0, 700.0)
      friction_bp.set_attribute("extent_x", str(extent.x))
      friction_bp.set_attribute("extent_y", str(extent.y))
      friction_bp.set_attribute("extent_z", str(extent.z))
  
      vol_transf = carla.Transform(carla.Location(27, -100, 1))
  
      self.world.debug.draw_box(
          box=carla.BoundingBox(vol_transf.location, extent * 1e-2),
          rotation=vol_transf.rotation,
          life_time=1000,
          thickness=0.5,
          color=carla.Color(r=0, g=255, b=0),
      )
      friction_trigger = self.world.spawn_actor(friction_bp, vol_transf)
  
      for bp_veh in bp_vehicles:
          veh_transf_00 = carla.Transform(
              carla.Location(36, -200, 0.2), carla.Rotation(yaw=90)
          )
          veh_transf_01 = carla.Transform(
              carla.Location(28, -200, 0.7), carla.Rotation(yaw=90)
          )
  
          batch = [
              SpawnActor(bp_veh, veh_transf_00).then(
                  ApplyTargetVelocity(
                      FutureActor, carla.Vector3D(0, 0, 0)
                  )
              ),
              SpawnActor(bp_veh, veh_transf_01).then(
                  ApplyTargetVelocity(
                      FutureActor, carla.Vector3D(0, 0, 0)
                  )
              ),
          ]
  
          responses = self.client.apply_batch_sync(batch)
  
          veh_ids = [x.actor_id for x in responses]
          veh_refs = [self.world.get_actor(x) for x in veh_ids]
  
          if (0 in veh_ids) or (None in veh_refs):
              self.fail(
                  "%s: The test cars could not be correctly spawned"
                  % (bp_veh.id)
              )
  
          self.wait(10)
  
          vel_ref = 50.0 / 3.6
          friction_ref = 0.0
  
          self.client.apply_batch_sync(
              [
                  ApplyVehiclePhysicsControl(
                      veh_refs[0],
                      change_physics_control(
                          veh_refs[0],
                          tire_friction=friction_ref,
                          drag=0.0,
                      ),
                  ),
                  ApplyVehiclePhysicsControl(
                      veh_refs[1],
                      change_physics_control(
                          veh_refs[1],
                          tire_friction=friction_ref,
                          drag=0.0,
                      ),
                  ),
              ]
          )
          self.wait(1)
  
          self.client.apply_batch_sync(
              [
                  ApplyTargetVelocity(
                      veh_refs[0], carla.Vector3D(0, vel_ref, 0)
                  ),
                  ApplyTargetVelocity(
                      veh_refs[1], carla.Vector3D(0, vel_ref, 0)
                  ),
              ]
          )
  
          self.wait(4)
  
          # Before trigger
          bef_vel_veh_00 = veh_refs[0].get_velocity().y
          bef_vel_veh_01 = veh_refs[1].get_velocity().y
          bef_tire_fr_00 = (
              veh_refs[0].get_physics_control().wheels[0].tire_friction
          )
          bef_tire_fr_01 = (
              veh_refs[1].get_physics_control().wheels[0].tire_friction
          )
          extent = carla.Location(100.0, 100.0, 200.0)
          self.world.debug.draw_box(
              box=carla.BoundingBox(
                  veh_refs[1].get_location(), extent * 1e-2
              ),
              rotation=vol_transf.rotation,
              life_time=8,
              thickness=0.5,
              color=carla.Color(r=255, g=0, b=0),
          )
  
          if not equal_tol(
              bef_vel_veh_00, vel_ref, 1e-3
          ) or not equal_tol(bef_tire_fr_00, friction_ref, 1e-3):
              self.fail(
                  "%s: Reference vehicle has changed before trigger. Vel: %.3f [%.3f]. Fric: %.3f [%.3f]"
                  % (
                      bp_veh.id,
                      bef_vel_veh_00,
                      vel_ref,
                      bef_tire_fr_00,
                      friction_ref,
                  )
              )
          if not equal_tol(
              bef_vel_veh_01, vel_ref, 1e-3
          ) or not equal_tol(bef_tire_fr_01, friction_ref, 1e-3):
              self.fail(
                  "%s: Test vehicle has changed before trigger. Vel: %.3f [%.3f]. Fric: %.3f [%.3f]"
                  % (
                      bp_veh.id,
                      bef_vel_veh_01,
                      vel_ref,
                      bef_tire_fr_01,
                      friction_ref,
                  )
              )
  
          self.wait(100)
  
          # Inside trigger
          ins_vel_veh_00 = veh_refs[0].get_velocity().y
          ins_vel_veh_01 = veh_refs[1].get_velocity().y
          ins_tire_fr_00 = (
              veh_refs[0].get_physics_control().wheels[0].tire_friction
          )
          ins_tire_fr_01 = (
              veh_refs[1].get_physics_control().wheels[0].tire_friction
          )
  
          extent = carla.Location(100.0, 100.0, 200.0)
          self.world.debug.draw_box(
              box=carla.BoundingBox(
                  veh_refs[1].get_location(), extent * 1e-2
              ),
              rotation=vol_transf.rotation,
              life_time=8,
              thickness=0.5,
              color=carla.Color(r=255, g=0, b=0),
          )
  
          if not equal_tol(
              ins_vel_veh_00, vel_ref, 1e-3
          ) or not equal_tol(ins_tire_fr_00, friction_ref, 1e-3):
              self.fail(
                  "%s: Reference vehicle has changed inside trigger. Vel: %.3f [%.3f]. Fric: %.3f [%.3f]"
                  % (
                      bp_veh.id,
                      ins_vel_veh_00,
                      vel_ref,
                      ins_tire_fr_00,
                      friction_ref,
                  )
              )
          if ins_vel_veh_01 > vel_ref or not equal_tol(
              ins_tire_fr_01, value_vol_friction, 1e-3
          ):
              self.fail(
                  "%s: Test vehicle is not correct inside trigger. Vel: %.3f [%.3f]. Fric: %.3f [%.3f]"
                  % (
                      bp_veh.id,
                      ins_vel_veh_01,
                      vel_ref,
                      ins_tire_fr_01,
                      value_vol_friction,
                  )
              )
  
          self.wait(200)
  
          # Outside trigger
          out_vel_veh_00 = veh_refs[0].get_velocity().y
          out_vel_veh_01 = veh_refs[1].get_velocity().y
          out_tire_fr_00 = (
              veh_refs[0].get_physics_control().wheels[0].tire_friction
          )
          out_tire_fr_01 = (
              veh_refs[1].get_physics_control().wheels[0].tire_friction
          )
  
          extent = carla.Location(100.0, 100.0, 200.0)
          self.world.debug.draw_box(
              box=carla.BoundingBox(
                  veh_refs[1].get_location(), extent * 1e-2
              ),
              rotation=vol_transf.rotation,
              life_time=8,
              thickness=0.5,
              color=carla.Color(r=255, g=0, b=0),
          )
  
          if not equal_tol(
              out_vel_veh_00, vel_ref, 1e-3
          ) or not equal_tol(out_tire_fr_00, friction_ref, 1e-3):
              self.fail(
                  "%s: Reference vehicle has changed after trigger. Vel: %.3f [%.3f]. Fric: %.3f [%.3f]"
                  % (
                      bp_veh.id,
                      ins_vel_veh_00,
                      vel_ref,
                      out_tire_fr_00,
                      friction_ref,
                  )
              )
          if out_vel_veh_01 > vel_ref or not equal_tol(
              out_tire_fr_01, friction_ref, 1e-3
          ):
              self.fail(
                  "%s: Test vehicle is not correct after trigger. Vel: %.3f [%.3f]. Fric: %.3f [%.3f]"
                  % (
                      bp_veh.id,
                      out_vel_veh_01,
                      vel_ref,
                      out_tire_fr_01,
                      friction_ref,
                  )
              )
  
          self.client.apply_batch_sync(
              [carla.command.DestroyActor(x) for x in veh_ids]
          )
  
      friction_trigger.destroy()
  
imports: from .None import SyncSmokeTest
  from .None import SmokeTest
  import carla
  import time
  import math
  import numpy
  from enum import Enum
label_desc: Use image node_id 3 for calling the TestVehicleFriction obj's underlying member method code with example usage: obj.test_vehicle_friction_volume() without return types