Skip to content

Chassis APIs

The chassis APIs are implemented by the following classes. You can find the corresponding header files in the c++/include/drivers/chassis directory to access the complete set of APIs.

Header FileClass NameDescription
chassis_factory.hChassisFactoryA factory class for creating chassis instances of different types.
chassis_interface.hChassisInterfaceThe base interface class defining common APIs for chassis control. All vendor-specific drivers should inherit from this class.

There are two ways to create a chassis instance.

  1. Create a chassis instance by chassis parameters.

    • Method:

      static std::shared_ptr<ChassisInterface> create_chassis(
      const ChassisFactoryParam& param)
    • Parameter:

      Parameter
      Type
      Description
      paramInputParameters related to the chassis. For details, please refer to ChassisFactoryParam.
    • Return Value:

      Returns a shared pointer to an object of a class derived from ChassisInterface if the instance is created successfully; otherwise, returns nullptr.

  2. Create a chassis instance from a configuration file.

    • Method:

      static std::shared_ptr<ChassisInterface> create_chassis_from_config(
      const std::string& config_path)
    • Parameter:

      ParameterTypeDescription

      config_path

      Input

      Path to the configuration file. The configuration file must be a JSON file.

      {
      "chassis_type": "xxx", # Chassis vendor
      "chassis_name": "chassis", # Chassis name
      "ip": "127.0.0.1", # IP address
      "port": 51051 # Port number
      }
    • Return Value:

      Returns a shared pointer to an object of a class derived from ChassisInterface if the instance is created successfully; otherwise, returns nullptr.

After creating a chassis instance, you can establish a connection to the chassis using the following method.

  • Method:

    AbcErrorCode connect()
  • Return Value:

    AbcErrorCode::SUCCESS indicates success. For other error codes, please refer to AbcErrorCode.

