mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-05 03:21:42 +00:00
[wpilib] ExHub Follower Fixes (#8892)
A chunk of updates to followers on Expansion Hub Fixes followers not implicitly enabling. Allows followers to follow other followers Throws exceptions on construction if a follower cycle is detected. Allows reversing followers. The enable thing will fix https://github.com/wpilibsuite/SystemcoreTesting/discussions/259#discussioncomment-16886195 Closes #8843 Depends on https://github.com/wpilibsuite/scservices/pull/30
This commit is contained in:
@@ -79,6 +79,9 @@ class ExpansionHub {
|
||||
bool CheckAndReserveMotor(int channel);
|
||||
void UnreserveMotor(int channel);
|
||||
|
||||
void AddFollower(int leaderChannel, int followerChannel);
|
||||
void RemoveFollower(int followerChannel);
|
||||
|
||||
void ReportUsage(std::string_view device, std::string_view data);
|
||||
|
||||
class DataStore;
|
||||
|
||||
@@ -19,6 +19,14 @@ namespace wpi {
|
||||
* ExpansionHub. */
|
||||
class ExpansionHubMotor {
|
||||
public:
|
||||
/** The direction to follow a leader motor in when using the follow method. */
|
||||
enum class FollowDirection {
|
||||
/** Follow the leader motor in the same direction. */
|
||||
Aligned,
|
||||
/** Follow the leader motor in the opposite direction. */
|
||||
Opposed
|
||||
};
|
||||
|
||||
/**
|
||||
* Constructs a servo at the requested channel on a specific USB port.
|
||||
*
|
||||
@@ -144,8 +152,14 @@ class ExpansionHubMotor {
|
||||
* Additionally, the direction of both motors will be the same.
|
||||
*
|
||||
* @param leader The motor to follow
|
||||
* @param direction The direction to follow the leader
|
||||
*/
|
||||
void Follow(const ExpansionHubMotor& leader);
|
||||
void Follow(const ExpansionHubMotor& leader, FollowDirection direction);
|
||||
|
||||
/**
|
||||
* Stops following the currently set leader motor.
|
||||
*/
|
||||
void Unfollow();
|
||||
|
||||
private:
|
||||
ExpansionHub m_hub;
|
||||
|
||||
Reference in New Issue
Block a user