Carla修改车辆属性

车辆和轮胎的属性可以再运行期调节,当运行结束后所有设置会回到初始状态。

代码示例:

import carla

import random

def main(): 

# Connect to client 

client = carla.Client('127.0.0.1', 2000)

client.set_timeout(2.0)

# Get World and Actors 

world = client.get_world()

actors = world.get_actors()

# Get a random vehicle from world (there should be one at least)  vehicle = random.choice([actor for actor in actors if 'vehicle' in  actor.type_id])

# Create Wheels Physics Control 

front_left_wheel = carla.WheelPhysicsControl(tire_friction=2.0, damping_rate=1.5, max_steer_angle=70.0, long_stiff_value=1000)

front_right_wheel = carla.WheelPhysicsControl(tire_friction=2.0, damping_rate=1.5, max_steer_angle=70.0, long_stiff_value=1000)

rear_left_wheel = carla.WheelPhysicsControl(tire_friction=3.0, damping_rate=1.5, max_steer_angle=0.0, long_stiff_value=1000)

rear_right_wheel = carla.WheelPhysicsControl(tire_friction=3.0, damping_rate=1.5, max_steer_angle=0.0, long_stiff_value=1000)

wheels = [front_left_wheel, front_right_wheel, rear_left_wheel, rear_right_wheel]

# Change Vehicle Physics Control parameters of the vehicle  physics_control = vehicle.get_physics_control()

physics_control.torque_curve = [carla.Vector2D(x=0, y=400),        carla.Vector2D(x=1300, y=600)]

physics_control.max_rpm = 10000

physics_control.moi = 1.0 

physics_control.damping_rate_full_throttle = 0.0

physics_control.use_gear_autobox = True

physics_control.gear_switch_time = 0.5

physics_control.clutch_strength = 10 

physics_control.mass = 10000

physics_control.drag_coefficient = 0.25

physics_control.steering_curve = [carla.Vector2D(x=0, y=1), carla.Vector2D(x=100, y=1), carla.Vector2D(x=300, y=1)]

physics_control.use_sweep_wheel_collision = True

physics_control.wheels = wheels

# Apply Vehicle Physics Control for the vehicle  vehicle.apply_physics_control(physics_control) print(physics_control)

if __name__ == '__main__': main()

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值