sbgisen / vesc

VESC Interface for ROS
Apache License 2.0
41 stars 33 forks source link

Fix counterTD (Differentiation is discrete) #65

Closed nyxrobotics closed 1 year ago

nyxrobotics commented 1 year ago

Abstract

The value of velocity is discrete because the low resolution angle is differentiated in a short time. Extend the sampling period when the change in angle is small and smooth the velocity values.

Reference:https://jsdkk.com/blog/mugita/?p=458

Purpose

To prevent PID control from vibrating

Implementation Details

nyxrobotics commented 1 year ago

Implement two functions counterTDRaw and counterTDVariableWindow to be able to switch between them with rosparam

nyxrobotics commented 1 year ago

This program is converting a number subtracted by uint16_t to a double, so -1 is 65535. It seems that the gain was diverging each time the counter increased by 65536.

https://github.com/sbgisen/vesc/blob/d96dcc2d81419f33647b37b249769c0101b7b7f5/vesc_hw_interface/src/vesc_wheel_controller.cpp#L169-L170