You can disconnect from the chassis using the following method.

  • Method:

    AbcErrorCode disconnect()
  • Return Value:

    AbcErrorCode::SUCCESS indicates success. For other error codes, please refer to AbcErrorCode.

  • Method:

    AbcErrorCode get_pose_speed(alphabot::ChassisPoseSpeed& pose_spd)
  • Parameter:

    Parameter
    Type
    Description
    pose_spdOutputThe chassis pose and speed. For details, please refer to ChassisPoseSpeed.
  • Return Value:

    AbcErrorCode::SUCCESS indicates success. For other error codes, please refer to AbcErrorCode.

  • Method:

    AbcErrorCode get_pose(alphabot::ChassisPose2D& pose)
  • Parameter:

    Parameter
    Type
    Description
    poseOutputThe chassis pose. For details, please refer to ChassisPose2D.
  • Return Value:

    AbcErrorCode::SUCCESS indicates success. For other error codes, please refer to AbcErrorCode.

  • Method:

    AbcErrorCode get_speed(alphabot::ChassisTwist& spd)
  • Parameter:

    Parameter
    Type
    Description
    spdOutputThe chassis speed. For details, please refer to ChassisTwist.
  • Return Value:

    AbcErrorCode::SUCCESS indicates success. For other error codes, please refer to AbcErrorCode.

  • Method:

    AbcErrorCode get_mileage(uint32_t& mileage)
  • Parameter:

    Parameter
    Type
    Description
    mileageOutputAccumulated mileage.
  • Return Value:

    AbcErrorCode::SUCCESS indicates success. For other error codes, please refer to AbcErrorCode.

  • Method:

    AbcErrorCode get_battery(alphabot::ChassisBattery& battery)
  • Parameter:

    Parameter
    Type
    Description
    batteryOutputThe chassis battery information. For details, please refer to ChassisBattery.
  • Return Value:

    AbcErrorCode::SUCCESS indicates success. For other error codes, please refer to AbcErrorCode.

  • Method:

    AbcErrorCode get_robot_state(alphabot::ChassisState& robot_state)
  • Parameter:

    Parameter
    Type
    Description
    robot_stateOutputThe chassis status. For details, please refer to ChassisState.
  • Return Value:

    AbcErrorCode::SUCCESS indicates success. For other error codes, please refer to AbcErrorCode.

  • Method:

    AbcErrorCode get_status_code(alphabot::ChassisStatusCode& status_code)
  • Parameter:

    Parameter
    Type
    Description
    status_stateOutputThe chassis status code. For details, please refer to ChassisStatusCode.
  • Return Value:

    AbcErrorCode::SUCCESS indicates success. For other error codes, please refer to AbcErrorCode.

  • Method:

    AbcErrorCode get_hardware_state(alphabot::ChassisHardwareState& hardware_state)
  • Parameter:

    Parameter
    Type
    Description
    hardware_stateOutputThe hardware status of the chassis. For details, please refer to ChassisHardwareState.
  • Return Value:

    AbcErrorCode::SUCCESS indicates success. For other error codes, please refer to AbcErrorCode.

  • Method:

    AbcErrorCode get_static_tf(std::vector<alphabot::ChassisTransformStamped>& transforms)
  • Parameter:

    Parameter
    Type
    Description
    transformsOutputChassis static transforms. For details, please refer to ChassisTransformStamped.
  • Return Value:

    AbcErrorCode::SUCCESS indicates success. For other error codes, please refer to AbcErrorCode.

  • Method:

    AbcErrorCode twist_control(float linear, float angular)
  • Parameters:

    Parameter
    Type
    Description
    linearInputLinear velocity
    angularInputAngular velocity
  • Return Value:

    AbcErrorCode::SUCCESS indicates success. For other error codes, please refer to AbcErrorCode.

  • Method:

    AbcErrorCode set_max_speed(float max_spd)
  • Parameter:

    Parameter
    Type
    Description
    max_spdInputMaximum speed
  • Return Value:

    AbcErrorCode::SUCCESS indicates success. For other error codes, please refer to AbcErrorCode.

  • Method:

    AbcErrorCode init_robot(alphabot::ChassisPose2D pose, uint8_t update_flg)
  • Parameters:

    Parameter
    Type
    Description
    poseInputThe chassis pose. For details, please refer to ChassisPose2D.
    update_flgInputFlag indicating whether to update the chassis pose.
  • Return Value:

    AbcErrorCode::SUCCESS indicates success. For other error codes, please refer to AbcErrorCode.

  • Method:

    AbcErrorCode move_to_point_sync(
    float x,
    float y,
    float theta,
    std::function<void(alphabot::ChassisTaskResponse)> func_callback,
    float max_spd = 1.0)
  • Parameters:

    Parameter
    Type
    Description
    xInputX-axis coordinate of the target position.
    yInputY-axis coordinate of the target position.
    thetaInputOrientation of the target position.
    func_callbackInputCallback function. For the function parameter type, please refer to ChassisTaskResponse.
    max_spdInput (optional)Maximum speed.
  • Return Value:

    AbcErrorCode::SUCCESS indicates success. For other error codes, please refer to AbcErrorCode.

  • Method:

    AbcErrorCode to_charge_sync(float max_spd = 1.0)
  • Parameter:

    Parameter
    Type
    Description
    max_spdInput (optional)Maximum speed.
  • Return Value:

    AbcErrorCode::SUCCESS indicates success. For other error codes, please refer to AbcErrorCode.

  • Method:

    AbcErrorCode exit_charge_sync(float max_spd = 1.0)
  • Parameter:

    Parameter
    Type
    Description
    max_spdInput (optional)Maximum speed.
  • Return Value:

    AbcErrorCode::SUCCESS indicates success. For other error codes, please refer to AbcErrorCode.

  • Method:

    AbcErrorCode move_straight_sync(
    float distance,
    float speed,
    std::function<void(alphabot::ChassisTaskResponse)> func_callback,
    bool use_avoid = true)
  • Parameters:

    Parameter
    Type
    Description
    distanceInputTravel distance.
    speedInputTravel speed.
    func_callbackInputCallback function. For the function parameter type, please refer to ChassisTaskResponse.
    use_avoidInput (optional)Whether to enable obstacle avoidance.
  • Return Value:

    AbcErrorCode::SUCCESS indicates success. For other error codes, please refer to AbcErrorCode.

  • Method:

    AbcErrorCode move_rotate_sync(
    float angle,
    float speed,
    std::function<void(alphabot::ChassisTaskResponse)> func_callback,
    bool use_avoid = true)
  • Parameters:

    Parameter
    Type
    Description
    angleInputRotation angle.
    speedInputRotation speed.
    func_callbackInputCallback function. For the function parameter type, please refer to ChassisTaskResponse.
    use_avoidInput (optional)Whether to enable obstacle avoidance.
  • Return Value:

    AbcErrorCode::SUCCESS indicates success. For other error codes, please refer to AbcErrorCode.

  • Method:

    AbcErrorCode get_local_footprint(std::vector<alphabot::ChassisPoint32>& points)
  • Parameter:

    Parameter
    Type
    Description
    pointsOutputLocal footprint points. For details, please refer to ChassisPoint32.
  • Return Value:

    AbcErrorCode::SUCCESS indicates success. For other error codes, please refer to AbcErrorCode.

  • Method:

    AbcErrorCode get_global_footprint(std::vector<alphabot::ChassisPoint32>& points)
  • Parameter:

    Parameter
    Type
    Description
    pointsOutputGlobal footprint points. For details, please refer to ChassisPoint32.
  • Return Value:

    AbcErrorCode::SUCCESS indicates success. For other error codes, please refer to AbcErrorCode.

  • Method:

    AbcErrorCode get_all_footprint(
    std::vector<alphabot::ChassisPoint32>& local_points,
    std::vector<alphabot::ChassisPoint32>& global_points)
  • Parameters:

    Parameter
    Type
    Description
    local_pointsOutputLocal footprint points. For details, please refer to ChassisPoint32.
    global_pointsOutputGlobal footprint points. For details, please refer to ChassisPoint32.
  • Return Value:

    AbcErrorCode::SUCCESS indicates success. For other error codes, please refer to AbcErrorCode.

