Open RunaAM opened 1 year ago
Today we started constructing an arm for the robot to grasp cones and move them to those yellow pillars. We have installed a rotatory base (a wheel with a diameter of 15 cm and a rev core hex motor where the slider will be fixed ). To program this new motor we have created some new function named slider_base_rotate()
which is similar to the rotate()
function because it takes the same parameter: degrees , power and direction. After implementing a rudimentary implementation and testing the motor would not move. We thought the problem was a hardware kind and to prove that we implemented in the control part file so that everytime the button X and Y on the gamepad1 is pressed the wheel would spin left or right. When we started the program the wheel moved fine without a problem. We debugged the code for half and hour and found out that the motor would move to the right but not to the left, the cause of that was that the distance would be positive no matter what even though the code for changing direction was:
if(dir == "right"){
distance = distance;
}else if(dir == "left){
distance = -distance;
}
We changed distance to degrees and the code ran fine:
if(dir == "right"){
degrees =degrees;
}else if(dir == "left){
degrees = -degrees;
}
After resolving the issue we have refactored the code:
calculate_distance()
now takes distance, wheel_diameter and ticks (because we use 2 diferent motors)
StimDC
class now takes DcMotor rotatory_base as a fifth argumentconst_lateral_movement
became CONST_LATERAL_MOVEMENT
TICKS_PER_REVOLUTION
became GO_TICKS_PER_REVOLUTION
since we now use 2 diferent types of motors, there should not be a confusion in the codeslider_wheel
became SLIDER_WHEEL
and changed from 1.12 cm to 0.4409 inToday i worked from home on the StimDC class and made these following changes:
init_slider(DcMotor slider, Servo c1, Servo c2)
and init_wheel_motors(DcMotor front_left, DcMotor front_right,DcMotor back_left, DcMotor back_right)
run_using_encoders()
will be deprecated and added run_using_encoders_wheel_motors()
and run_using_encoders_slider()
stop()
will be deprecated and added stop_wheel_power()
and stop_slider()
reset_encoders()
will be deprecated and added reset_encoders_wheel_motors()
and reset_encoders_slider()
slider_wheel
and rotatory_base
variables by multiplying the values by PI
because those were used for storing the circumference not the diameterlateral()
and rotate()
function the if statement from if(dir == "right")
to if(dir.equals("right"))
This week we have further optimised the StimDC class because the robot would sometimes wait seconds when stopping, reseting encoders, enabling encoders etc before 22.01.23 and started experimenting with Kotlin by cloning the StimDc class and renaming KStimDC for differentiating from each other
TO DO: