mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-27 02:01:42 +00:00
Simplify Sendable interface (#1864)
This removes the name and subsystem from individual objects, and instead puts this data into a new singleton class, SendableRegistry. Much of LiveWindow has been refactored into SendableRegistry. In C++, a new CRTP helper class, SendableHelper, has been added to provide move and destruction functionality. Shims for GetName, SetName, GetSubsystem, and SetSubsystem have been added to Command and Subsystem (both old and new), and also to SendableHelper to prevent code breakage. This deprecates SendableBase in preparation for future removal.
This commit is contained in:
@@ -10,6 +10,8 @@
|
||||
#include <wpi/raw_ostream.h>
|
||||
|
||||
#include "frc/drive/RobotDriveBase.h"
|
||||
#include "frc/smartdashboard/Sendable.h"
|
||||
#include "frc/smartdashboard/SendableHelper.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
@@ -96,7 +98,9 @@ class SpeedController;
|
||||
* RobotDrive#Drive(double, double) with the addition of a quick turn
|
||||
* mode. However, it is not designed to give exactly the same response.
|
||||
*/
|
||||
class DifferentialDrive : public RobotDriveBase {
|
||||
class DifferentialDrive : public RobotDriveBase,
|
||||
public Sendable,
|
||||
public SendableHelper<DifferentialDrive> {
|
||||
public:
|
||||
static constexpr double kDefaultQuickStopThreshold = 0.2;
|
||||
static constexpr double kDefaultQuickStopAlpha = 0.1;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2017-2018 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2017-2019 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -13,6 +13,8 @@
|
||||
|
||||
#include "frc/drive/RobotDriveBase.h"
|
||||
#include "frc/drive/Vector2d.h"
|
||||
#include "frc/smartdashboard/Sendable.h"
|
||||
#include "frc/smartdashboard/SendableHelper.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
@@ -44,7 +46,9 @@ class SpeedController;
|
||||
* and the positive Z axis points down. Rotations follow the right-hand rule, so
|
||||
* clockwise rotation around the Z axis is positive.
|
||||
*/
|
||||
class KilloughDrive : public RobotDriveBase {
|
||||
class KilloughDrive : public RobotDriveBase,
|
||||
public Sendable,
|
||||
public SendableHelper<KilloughDrive> {
|
||||
public:
|
||||
static constexpr double kDefaultLeftMotorAngle = 60.0;
|
||||
static constexpr double kDefaultRightMotorAngle = 120.0;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2008-2018 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2008-2019 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -12,6 +12,8 @@
|
||||
#include <wpi/raw_ostream.h>
|
||||
|
||||
#include "frc/drive/RobotDriveBase.h"
|
||||
#include "frc/smartdashboard/Sendable.h"
|
||||
#include "frc/smartdashboard/SendableHelper.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
@@ -62,7 +64,9 @@ class SpeedController;
|
||||
* RobotDrive#MecanumDrive_Polar(double, double, double) if a
|
||||
* deadband of 0 is used.
|
||||
*/
|
||||
class MecanumDrive : public RobotDriveBase {
|
||||
class MecanumDrive : public RobotDriveBase,
|
||||
public Sendable,
|
||||
public SendableHelper<MecanumDrive> {
|
||||
public:
|
||||
/**
|
||||
* Construct a MecanumDrive.
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
#include <wpi/raw_ostream.h>
|
||||
|
||||
#include "frc/MotorSafety.h"
|
||||
#include "frc/smartdashboard/SendableBase.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
@@ -22,7 +21,7 @@ class SpeedController;
|
||||
/**
|
||||
* Common base class for drive platforms.
|
||||
*/
|
||||
class RobotDriveBase : public MotorSafety, public SendableBase {
|
||||
class RobotDriveBase : public MotorSafety {
|
||||
public:
|
||||
/**
|
||||
* The location of a motor on the robot for the purpose of driving.
|
||||
|
||||
Reference in New Issue
Block a user