Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:CARLA simulator Carla VehicleControl

From Leeroopedia
Revision as of 12:15, 16 February 2026 by Admin (talk | contribs) (Auto-imported from implementations/CARLA_simulator_Carla_VehicleControl.md)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Knowledge Sources
Domains Vehicle Control, RPC Serialization
Last Updated 2026-02-15 05:00 GMT

Overview

VehicleControl is an RPC-serializable class that holds the standard vehicle control inputs: throttle, steer, brake, hand brake, reverse, manual gear shift, and gear selection.

Description

Defined in the carla::rpc namespace (~100 lines), this class represents the basic vehicle control interface with seven parameters:

  • throttle (float, 0.0-1.0): engine throttle amount
  • steer (float, -1.0 to 1.0): steering input
  • brake (float, 0.0-1.0): brake pedal amount
  • hand_brake (bool): hand brake engaged
  • reverse (bool): reverse gear engaged
  • manual_gear_shift (bool): manual transmission mode
  • gear (int32_t): current gear number

The class supports MsgPack serialization, equality operators, and UE4 conversion to/from FVehicleControl when compiled within Unreal Engine.

Usage

Use this type to apply standard vehicle control commands (throttle/steer/brake) to vehicles via the CARLA client API.

Code Reference

Source Location

  • Repository: CARLA
  • File: LibCarla/source/carla/rpc/VehicleControl.h

Signature

namespace carla {
namespace rpc {

  class VehicleControl {
  public:
    VehicleControl() = default;
    VehicleControl(float throttle, float steer, float brake,
        bool hand_brake, bool reverse,
        bool manual_gear_shift, int32_t gear);

    float throttle = 0.0f;
    float steer = 0.0f;
    float brake = 0.0f;
    bool hand_brake = false;
    bool reverse = false;
    bool manual_gear_shift = false;
    int32_t gear = 0;

    bool operator!=(const VehicleControl &rhs) const;
    bool operator==(const VehicleControl &rhs) const;

    MSGPACK_DEFINE_ARRAY(throttle, steer, brake,
        hand_brake, reverse, manual_gear_shift, gear);
  };

} // namespace rpc
} // namespace carla

Import

#include "carla/rpc/VehicleControl.h"

I/O Contract

Field Type Default Range Description
throttle float 0.0f 0.0 - 1.0 Engine throttle amount
steer float 0.0f -1.0 to 1.0 Steering input (left/right)
brake float 0.0f 0.0 - 1.0 Brake pedal amount
hand_brake bool false -- Hand brake engaged
reverse bool false -- Reverse gear
manual_gear_shift bool false -- Manual transmission mode
gear int32_t 0 -- Current gear number

Usage Examples

#include "carla/rpc/VehicleControl.h"

carla::rpc::VehicleControl control;
control.throttle = 0.5f;    // half throttle
control.steer = -0.2f;      // slight left
control.brake = 0.0f;
control.hand_brake = false;
control.reverse = false;

// Apply control to vehicle actor
vehicle->ApplyControl(control);

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment