CommonplaceRobotics / iRC_ROS

ROS2 packages for the igus Robot Control
Apache License 2.0
15 stars 7 forks source link

Add deque as velocity buffer #25

Closed cpr-fer closed 1 year ago

cpr-fer commented 1 year ago

While this is not yet nicely coded it adds a velocity buffer and a weighted moving average filter as can be seen below:

ros2_control_node-1] [ERROR] [1678381353.367514750] [iRC_ROS]: Module 0x60: Weight 0 is 0.018182
[ros2_control_node-1] [ERROR] [1678381353.367519044] [iRC_ROS]: Module 0x60: Weight 1 is 0.036364
[ros2_control_node-1] [ERROR] [1678381353.367523367] [iRC_ROS]: Module 0x60: Weight 2 is 0.054545
[ros2_control_node-1] [ERROR] [1678381353.367527302] [iRC_ROS]: Module 0x60: Weight 3 is 0.072727
[ros2_control_node-1] [ERROR] [1678381353.367531445] [iRC_ROS]: Module 0x60: Weight 4 is 0.090909
[ros2_control_node-1] [ERROR] [1678381353.367535097] [iRC_ROS]: Module 0x60: Weight 5 is 0.109091
[ros2_control_node-1] [ERROR] [1678381353.367538960] [iRC_ROS]: Module 0x60: Weight 6 is 0.127273
[ros2_control_node-1] [ERROR] [1678381353.367543133] [iRC_ROS]: Module 0x60: Weight 7 is 0.145455
[ros2_control_node-1] [ERROR] [1678381353.367547203] [iRC_ROS]: Module 0x60: Weight 8 is 0.163636
[ros2_control_node-1] [ERROR] [1678381353.367551389] [iRC_ROS]: Module 0x60: Weight 9 is 0.181818
[ros2_control_node-1] [ERROR] [1678381353.367555642] [iRC_ROS]: Module 0x60: Weights sum is 1.000000

Before merging cleanup and comparing the velocity output curve via PlotJuggler should be done.

cpr-fer commented 1 year ago

Well, that could have been a force push instead. Anyways, the filter seems to work okay-ish. The following images show the output for the same set velocity with buffer sizes 1, 10, 15 and 30. While there is still some notable change in the amount of noise after 10 samples, the responsiveness decreases further (1 Sample every 10 ms). As such I've chosen a buffer size of 10 for now.

1 10 15 30