sta-titansrobotics / 19447-IntoTheDeep

BSD 3-Clause Clear License
2 stars 0 forks source link

Felix_sprint 4 - advanced movement control #32

Open afunnyrat opened 5 days ago

afunnyrat commented 5 days ago

I'm working on these core Features of the code Hopefully they should be done before next week friday.

X-Y Coordinate Tracking: The robot’s position is tracked using xPosition and yPosition, representing how far the robot has moved along a fixed, original coordinate system. (x,y) Global Orientation: The initialAngle is set when the robot first powers on and aligns the robot's forward, backward, left, and right movements to the original orientation. Absolute Angle Calculation: The robot's current angle relative to the original orientation is constantly updated. This ensures that directional commands (FORWARD, BACKWARD, LEFT, RIGHT) are interpreted based on the initial orientation, not the robot's current rotation.

Movement Stack: A stack (movementStack) stores movement commands as target coordinates (x, y) relative to the initial orientation. Commands are processed in order, ensuring each is completed before the next begins. Stack Command Addition: When a D-pad button is pressed, a movement of 10 cm in the specified direction (e.g., forward, backward) is added to the stack by calculating the new target coordinates and storing them. Each button press adds a 10 cm movement command, queued for sequential execution. Processing Commands in Sequence: The processMovementStack() function processes one command at a time from the stack by calling gotoPosition(x, y), which initiates movement toward the next set of (x, y) coordinates. gotoPosition Function (Precise Movements)

Target Calculation: For each command, gotoPosition(x, y) calculates the distance (distanceToMove) and direction (angleToTarget) to the target (x, y) based on the robot’s current position. Setting Motor Power for Correct Heading: The angle to the target (angleToTarget) is calculated from the current position. Motor power is set based on this angle, keeping the movement direction aligned to the global coordinate system, as defined by initialAngle. This allows precise 10 cm movements in any direction relative to the starting orientation. Encoder-Based Distance Tracking: The motors are controlled to run until the robot moves the specified distance (e.g., 10 cm) by converting distance to motor encoder ticks. Stopping Motors Upon Reaching Target: Once the robot reaches the target position, motor power is set to zero, ensuring the robot stops precisely. Teleop Control for Manual Movement

Joystick Control: The original joystick control remains functional, allowing manual movement based on the joystick position while automatically adjusting to the initial orientation. Mixing Manual and Autonomous Movements: The D-pad commands are added to the stack and processed autonomously, while joystick input provides real-time manual control. Telemetry Output

Real-Time Data: The telemetry constantly updates to show the following: Current Angle: Displays the robot’s current angle, adjusted to remain within 0–360 degrees, relative to the initial orientation. X and Y Position: Displays the robot’s current position (x, y) in cm, aligned with the initial orientation. Pending Stack Commands: Shows the number of commands remaining in the stack, giving insight into upcoming movements.

afunnyrat commented 4 days ago

Nov 7: the movement is working, the stack is not working, Gabriel is using the bot so it's hard to test

afunnyrat commented 4 days ago

Screenshot 2024-11-08 at 1 18 42 PM Nov/7

afunnyrat commented 4 days ago

My other goal is to assist Gabriel in maintaining the robot as best I can.

afunnyrat commented 4 days ago

Screenshot 2024-11-08 at 1 54 35 PM Fixed the profolio for my intake

afunnyrat commented 4 days ago

20241108_144210 20241108_143457

20241108_141444

20241108_135941

Completely cleaned up (extremely hard)

afunnyrat commented 4 days ago

20241108_152655 Messed up by 19446

afunnyrat commented 2 hours ago

Yesterday I was sick

afunnyrat commented 2 hours ago

Mount the hook onto the robot(flipped) Screenshot 2024-11-12 at 1 22 53 PM

afunnyrat commented 2 hours ago

image yay

afunnyrat commented 38 minutes ago

Screenshot 2024-11-12 at 3 22 42 PM PARTIALLY WORKS for the movement