Skip to content

Commit 4b6c420

Browse files
authored
Merge pull request #6 from team914/dev
👌 v0.9.3
2 parents 68f7849 + 801b4c7 commit 4b6c420

File tree

7 files changed

+31
-7
lines changed

7 files changed

+31
-7
lines changed

autolib@0.9.3.zip

76.2 KB
Binary file not shown.

bin/_pros_ld_timestamp.o

0 Bytes
Binary file not shown.

bin/monolith.bin

320 Bytes
Binary file not shown.

bin/monolith.elf

376 Bytes
Binary file not shown.

include/autolib/auto/purePursuit.hpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,20 @@ class PurePursuit {
5353
PurePursuitTriangle run( const okapi::OdomState &ipose, const std::string &iid );
5454
PurePursuitTriangle run( const Pose &ipose, const std::string &iid );
5555

56+
/**
57+
* This should be used in a loop during your autonomous. It is static, but is meant for the PurePursuit class.
58+
* It is recommended to use motion profiling for the first parameter. The second parameter should be from your
59+
* run method from the PurePursuit class. The third method should be from you okapi's ChassisControllerBuilder.
60+
*
61+
* Note: Using this method is optional. You can and probably should create your own controller to use the triangle
62+
* motor output This is only meant for users of okapi >= v4.0.0.
63+
*
64+
* @param {double} reqVelocity :
65+
* @param {PurePursuitTriangle} triangle :
66+
* @param {std::shared_ptr<OdomChassisController>} controller :
67+
*/
68+
static void updateChassis( const double &reqVelocity, const PurePursuitTriangle &triangle, const std::shared_ptr<OdomChassisController> &controller );
69+
5670
protected:
5771
const std::vector<IndexedDistancePosePath> paths;
5872
IndexedDistancePosePath path;

src/auto/purePursuit.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,15 @@ PurePursuitTriangle PurePursuit::run( const Pose &ipose, const std::string &iid
3939
return findPurePursuitTriangle();
4040
}
4141

42+
void PurePursuit::updateChassis( const double &reqVelocity, const PurePursuitTriangle &itriangle, const std::shared_ptr<OdomChassisController> &controller ){
43+
PurePursuitTriangle triangle = itriangle;
44+
double curvature_scales = triangle.localGoalPose.yaw * (controller->getChassisScales().wheelTrack.convert(meter))/2;
45+
double left = reqVelocity * ( 2 + curvature_scales )/2;
46+
double right = reqVelocity * ( 2 - curvature_scales )/2;
47+
controller->getModel()->left( left );
48+
controller->getModel()->right( right );
49+
}
50+
4251
void PurePursuit::findPath( const std::string &iid ){
4352
for( const auto &ipath: paths ){
4453
if( ipath.id == iid ){

src/opcontrol.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,27 +14,25 @@ void opcontrol() {
1414
std::make_shared<Logger>(std::make_unique<Timer>(), "/ser/sout", Logger::LogLevel::debug));
1515

1616
controller = ChassisControllerBuilder()
17-
.withMotors({1, -2}, {-6, 7})
18-
.withSensors( IntegratedEncoder{ 1 }, IntegratedEncoder{ 6, true } )
19-
.withOdometry( StateMode::FRAME_TRANSFORMATION )
17+
.withMotors({-1, 2}, {6, -7})
18+
.withSensors( IntegratedEncoder{ 1, true }, IntegratedEncoder{ 6 } )
19+
.withOdometry( StateMode::CARTESIAN )
2020
.withGearset( AbstractMotor::GearsetRatioPair{ AbstractMotor::gearset::green, 5/3 } )
2121
.withDimensions( {{3.75_in, 15_in}, 900} )
2222
.buildOdometry();
23-
23+
2424
model = controller->getModel();
2525

2626
PathGenerator pathGenerator( {1.0, 2.0, 4.0} );
2727
pathGenerator.generatePath(
2828
{
2929
Pose{ 1_ft, 1_ft, 270_deg },
3030
Pose{ 1_ft, 0_ft, 90_deg }
31-
},
31+
},
3232
std::string("test")
3333
);
3434

3535
autolib::PurePursuit purePursuit( pathGenerator.getPaths(), 1_ft );
36-
auto state = controller->getState();
37-
PurePursuitTriangle triangle = purePursuit.run( state, std::string("test") );
3836

3937
// pros::Task printSensorValsTask(printSensorVals);
4038

@@ -43,6 +41,9 @@ void opcontrol() {
4341
// drive->moveDistance(6_in);
4442

4543
while (true) {
44+
auto state = controller->getState();
45+
PurePursuit::updateChassis( 50, purePursuit.run( state, std::string("test") ), controller );
46+
4647
pros::delay(50);
4748
}
4849
}

0 commit comments

Comments
 (0)