Skip to content

Library

Deng.Pan@Linux edited this page Dec 20, 2023 · 2 revisions

This document provides detailed instructions and usage guidelines for the dynamic link library (DLL) APIs, essentially serving as a comprehensive commentary on the header files. We hope this will be of help to you. The header files can be found in the /LibAPI/include directory of any RMP SDK:

  • For the RMP220 header files, visit here
  • For the RMP401PRO header files, visit here
  • ...

Data Callback

The interface provides relevant data to users in the form of Callbacks, facilitating quick data access and usage. Users can register callback data after initialization by using void aprctrl_datastamped_jni_register(s_aprctrl_datastamped_t* f);.

You can refer to the examples in the "Sample" section.

Callback ID Callback Definition Description Data Structure
1 Chassis_Data_Speed Chassis speed data typedef struct{
int16_t l_speed;
int16_t r_speed;
int16_t car_speed;
int16_t turn_speed;
}chassis_speed_data_t;
2 Chassis_Data_Ticks Chassis encoder data typedef struct{
int32_t l_ticks;
int32_t r_ticks;
}motor_ticks_t;
3 Chassis_Data_Odom_Pose_xy Odom pose data typedef struct{
float pos_x;
float pos_y;
}odom_pos_xy_t;
4 Chassis_Data_Odom_Euler_xy Odom Euler x/y axis data typedef struct{
float euler_x;
float euler_y;
}odom_euler_xy_t;
5 Chassis_Data_Odom_Euler_z Odom Euler z axis data typedef struct{
float euler_z;
}odom_euler_z_t;
6 Chassis_Data_Odom_LineVel_xy Odom speed x/y axis data typedef struct{
float vel_line_x;
float vel_line_y;
}odom_vel_line_xy_t;
7 Chassis_Data_Imu_Gyr Gyroscope data typedef struct{
int16_t gyr[3];
}imu_gyr_original_data_;
8 Chassis_Data_Imu_Acc Accelerometer data typedef struct{
int16_t acc[3];
}imu_acc_original_data_;

Event Definition

The interface provides relevant event data to users in the form of Events. Users can register event information after initialization by using void aprctrl_eventcallback_jni_register(s_aprctrl_event_t* f);.

You can refer to the examples in the "Sample" section.

Event ID Event Definition Description
1 ChassisBootReadyEvent Chassis control board startup complete
2 PadPowerOffEvent Chassis power off
3 OnEmergeStopEvent Enter emergency stop
4 OutEmergeStopEvent Exit emergency stop
5 OnLockedRotorProtectEvent Locked rotor occurrence
6 OutLockedRotorProtectEvent Locked rotor cleared
7 OnLostCtrlProtectEvent Lost control occurrence
8 OutLostCtrlProtectEvent Lost control cleared
9 CalibrateGyroSuccess Gyroscope calibration success
10 CalibrateGyroFail Gyroscope calibration failed
11 CalibratePasheCurrentSuccess Phase current calibration success
12 CalibratePasheCurrentFail Phase current calibration failed

Interface Explanation

API Name API Description
get_err_state() Get error codes from the host/control board/motor board/battery
get_bat_soc() Get battery remaining percentage
get_bat_charging() Get battery charging status (1: charging; 0: not charging)
get_bat_mvol() Get battery voltage (unit: mV)
get_bat_mcurrent() Get battery current (unit: mA)
get_bat_temp() Get battery temperature (unit: Celsius)
get_chassis_work_model() Get chassis work state (0: release; 1: add force)
get_chassis_load_state() Get chassis load parameter setting (0: no load; 1: full load)
get_chassis_mode() Get chassis mode (0: lock; 1: control; 2: push; 3: emergency stop; 4: error)
get_ctrl_cmd_src() Get current control source of the chassis (0: remote control; 1: host)
get_vehicle_meter() Get chassis mileage (unit: meter)
get_host_version() Get host version number
get_chassis_central_version() Get control board version number
get_chassis_motor_version() Get motor board version number (reserved)
get_line_forward_max_vel_fb() Get chassis forward speed limit (unit: m/h)
get_line_backward_max_vel_fb() Get chassis reverse speed limit (unit: m/h)
get_angular_max_vel_fb() Get chassis angular speed limit (unit: mrad/s)
getIapTotalProgress() Get IAP progress
iapCentralBoard() IAP upgrade for control board
iapMotorBoard() IAP upgrade for motor board
isHostIapOver() Check if IAP is over
getHostIapResult() Get IAP result (3: complete; 4: fail; 5: interrupt; 0: meaningless)
getHostIapErrorCode() Get IAP error code
get_chassis_hang_mode() Get whether the chassis is in suspension mode (0: not in suspension; 1: in suspension mode)
get_charge_mos_ctrl_status() Get charging MOS status (1: charging MOS open, 0: MOS off) Reserved
set_cmd_vel() Set chassis linear and angular velocities (unit: m/s and rad/s)
set_line_forward_max_vel() Set chassis forward speed limit (unit: m/s)
set_line_backward_max_vel() Set chassis reverse speed limit (unit: m/s)
set_angular_max_vel() Set chassis angular speed limit (unit: rad/s)
set_enable_ctrl() Set chassis host control enable state (1: enable; 0: disable)
init_control_ctrl() Chassis initialization interface
exit_control_ctrl() Chassis de-initialization interface
set_smart_car_serial() Set the serial port name used by the host dynamic library
set_comu_interface() Set the communication interface with the chassis (0: UART; 1: CAN)
set_chassis_load_state() Set chassis load parameters (0: no load; 1: full load)
set_chassis_poweroff() Issue chassis power off command
set_remove_push_cmd() Revoke chassis push command
setHostIapCanceled() Cancel host IAP command
set_chassis_hang_mode() Set chassis suspension mode (1: enter suspension mode; 0: exit suspension mode)
set_charge_mos_ctrl() Set charging MOS switch (1: open MOS; 0: close MOS) Reserved

Sample

#include "XXX.h"
// Other declarations...


s_aprctrl_event_t event_callback;
s_aprctrl_datastamped_t timestamp_data;

int main(int argc,char *argv[])
{

    //library initialization
    ///////////////////////////////////////////////
    //PART0
    //todo:argc arvg selfcheck

    //PART1
    //hardware interface selection
    set_comu_interface(comu_serial);
    //set_comu_interface(comu_can);
 
    //PART2
    //init
    init_control_ctrl();


    //user api
    ///////////////////////////////////////////////
    //Below are some examples of interface calls for your reference. You can use them according to your choice.


    //library version    
    printf("Lib file version: 0x%x\n",get_host_version());

    //event register
    event_callback.event_callback = Test_Event_Callback;  //Test_Event_Callback is defined by the user.
    aprctrl_eventcallback_jni_register(&event_callback);

    //data register
    timestamp_data.on_new_data = Test_GetData;  //Test_GetData is defined by the user.
    aprctrl_datastamped_jni_register(&timestamp_data);

    //central board verison
    get_chassis_central_version();

    //battery info
    get_bat_soc();
    get_bat_mvol();
    get_bat_mcurrent();

    //calibration 
    while(set_calib_chassis_imu_gyro());

	//get err msg
    get_err_state(Host);
    get_err_state(Central);

    //chassis mode
    get_chassis_mode();

    //move chasiss
    set_enable_ctrl(true);  //enable control
    set_cmd_vel(0.1,0.2);  //linear speed = 0.1m/s,angular speed = 0.2m/s

    //IAP central
    //iapCentralBoard();

    //IAP motor
    //iapMotorBoard();

    return 0;
}

Clone this wiki locally