Hi,
my name is Mike and I'm trying to get into the functionality of the API.
I have a little robot that drives as 'tank'. Would you please tell me, what is the best way to turn the robot 90 degrees?
To turn your robot 90 degrees, you basically need to do a calculation based on the following values:
Distance between the wheels or treads
Radius of the wheels or wheels turning the treads
So here are the basic steps for you:
Determine the distance each wheel/tread needs to travel: distancetotravel=wheelspacingPi(90/360)
Determine the distance 1 rotation of the motor will travel: onerotationdistance=2_Pi_wheelradius
Determine the number of rotations required to rotate your tank 90 degrees: requiredrotations=distancetotravel/onerotationdistance
Determine the number of degrees to rotate the motor: motordegrees=360_requiredrotations
So, the final simplified answer is rotate the motors the following number of degrees:
motordegrees=(wheelspacing_degreestorotatetank)/(2*wheelradius)
I would suggest making this a function that takes degreestorotatetank as a parameter (instead of a function just for 90 degrees), you can also define wheelspacing & wheelradius as constants. Hopefully this helps.
Hi, my name is Mike and I'm trying to get into the functionality of the API. I have a little robot that drives as 'tank'. Would you please tell me, what is the best way to turn the robot 90 degrees?
public async Task<bool> TurnRight90Degrees() { _brick.BatchCommand.StepMotorAtSpeed(_drivePortRight, _state.SpeedInverted, 200 /* try values here */, BRAKE); _brick.BatchCommand.StepMotorAtSpeed(_drivePortLeft, _state.Speed, 200, BRAKE); await _brick.BatchCommand.SendCommandAsync(); return true; }
also i can't find any hints what this method is for:
StepMotorSync
would you be so nice to explain it to me?
thanks! cheers mike