38 const std::shared_ptr<ChassisModel> &imodel,
60 void generatePath(std::initializer_list<PathfinderPoint> iwaypoints,
const std::string &ipathId);
78 void generatePath(std::initializer_list<PathfinderPoint> iwaypoints,
79 const std::string &ipathId,
115 void setTarget(std::string ipathId,
bool ibackwards,
bool imirrored =
false);
151 void moveTo(std::initializer_list<PathfinderPoint> iwaypoints,
152 bool ibackwards =
false,
153 bool imirrored =
false);
164 void moveTo(std::initializer_list<PathfinderPoint> iwaypoints,
166 bool ibackwards =
false,
167 bool imirrored =
false);
248 void storePath(
const std::string &idirectory,
const std::string &ipathId);
257 void loadPath(
const std::string &idirectory,
const std::string &ipathId);
269 std::map<std::string, std::vector<squiggles::ProfilePoint>>
paths{};
271 std::shared_ptr<ChassisModel>
model;
294 std::unique_ptr<AbstractRate> rate);
305 const std::string &ipathId,
316 static std::string
makeFilePath(
const std::string &directory,
const std::string &filename);
321 std::istream &rightFile,
322 const std::string &ipathId);
324 static constexpr double DT = 0.01;
void moveTo(std::initializer_list< PathfinderPoint > iwaypoints, bool ibackwards=false, bool imirrored=false)
Generates a new path from the position (typically the current position) to the target and blocks unti...
bool isDisabled() const override
Returns whether the controller is currently disabled.
virtual void executeSinglePath(const std::vector< squiggles::ProfilePoint > &path, std::unique_ptr< AbstractRate > rate)
Follow the supplied path.
void waitUntilSettled() override
Blocks the current task until the controller has settled.
std::string getProcessValue() const override
This is overridden to return the current path.
void setTarget(std::string ipathId, bool ibackwards, bool imirrored=false)
Executes a path with the given ID.
void controllerSet(std::string ivalue) override
Writes the value of the controller output.
std::string getPathErrorMessage(const std::vector< PathfinderPoint > &points, const std::string &ipathId, int length)
void generatePath(std::initializer_list< PathfinderPoint > iwaypoints, const std::string &ipathId)
Generates a path which intersects the given waypoints and saves it internally with a key of pathId.
void flipDisable(bool iisDisabled) override
Sets whether the controller is off or on.
void internalStorePath(std::ostream &file, const std::string &ipathId)
std::shared_ptr< Logger > logger
CrossplatformMutex currentPathMutex
std::map< std::string, std::vector< squiggles::ProfilePoint > > paths
void internalLoadPathfinderPath(std::istream &leftFile, std::istream &rightFile, const std::string &ipathId)
void generatePath(std::initializer_list< PathfinderPoint > iwaypoints, const std::string &ipathId, const PathfinderLimits &ilimits)
Generates a path which intersects the given waypoints and saves it internally with a key of pathId.
static constexpr double DT
void moveTo(std::initializer_list< PathfinderPoint > iwaypoints, const PathfinderLimits &ilimits, bool ibackwards=false, bool imirrored=false)
Generates a new path from the position (typically the current position) to the target and blocks unti...
std::vector< std::string > getPaths()
Gets the identifiers of all paths saved in this AsyncMotionProfileController.
std::atomic_bool isRunning
bool removePath(const std::string &ipathId)
Removes a path and frees the memory it used.
void flipDisable() override
Changes whether the controller is off or on.
static std::string makeFilePath(const std::string &directory, const std::string &filename)
Joins and escapes a directory and file name.
QAngularSpeed convertLinearToRotational(QSpeed linear) const
Converts linear chassis speed to rotational motor speed.
AsyncMotionProfileController(const TimeUtil &itimeUtil, const PathfinderLimits &ilimits, const std::shared_ptr< ChassisModel > &imodel, const ChassisScales &iscales, const AbstractMotor::GearsetRatioPair &ipair, const std::shared_ptr< Logger > &ilogger=Logger::getDefaultLogger())
An Async Controller which generates and follows 2D motion profiles.
std::atomic_int direction
void loadPath(const std::string &idirectory, const std::string &ipathId)
Loads a path from a directory on the SD card containing a path CSV file.
AbstractMotor::GearsetRatioPair pair
void setMaxVelocity(std::int32_t imaxVelocity) override
This implementation does nothing because the maximum velocity is configured using PathfinderLimits el...
std::atomic_bool disabled
void reset() override
Resets the controller so it can start from 0 again properly.
CrossplatformThread * task
std::string getTarget() override
Gets the last set target, or the default target if none was set.
CrossplatformThread * getThread() const
PathfinderPoint getError() const override
Returns the last error of the controller.
std::atomic_bool dtorCalled
bool isSettled() override
Returns whether the controller has settled at the target.
std::atomic_bool mirrored
void forceRemovePath(const std::string &ipathId)
Attempts to remove a path without stopping execution.
~AsyncMotionProfileController() override
void storePath(const std::string &idirectory, const std::string &ipathId)
Saves a generated path to a file.
AsyncMotionProfileController(AsyncMotionProfileController &&other)=delete
static void trampoline(void *context)
void setTarget(std::string ipathId) override
Executes a path with the given ID.
void internalLoadPath(std::istream &file, const std::string &ipathId)
AsyncMotionProfileController & operator=(AsyncMotionProfileController &&other)=delete
void startThread()
Starts the internal thread.
void tarePosition() override
This implementation does nothing because the API always requires the starting position to be specifie...
std::shared_ptr< ChassisModel > model
static std::shared_ptr< Logger > getDefaultLogger()
Utility class for holding an AbstractTimer, AbstractRate, and SettledUtil together in one class since...
A simple structure representing the full ratio between motor and wheel.