Section titled “Get Static Footprint (Based on odom and base_link Frames)”
  • Method:

    AbcErrorCode ai2_get_local_footprint(std::vector<alphabot::ChassisPoint32>& points)
  • Parameter:

    Parameter
    Type
    Description
    pointsOutputFootprint points. For details, please refer to ChassisPoint32.
  • Return Value:

    AbcErrorCode::SUCCESS indicates success. For other error codes, please refer to AbcErrorCode.

Section titled “Get Static Footprint (Based on map and base_link Frames)”
  • Method:

    AbcErrorCode ai2_get_global_footprint(std::vector<alphabot::ChassisPoint32>& points)
  • Parameter:

    Parameter
    Type
    Description
    pointsOutputFootprint points. For details, please refer to ChassisPoint32.
  • Return Value:

    AbcErrorCode::SUCCESS indicates success. For other error codes, please refer to AbcErrorCode.

  • Method:

    AbcErrorCode ai2_get_all_footprint(
    std::vector<alphabot::ChassisPoint32>& local_points,
    std::vector<alphabot::ChassisPoint32>& global_points)
  • Parameters:

    Parameter
    Type
    Description
    local_pointsOutputFootprint points (Based on odom and base_link Frames). For details, please refer to ChassisPoint32.
    global_pointsOutputFootprint points (Based on map and base_link frames). For details, please refer to ChassisPoint32.
  • Return Value:

    AbcErrorCode::SUCCESS indicates success. For other error codes, please refer to AbcErrorCode.

  • Method:

    AbcErrorCode set_local_footprint(const std::vector<alphabot::ChassisPoint32>& points)
  • Parameter:

    Parameter
    Type
    Description
    pointsInputLocal footprint points. For details, please refer to ChassisPoint32.
  • Return Value:

    AbcErrorCode::SUCCESS indicates success. For other error codes, please refer to AbcErrorCode.

  • Method:

    AbcErrorCode set_global_footprint(const std::vector<alphabot::ChassisPoint32>& points)
  • Parameter:

    Parameter
    Type
    Description
    pointsInputGlobal footprint points. For details, please refer to ChassisPoint32.
  • Return Value:

    AbcErrorCode::SUCCESS indicates success. For other error codes, please refer to AbcErrorCode.

  • Method:

    AbcErrorCode set_all_footprint(
    const std::vector<alphabot::ChassisPoint32>& local_points,
    const std::vector<alphabot::ChassisPoint32>& global_points)
  • Parameters:

    Parameter
    Type
    Description
    local_pointsInputLocal footprint points. For details, please refer to ChassisPoint32.
    global_pointsInputGlobal footprint points. For details, please refer to ChassisPoint32.
  • Return Value:

    AbcErrorCode::SUCCESS indicates success. For other error codes, please refer to AbcErrorCode.

  • Method:

    std::string get_name() const
  • Return Value:

    The name of the chassis instance.