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 File | Class Name | Description |
|---|---|---|
chassis_factory.h | ChassisFactory | A factory class for creating chassis instances of different types. |
chassis_interface.h | ChassisInterface | The base interface class defining common APIs for chassis control. All vendor-specific drivers should inherit from this class. |
Create a Chassis Instance
Section titled “Create a Chassis Instance”There are two ways to create a chassis instance.
-
Create a chassis instance by chassis parameters.
-
Method:
static std::shared_ptr<ChassisInterface> create_chassis(const ChassisFactoryParam& param) -
Parameter:
ParameterTypeDescription paramInput Parameters related to the chassis. For details, please refer to ChassisFactoryParam. -
Return Value:
Returns a shared pointer to an object of a class derived from
ChassisInterfaceif the instance is created successfully; otherwise, returnsnullptr.
-
-
Create a chassis instance from a configuration file.
-
Method:
static std::shared_ptr<ChassisInterface> create_chassis_from_config(const std::string& config_path) -
Parameter:
Parameter Type Description config_pathInput
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
ChassisInterfaceif the instance is created successfully; otherwise, returnsnullptr.
-
Connect to the Chassis
Section titled “Connect to the Chassis”After creating a chassis instance, you can establish a connection to the chassis using the following method.
-
Method:
AbcErrorCode connect() -
Return Value:
AbcErrorCode::SUCCESSindicates success. For other error codes, please refer to AbcErrorCode.
Disconnect from the Chassis
Section titled “Disconnect from the Chassis”You can disconnect from the chassis using the following method.
-
Method:
AbcErrorCode disconnect() -
Return Value:
AbcErrorCode::SUCCESSindicates success. For other error codes, please refer to AbcErrorCode.
Get Chassis Pose and Speed
Section titled “Get Chassis Pose and Speed”-
Method:
AbcErrorCode get_pose_speed(alphabot::ChassisPoseSpeed& pose_spd) -
Parameter:
ParameterTypeDescription pose_spdOutput The chassis pose and speed. For details, please refer to ChassisPoseSpeed. -
Return Value:
AbcErrorCode::SUCCESSindicates success. For other error codes, please refer to AbcErrorCode.
Get Chassis Pose
Section titled “Get Chassis Pose”-
Method:
AbcErrorCode get_pose(alphabot::ChassisPose2D& pose) -
Parameter:
ParameterTypeDescription poseOutput The chassis pose. For details, please refer to ChassisPose2D. -
Return Value:
AbcErrorCode::SUCCESSindicates success. For other error codes, please refer to AbcErrorCode.
Get Chassis Speed
Section titled “Get Chassis Speed”-
Method:
AbcErrorCode get_speed(alphabot::ChassisTwist& spd) -
Parameter:
ParameterTypeDescription spdOutput The chassis speed. For details, please refer to ChassisTwist. -
Return Value:
AbcErrorCode::SUCCESSindicates success. For other error codes, please refer to AbcErrorCode.
Get Chassis Mileage
Section titled “Get Chassis Mileage”-
Method:
AbcErrorCode get_mileage(uint32_t& mileage) -
Parameter:
ParameterTypeDescription mileageOutput Accumulated mileage. -
Return Value:
AbcErrorCode::SUCCESSindicates success. For other error codes, please refer to AbcErrorCode.
Get Chassis Battery Information
Section titled “Get Chassis Battery Information”-
Method:
AbcErrorCode get_battery(alphabot::ChassisBattery& battery) -
Parameter:
ParameterTypeDescription batteryOutput The chassis battery information. For details, please refer to ChassisBattery. -
Return Value:
AbcErrorCode::SUCCESSindicates success. For other error codes, please refer to AbcErrorCode.
Get Chassis Status
Section titled “Get Chassis Status”-
Method:
AbcErrorCode get_robot_state(alphabot::ChassisState& robot_state) -
Parameter:
ParameterTypeDescription robot_stateOutput The chassis status. For details, please refer to ChassisState. -
Return Value:
AbcErrorCode::SUCCESSindicates success. For other error codes, please refer to AbcErrorCode.
Get Chassis Status Code
Section titled “Get Chassis Status Code”-
Method:
AbcErrorCode get_status_code(alphabot::ChassisStatusCode& status_code) -
Parameter:
ParameterTypeDescription status_stateOutput The chassis status code. For details, please refer to ChassisStatusCode. -
Return Value:
AbcErrorCode::SUCCESSindicates success. For other error codes, please refer to AbcErrorCode.
Get Chassis Hardware Status
Section titled “Get Chassis Hardware Status”-
Method:
AbcErrorCode get_hardware_state(alphabot::ChassisHardwareState& hardware_state) -
Parameter:
ParameterTypeDescription hardware_stateOutput The hardware status of the chassis. For details, please refer to ChassisHardwareState. -
Return Value:
AbcErrorCode::SUCCESSindicates success. For other error codes, please refer to AbcErrorCode.
Get Chassis Static Transform
Section titled “Get Chassis Static Transform”-
Method:
AbcErrorCode get_static_tf(std::vector<alphabot::ChassisTransformStamped>& transforms) -
Parameter:
ParameterTypeDescription transformsOutput Chassis static transforms. For details, please refer to ChassisTransformStamped. -
Return Value:
AbcErrorCode::SUCCESSindicates success. For other error codes, please refer to AbcErrorCode.
Set Chassis Twist
Section titled “Set Chassis Twist”-
Method:
AbcErrorCode twist_control(float linear, float angular) -
Parameters:
ParameterTypeDescription linearInput Linear velocity angularInput Angular velocity -
Return Value:
AbcErrorCode::SUCCESSindicates success. For other error codes, please refer to AbcErrorCode.
Set Chassis Maximum Speed
Section titled “Set Chassis Maximum Speed”-
Method:
AbcErrorCode set_max_speed(float max_spd) -
Parameter:
ParameterTypeDescription max_spdInput Maximum speed -
Return Value:
AbcErrorCode::SUCCESSindicates success. For other error codes, please refer to AbcErrorCode.
Initialize Chassis
Section titled “Initialize Chassis”-
Method:
AbcErrorCode init_robot(alphabot::ChassisPose2D pose, uint8_t update_flg) -
Parameters:
ParameterTypeDescription poseInput The chassis pose. For details, please refer to ChassisPose2D. update_flgInput Flag indicating whether to update the chassis pose. -
Return Value:
AbcErrorCode::SUCCESSindicates success. For other error codes, please refer to AbcErrorCode.
Move to a Target Position
Section titled “Move to a Target Position”-
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:
ParameterTypeDescription xInput X-axis coordinate of the target position. yInput Y-axis coordinate of the target position. thetaInput Orientation of the target position. func_callbackInput Callback function. For the function parameter type, please refer to ChassisTaskResponse. max_spdInput (optional) Maximum speed. -
Return Value:
AbcErrorCode::SUCCESSindicates success. For other error codes, please refer to AbcErrorCode.
Charge
Section titled “Charge”-
Method:
AbcErrorCode to_charge_sync(float max_spd = 1.0) -
Parameter:
ParameterTypeDescription max_spdInput (optional) Maximum speed. -
Return Value:
AbcErrorCode::SUCCESSindicates success. For other error codes, please refer to AbcErrorCode.
Exit Charging
Section titled “Exit Charging”-
Method:
AbcErrorCode exit_charge_sync(float max_spd = 1.0) -
Parameter:
ParameterTypeDescription max_spdInput (optional) Maximum speed. -
Return Value:
AbcErrorCode::SUCCESSindicates success. For other error codes, please refer to AbcErrorCode.
Move Linearly
Section titled “Move Linearly”-
Method:
AbcErrorCode move_straight_sync(float distance,float speed,std::function<void(alphabot::ChassisTaskResponse)> func_callback,bool use_avoid = true) -
Parameters:
ParameterTypeDescription distanceInput Travel distance. speedInput Travel speed. func_callbackInput Callback function. For the function parameter type, please refer to ChassisTaskResponse. use_avoidInput (optional) Whether to enable obstacle avoidance. -
Return Value:
AbcErrorCode::SUCCESSindicates success. For other error codes, please refer to AbcErrorCode.
Move Rotationally
Section titled “Move Rotationally”-
Method:
AbcErrorCode move_rotate_sync(float angle,float speed,std::function<void(alphabot::ChassisTaskResponse)> func_callback,bool use_avoid = true) -
Parameters:
ParameterTypeDescription angleInput Rotation angle. speedInput Rotation speed. func_callbackInput Callback function. For the function parameter type, please refer to ChassisTaskResponse. use_avoidInput (optional) Whether to enable obstacle avoidance. -
Return Value:
AbcErrorCode::SUCCESSindicates success. For other error codes, please refer to AbcErrorCode.
Get or Set Footprint
Section titled “Get or Set Footprint”Get Local Footprint
Section titled “Get Local Footprint”-
Method:
AbcErrorCode get_local_footprint(std::vector<alphabot::ChassisPoint32>& points) -
Parameter:
ParameterTypeDescription pointsOutput Local footprint points. For details, please refer to ChassisPoint32. -
Return Value:
AbcErrorCode::SUCCESSindicates success. For other error codes, please refer to AbcErrorCode.
Get Global Footprint
Section titled “Get Global Footprint”-
Method:
AbcErrorCode get_global_footprint(std::vector<alphabot::ChassisPoint32>& points) -
Parameter:
ParameterTypeDescription pointsOutput Global footprint points. For details, please refer to ChassisPoint32. -
Return Value:
AbcErrorCode::SUCCESSindicates success. For other error codes, please refer to AbcErrorCode.
Get Local and Global Footprint
Section titled “Get Local and Global Footprint”-
Method:
AbcErrorCode get_all_footprint(std::vector<alphabot::ChassisPoint32>& local_points,std::vector<alphabot::ChassisPoint32>& global_points) -
Parameters:
ParameterTypeDescription local_pointsOutput Local footprint points. For details, please refer to ChassisPoint32. global_pointsOutput Global footprint points. For details, please refer to ChassisPoint32. -
Return Value:
AbcErrorCode::SUCCESSindicates success. For other error codes, please refer to AbcErrorCode.
Get Static Footprint (Based on odom and base_link Frames)
Section titled “Get Static Footprint (Based on odom and base_link Frames)”-
Method:
AbcErrorCode ai2_get_local_footprint(std::vector<alphabot::ChassisPoint32>& points) -
Parameter:
ParameterTypeDescription pointsOutput Footprint points. For details, please refer to ChassisPoint32. -
Return Value:
AbcErrorCode::SUCCESSindicates success. For other error codes, please refer to AbcErrorCode.
Get Static Footprint (Based on map and base_link Frames)
Section titled “Get Static Footprint (Based on map and base_link Frames)”-
Method:
AbcErrorCode ai2_get_global_footprint(std::vector<alphabot::ChassisPoint32>& points) -
Parameter:
ParameterTypeDescription pointsOutput Footprint points. For details, please refer to ChassisPoint32. -
Return Value:
AbcErrorCode::SUCCESSindicates success. For other error codes, please refer to AbcErrorCode.
Get Static Footprint
Section titled “Get Static Footprint”-
Method:
AbcErrorCode ai2_get_all_footprint(std::vector<alphabot::ChassisPoint32>& local_points,std::vector<alphabot::ChassisPoint32>& global_points) -
Parameters:
ParameterTypeDescription local_pointsOutput Footprint points (Based on odom and base_link Frames). For details, please refer to ChassisPoint32. global_pointsOutput Footprint points (Based on map and base_link frames). For details, please refer to ChassisPoint32. -
Return Value:
AbcErrorCode::SUCCESSindicates success. For other error codes, please refer to AbcErrorCode.
Set Local Footprint
Section titled “Set Local Footprint”-
Method:
AbcErrorCode set_local_footprint(const std::vector<alphabot::ChassisPoint32>& points) -
Parameter:
ParameterTypeDescription pointsInput Local footprint points. For details, please refer to ChassisPoint32. -
Return Value:
AbcErrorCode::SUCCESSindicates success. For other error codes, please refer to AbcErrorCode.
Set Global Footprint
Section titled “Set Global Footprint”-
Method:
AbcErrorCode set_global_footprint(const std::vector<alphabot::ChassisPoint32>& points) -
Parameter:
ParameterTypeDescription pointsInput Global footprint points. For details, please refer to ChassisPoint32. -
Return Value:
AbcErrorCode::SUCCESSindicates success. For other error codes, please refer to AbcErrorCode.
Set Local and Global Footprint
Section titled “Set Local and Global Footprint”-
Method:
AbcErrorCode set_all_footprint(const std::vector<alphabot::ChassisPoint32>& local_points,const std::vector<alphabot::ChassisPoint32>& global_points) -
Parameters:
ParameterTypeDescription local_pointsInput Local footprint points. For details, please refer to ChassisPoint32. global_pointsInput Global footprint points. For details, please refer to ChassisPoint32. -
Return Value:
AbcErrorCode::SUCCESSindicates success. For other error codes, please refer to AbcErrorCode.
Get Chassis Name
Section titled “Get Chassis Name”-
Method:
std::string get_name() const -
Return Value:
The name of the chassis instance.