Skip to content
This repository has been archived by the owner on Jul 11, 2024. It is now read-only.

Updated arms::RELATIVE functionality | Implement movements based on vectors #103

Merged
merged 8 commits into from
Oct 6, 2023

Conversation

BennyBot
Copy link
Member

PROBLEM
For a long time now, the arms::RELATIVE flag has been used to move a relative distance/angle from the robot's CURRENT position. However, this can cause some problems if autonomous routes are made in the following manner:

arms::chassis::move(24, 100); // drive forward for 24 inches. supposed to move to the odom point {0, 24}
pros::delay(1000); // 1 second delay
arms::chassis::move(24, 100); // drive forward for 24 inches. supposed to move to the odom point {0, 48}

This seems like it would work. However, here are a couple real world examples that would cause it to fail.

  • PID was not tuned perfectly, so all movements are undershooting by 0.1 inches. The first movement moves to the point {0, 23.9}. Now, instead of moving towards the point {0, 48}, the second movement's target point is {0, 47.9}. This causes the error to compound throughout the script.
  • The robot is hit hard in between the two movements, causing its heading to turn by 90 degrees. Now, instead of the second target being the point {0, 48}, the target point is {24, 24}.

Implemented Solution
Odometry will now store a current_position, as well as a target_position. All movement calls using the arms::RELATIVE flag will be changed to use the odometry's target_position in their calculations for new target pose, contrary to how they currently use odometry's current_position. This will ensure that the issues listed above will no longer affect the script. In order to make sure the previous functionality is still available, a new flag arms::TRUE_RELATIVE was made that uses the old arms::RELATIVE logic.

@BennyBot BennyBot requested a review from mihirlaud March 30, 2023 02:07
@BennyBot BennyBot changed the title Implement difference between 'Relative' movements and truly relative movements Updated arms::RELATIVE functionality | Implement movements based on vectors Mar 30, 2023
@BennyBot
Copy link
Member Author

Second part of this PR: Implement movements based on vectors.
Two new functions were added to the chassis namespace:

arms::chassis::moveVectorPath. given a vector's angle and magnitude, perform a arms::chassis::turn and a 1D arms::chassis::move back to back. please note that using the arms::ASYNC flag will have undesired results.

arms::chassis::moveVectorEnd. given a vector's angle and magnitude, calculate the end point and perform a 2D arms::chassis::move.

Seems to work not very thoroughly tested.

@AndrewLuGit AndrewLuGit merged commit a9b6814 into master Oct 6, 2023
2 checks passed
@AndrewLuGit AndrewLuGit deleted the feature/relative-vs-true-relative branch October 6, 2023 19:38
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants