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:
Peter Johnson
2019-09-14 15:22:54 -05:00
committed by GitHub
parent 1d8c4d016f
commit 471f375a38
216 changed files with 2448 additions and 1433 deletions

View File

@@ -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;

View File

@@ -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;

View File

@@ -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.

View File

@@ -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.