With our pathfinding code provided by the okapi library, the robot moves too fast. Is there a way to limit the speed of the motors?
Edit: turns out trusting someone elseās solution was not good idea. While this will slow the robot down, it will lose the trajectory completely. Keep reading for proper answer.
Ya @rpm answered you last time you asked yesterday. They just did it in a pretty confusing way.
Here is what they wanted you to see
profileControllerM->setTarget("C");
profileControllerS->removePath("B");
profileControllerM->generatePath({{0_in, 0_in, 0_deg}, {24_in, 0_in, 0_deg}}, "D");
profileControllerM->waitUntilSettled();
profileControllerM->setTarget("D",true);
profileControllerM->removePath("C");
profileControllerS->generatePath({{0_in, 0_in, 0_deg}, {12_in, 0_in, 0_deg}}, "E");
profileControllerM->waitUntilSettled();
chassis->getModel()->setMaxVelocity(gearing*.25);
chassis->turnAngle(-270_deg);
chassis->getModel()->setMaxVelocity(gearing);
profileControllerS->setTarget("E");
profileControllerS->waitUntilSettled();
profileControllerS->removePath("E");
}
void mabl3() {
info_printf(1,"in mabl3");
look on the git link in src/mab.cpp and function mabl1 near the bottom. if you need okapi 3.3.13 use the tag for it under branch near the top of the page.
1 Like
I tried that, and it did 1 thing. It gave me an error saying the ā was wrong. I did more research, and that just didnāt work. Also, does that even change the speed for the profilecontroller?
1 Like
When you create the profileController what arguments are you passing to it? Those are the limits.
I just used
AsyncMotionProfileControllerBuilder()
.withOutput(chassisMotion)
.withLimits({1.0, 2.0, 10.0})
.buildMotionProfileController();
void initialize() {
right_mtr.set_reversed(true);
right_back_mtr.set_reversed(true);
}
What do the limits mean?
1.0, // Maximum linear velocity of the Chassis in m/s
2.0, // Maximum linear acceleration of the Chassis in m/s/s
10.0, // Maximum linear jerk of the Chassis in m/s/s/s
4 Likes
Ok, thank you. The documentation for that is not helpful whatsoever.
1 Like
https://okapilib.github.io/OkapiLib/md_docs_tutorials_concepts_twodmotionprofiling.html
The current version of the okapilib docs have been updated with the comments explaining the limits. So hopefully people donāt get confused in the future.
Beauty of Open Source software. Anyone can choose to improve the code or the documentation for OkapiLib. Like I did here
OkapiLib:master
ā gftabor:patch-1
opened 06:05PM - 07 Mar 20 UTC
### Description of the Change
comments explaining limits copied from old docs⦠to new
### Motivation
https://www.vexforum.com/t/okapi-pathfinder/77226
### Possible Drawbacks
### Verification Process
None
### Applicable Issues
3 Likes
rpm
March 10, 2020, 4:01am
9
@tabor473 thanks for show me how to get a link to a specific line.
That weirdness was done b/c I was playing with cartridges and velocity is in rpms (ha) so here is the new comment for it:
////////////////////////////////////////////////////////////////////////
#include "robot.h"
#include "robot_gui.h"
void mabl1() {
info_printf(1,"in mabl1");
// example usage
// match_auton1(BLUE); // mirror of RED right
// velocity is in rpms which is dependent on the gear cartridge.
double gearing = (double)left_drive_motors.getGearing();
// test pathfinder using different profiles
profileControllerF->generatePath({{0_in, 0_in, 0_deg}, {36_in, 0_in, 0_deg}}, "A");
profileControllerF->setTarget("A");
// path with one waypoint. all points are suppose to be relative to the first point
// but to end close to x=0 from x=36 above, 24_in was needed. it should be noted
// that the runs are consistent even if the points are not exact.
profileControllerM->generatePath({{0_in, 0_in, 0_deg}, {10_in, 0_in, 0_deg}, {24_in, 28_in, 0_deg}}, "B");
profileControllerF->waitUntilSettled();
@M3Rocks in case you didnāt look at the profile controllersā¦
I noticed that the 3 profile controllers had a cut-n-paste error and were all the same. But they also documented what the Limits mean:
// hey what happened to using GearsetRatioPair on the chassis?
okapi::AbstractMotor::GearsetRatioPair drive_ratio = DRIVE_GEARSET * (DRIVE_GEARWHEEL/DRIVE_GEARMOTOR);
std::shared_ptr<okapi::ChassisController> chassis = okapi::ChassisControllerBuilder()
.withMotors(left_drive_motors,right_drive_motors)
.withDimensions(DRIVE_GEARSET,{{CHASSIS_WHEELS, CHASSIS_TRACK}, DRIVE_TPR})
.build();
// each parameter should be measured (or calculated) but can have individual scaling
// multple controllers can be defined for different uses for instance performing turns more slowly
std::shared_ptr<okapi::AsyncMotionProfileController> profileControllerF = okapi::AsyncMotionProfileControllerBuilder()
.withLimits({ 1.06 * 0.9, // Maximum linear velocity of the Chassis in m/s
2.00 * 0.9, // Maximum linear acceleration of the Chassis in m/s/s
10.00 * 0.9}) // Maximum linear jerk of the Chassis in m/s/s/s
.withOutput(*chassis) // Chassis Controller
.buildMotionProfileController();
std::shared_ptr<okapi::AsyncMotionProfileController> profileControllerM = okapi::AsyncMotionProfileControllerBuilder()
.withLimits({ 1.06 * 0.66, // Maximum linear velocity of the Chassis in m/s
2.00 * 0.66, // Maximum linear acceleration of the Chassis in m/s/s
10.00 * 0.66}) // Maximum linear jerk of the Chassis in m/s/s/s
I hope this helps.
1 Like