jsk-ros-pkg / jsk_visualization

jsk visualization ros packages
https://github.com/jsk-ros-pkg/jsk_visualization
329 stars 173 forks source link

Fixed linear gague display #860

Closed peci1 closed 1 year ago

peci1 commented 2 years ago

If the minimum of the linear gauge is not zero, it incorrectly displays the "progress". This PR fixes it.

Previously non-working config:

Min value 24, max value 25, current value 24.5.

Previous normalized_value would be min(max(24.5,0), 25) * width / 25 = min(24.5, 25) * width / 25 = 24.5 * width / 25 = almost 100% width, while it should be 50%.

New normalized value is min(max(24.5-24, 0), 25 - 24) * width / (25-24) = min(0.5, 1) * width / 1 = 50% width.