So I have been working on a program for our tank drive to have it drive with one joystick. Currently I have a code that can only turn right or left and move forward and backward, but it cant move forward while turning. This drive works by having a simple code that states if the absolute value of the y coordinate (Channel 2/3) is larger than the absolute value of the x coordinate (Channel 1/4) then I set the motors to the power of the y coordinate, thus moving the robot forward if the joystick is upward and moving backward if its downward. Similarly, if the absolute value of the x coordinate is greater than that of the y coordinate, the robot will move its motors at the x coordinates power in opposite directions, with one side of motors reversed, so if its on the right the robot turns right and if its on the left it turns left. A sample piece of code (without correct syntax):
if absval(Ch3)>=absval(Ch4){
leftmotors=rightmotors=Ch3
}
else if absval(Ch4)>absval(Ch3){
leftmotors=-1*rightmotors=Ch4
}
Now I made one that can curve while moving forward and backward, depending on where the joystick is, the closer you are to the top or bottom, the less amount of turn and more forward/backward motion, and the closer you are to the right and left, the more turn and less forward movement, with full to the right being both sides moving with full power in opposite directions. I tried a code that is something like this:
left side motors = ycoor + xcoor
right side motors = ycoor - xcoor
I was just wondering what you guys think of both programs and which one you opiniate would be better or easier to drive. Also please don’t hesitate to tell me if there is something wrong with the logic for the curve drive, I don’t believe there is but I could be wrong.