@小鱼 大佬,没看到呀,只看到per_pulse_distance和speed_factor怎么计算的😢
typedef struct
{
uint8_t id; // 电机编号
uint16_t reducation_ratio; // 减速器减速比,轮子转一圈,电机需要转的圈数
uint16_t pulse_ration; // 脉冲比,电机转一圈所产生的脉冲数
float wheel_diameter; // 轮子的外直径,单位mm
float per_pulse_distance; // 无需配置,单个脉冲轮子前进的距离,单位mm,设置时自动计算
// 单个脉冲距离=轮子转一圈所行进的距离/轮子转一圈所产生的脉冲数
// per_pulse_distance= (wheel_diameter*3.1415926)/(pulse_ration*reducation_ratio)
uint32_t speed_factor; // 无需配置,计算速度时使用的速度因子,设置时自动计算,speed_factor计算方式如下
// 设 dt(单位us,1s=1000ms=10^6us)时间内的脉冲数为dtick
// 速度speed = per_pulse_distance*dtick/(dt/1000/1000)=(per_pulse_distance*1000*1000)*dtic/dt
// 记 speed_factor = (per_pulse_distance*1000*1000)
int16_t motor_speed; // 无需配置,当前电机速度mm/s,计算时使用
int64_t last_encoder_tick; // 无需配置,上次电机的编码器读数
uint64_t last_update_time; // 无需配置,上次更新数据的时间,单位us
} motor_param_t;
设置和取值,也都是配置的默认值
float FishBotConfig::kinematics_reducation_ration()
{
return preferences.getString("reducate_ration", CONFIG_DEFAULT_MOTOR0_PARAM_REDUCATION_RATIO).toFloat();
}
preferences.putString("reducate_ration", CONFIG_DEFAULT_MOTOR0_PARAM_REDUCATION_RATIO);
还有个问题,WIFI设置是这样吗,为什么日志输出的对不上
/*=========================================默认值定义=====================================*/
#define CONFIG_DEFAULT_TRANSPORT_MODE_WIFI_SERVER_IP "192.168.1.16" // 默认UDP服务端IP
#define CONFIG_DEFAULT_TRANSPORT_MODE_WIFI_SERVER_PORT "8888" // 默认UDP服务端端口号
#define CONFIG_DEFAULT_TRANSPORT_MODE "udp_client" // 默认传输模式-udp_client模式
#define CONFIG_DEFAULT_SERIAL_ID "0" // 可选使用0或者2,使用2则需要使用GPIO16和17作为RXTX
#define CONFIG_DEFAULT_TRANSPORT_SERIAL_BAUD "921600"
//------------------------------------WIFI SSID-----------------------------------------
#define CONFIG_DEFAULT_WIFI_STA_SSID "ChinaNet-403"
#define CONFIG_DEFAULT_WIFI_STA_PSWK "15601885530@"
串口输出如下
[695649][E][WiFiUdp.cpp:185] endPacket(): could not send data: 118
ets Jul 29 2019 12:21:46
rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0030,len:1184
load:0x40078000,len:13260
load:0x40080400,len:3028
entry 0x400805e4
[54]@53>D:first_startup=0
=================================================
wwww.fishros.com
fishbot-motion-control-v1.0.0
=================================================
[66]@53>D:first_startup=0
$first_startup=0
$serial_baud=921600
$serial_id=0
$wifi_ssid=m5
$wifi_pswd=88888888
$wifi_ap_ssid=FISHBOT_9CF4
$wifi_ap_pswd=
$microros_mode=udp_client
$udpserver_ip=192.168.2.105
$udpserver_port=8888
$ros2_nodename=fishbot_motion_control
$ros2_namespace=
$odom_topic=odom
$odom_frameid=odom
$odom_c_frameid=base_link
$twist_topic=cmd_vel
$odom_pub_period=50
$reducate_ration=40.50
$pulse_ration=44
$wheel_diameter=65
$wheel_distance=172.75
$pid_kp=0.62
$pid_ki=0.13
$pid_kd=0.00
$pid_outlimit=100.00
$board=motion_board
$version=v1.1.0
[ 180][E][Wire.cpp:499] requestFrom(): i2cWriteReadNonStop returned Error -1
init motor param 0: 0.114592=65.000000*PI/(0*1078214656) speed_factor=44
init motor param 1: 0.114592=65.000000*PI/(0*1078214656) speed_factor=44
WIFI EVENT!
---- Closed serial port /dev/ttyUSB0 due to disconnection from the machine ----
---- Reopened serial port /dev/ttyUSB0 ----
wifi connected failed!
WIFI EVENT!
[ 2834][E][WiFiUdp.cpp:185] endPacket(): could not send data: 118
---- Closed the serial port /dev/ttyUSB0 ----