|
|
|
![]() |
|
|||||||
|
||||||||
|
|
Thread Tools | Rate Thread | Display Modes |
|
#3
|
|||
|
|||
|
Re: CAN follower mode
This is all the code to make our robot move forward the specified feet. leftMot is on id 4, rightMot is on id 3 and diameter is just a constant.
void driveFeet(double feet=10,double speed=.5){ leftMot->SetPosition(0); rightMot->SetPosition(0); rightMot->SetControlMode(rightMot->kFollower); rightMot->Set(4); double distance=abs(feet/(3.1415*diameter)*1000.0); while(abs(leftMot->GetEncPosition())<distance){ leftMot->Set((feet>0?speed:-speed)*(1-(abs(leftMot->GetEncPosition())/distance))); } leftMot->Set(0); } |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|