Currently, there is a bug in predictive display where the max speed when moving forward is lower than the max speed when using the button pad to move forward. The reason for this is that the speed multiplier in predictive display is computed by taking the distance between the base and the cursor and dividing it by the distance between the base and the corner (e.g., the max distance possible in the image). As a result, the robot only ever moves at max speed when the cursor is in the corner of the image (e.g., it is turning), and there is no way to have it move at max speed when it is moving straight.
This PR addresses that by refactoring the speed multiplier to be: the distance between the base and the cursor, divided by the distance between the base and the point that would be reached if extending the ray from the base to the cursor till the end of the image. As a result, in every direction, it is now possible to move at max speed by extending the cursor towards the end of the image.
Further, an unfortunate reality of PredictiveDisplay was that users would never reach max speed, because doing so requires the cursor to be on the edge of the image, which makes it very easy for the cursor to leave the image. Hence, this PR also adds a threshold -- fixed at 90% -- so that as long as the cursor is 90% of the way to the edge of the image (in that direction), the robot will reach max speed.
Testing procedure
[x] Verify the issue: Pull on master. Load the web interface and toggle on Predictive Display.
[x] ros2 topic echo /stretch/cmd_vel
[x] Move the speed to Fastest.
[x] Click the button pad forward, and note down what speed it moves at. (I got 0.16)
[x] Using predictive display, click near the top of the image (for forward motion), and verify the speed it moves at is slower than the button pad speed. (I got 0.125)
[x] Using the button pad, click back, and note down the speed (I got -0.16).
[x] Using predictive display, click near the bottom of the image, and verify the speed it moves at is close to but slightly lower than the button pad speed. (I got -0.13)
[x] Verify the fix: Pull on this branch. Load the web interface and toggle on Predictive Display.
[x] Repeat the above tests. Verify for both straight forward and straight backwards motion, the speed is the same between the button pad and predictive display.
Note: when moving backwards, I had to click very close to the bottom to get the max speed. This is likely for two reasons: (1) 90% of the smaller distance below the robot leaves a smaller margin from the edge; (2) perhaps this has to do with the offset bug
[x] Move the cursor around the image for various curved motions. Verify that the way the speed changes is intuitive.
Description
Currently, there is a bug in predictive display where the max speed when moving forward is lower than the max speed when using the button pad to move forward. The reason for this is that the speed multiplier in predictive display is computed by taking the distance between the base and the cursor and dividing it by the distance between the base and the corner (e.g., the max distance possible in the image). As a result, the robot only ever moves at max speed when the cursor is in the corner of the image (e.g., it is turning), and there is no way to have it move at max speed when it is moving straight.
This PR addresses that by refactoring the speed multiplier to be: the distance between the base and the cursor, divided by the distance between the base and the point that would be reached if extending the ray from the base to the cursor till the end of the image. As a result, in every direction, it is now possible to move at max speed by extending the cursor towards the end of the image.
Further, an unfortunate reality of PredictiveDisplay was that users would never reach max speed, because doing so requires the cursor to be on the edge of the image, which makes it very easy for the cursor to leave the image. Hence, this PR also adds a threshold -- fixed at 90% -- so that as long as the cursor is 90% of the way to the edge of the image (in that direction), the robot will reach max speed.
Testing procedure
master
. Load the web interface and toggle on Predictive Display.ros2 topic echo /stretch/cmd_vel
Before opening a pull request
From the top-level of this repository, run:
pre-commit run --all-files
To merge
Squash & Merge