Open afunnyrat opened 5 days ago
Nov 7: the movement is working, the stack is not working, Gabriel is using the bot so it's hard to test
Nov/7
My other goal is to assist Gabriel in maintaining the robot as best I can.
Fixed the profolio for my intake
Completely cleaned up (extremely hard)
Messed up by 19446
Yesterday I was sick
Mount the hook onto the robot(flipped)
yay
PARTIALLY WORKS for the movement
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.