Kaleo03
January 25, 2022, 3:34am
#1
Hi guys, I’m trying to do more with my old functions ideas I use to teacher my old kids, and integrate a smart drive into it, I’m getting red marks on this, can someone point me in the right direction?
competition Competition;
motor_group LeftSide(LeftFront, LeftBack);
motor_group RightSide(RightFront, RightBack);
motor_group ArmsGo(ArmLeft, ArmRight);
smartdrive robotDrive(LeftSide, RightSide, Inertial12, 12.56, 16, 16, distanceUnits::in);
void drivingF(int distance, int speed, int direction) {
robotDrive.driveFor(distance, distanceUnits::in, speed, velocityUnits::pct, direction, directionType::fwd);
}
this is what I use to use for funtions:
void dforward(int distance, int speed) { //Drive Forward
Left.rotateFor(-distance, rotationUnits::deg,speed,velocityUnits::pct,false);
Lefter.rotateFor(-distance, rotationUnits::deg,speed,velocityUnits::pct,false);
Right.rotateFor(distance, rotationUnits::deg,speed,velocityUnits::pct,false);
Righter.rotateFor(distance, rotationUnits::deg,speed,velocityUnits::pct);
}
xTigr
January 25, 2022, 4:09am
#2
When you specify the direction, you don’t do
Kaleo03:
robotDrive.driveFor(distance, distanceUnits::in, speed, velocityUnits::pct, direction, directionType::fwd);
Instead, it should be like this
void drivingF(int distance, int speed, directionType direction){
robotDrive.driveFor(direction, distance, distanceUnits::in, speed, velocityUnits::pct);
}
The directionType goes first, and you don’t need an int for it. You can just pass in the directionType as a parameter. You can then call it like this
drivingF(15, 50, forward);
Here is the API docs if you want more info
2 Likes
Kaleo03
January 25, 2022, 6:59am
#3
Thank you, really appreciate that
Kaleo03
January 26, 2022, 2:25am
#4
Ok sorry last question I think, how bout for turns, I’m getting a red line for turnType, so not sure what I need to do:
void drivingT(int angle, int speed, int turn){
robotDrive.turnFor(turn, turnType::dir, angle, rotationUnits::deg);
}
xTigr
January 26, 2022, 3:31am
#5
Same as above, you have to do this
void drivingT(int angle, int speed, turnType turn){
robotDrive.turnFor(turn, angle, deg);
}
2 Likes