Skip to content
This repository has been archived by the owner on Apr 5, 2020. It is now read-only.

Best way for turn a specific number of degrees? #15

Open
MikeHouser opened this issue Feb 11, 2016 · 1 comment
Open

Best way for turn a specific number of degrees? #15

MikeHouser opened this issue Feb 11, 2016 · 1 comment

Comments

@MikeHouser
Copy link

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

@njsokalski
Copy link

To turn your robot 90 degrees, you basically need to do a calculation based on the following values:

  1. Distance between the wheels or treads
  2. Radius of the wheels or wheels turning the treads
    So here are the basic steps for you:
  3. Determine the distance each wheel/tread needs to travel: distancetotravel=wheelspacing_Pi_(90/360)
  4. Determine the distance 1 rotation of the motor will travel: onerotationdistance=2_Pi_wheelradius
  5. Determine the number of rotations required to rotate your tank 90 degrees: requiredrotations=distancetotravel/onerotationdistance
  6. 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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants