Mostrar valores de LiveWindow
LiveWindow will automatically add your sensors and actuators for you. There is no need to do it manually. LiveWindow values may also be displayed by writing the code yourself and adding it to your robot program. This allows you to customize the names and group them in subsystems. This is a convenient method of displaying whether they are actual command based program subsystems or just a grouping that you decide to use in your program.
Agregar el código necesario a su programa
For each sensor or actuator that is created, set the subsystem name and display name by calling setName
(SetName
in C++). When the SmartDashboard is put into LiveWindow mode, it will display the sensors and actuators.
Ultrasonic ultrasonic = new Ultrasonic(1, 2);
SendableRegistry.setName(ultrasonic, "Arm", "Ultrasonic");
Jaguar elbow = new Jaguar(1);
SendableRegistry.setName(elbow, "Arm", "Elbow");
Victor wrist = new Victor(2);
SendableRegistry.setName(wrist, "Arm", "Wrist");
frc::Ultrasonic ultrasonic{1, 2};
SendableRegistry::SetName(ultrasonic, "Arm", "Ultrasonic");
frc::Jaguar elbow{1};
SendableRegistry::SetName(elbow, "Arm", "Elbow");
frc::Victor wrist{2};
SendableRegistry::SetName(wrist, "Arm", "Wrist");
from wpilib import Jaguar, Ultrasonic, Victor
from wpiutil import SendableRegistry
ultrasonic = Ultrasonic(1, 2)
SendableRegistry.setName(ultrasonic, "Arm", "Ultrasonic")
elbow = Jaguar(1)
SendableRegistry.setName(elbow, "Arm", "Elbow")
wrist = Victor(2)
SendableRegistry.setName(wrist, "Arm", "Wrist")
If your objects are in a Subsystem
, this can be simplified using the addChild method of SubsystemBase
Ultrasonic ultrasonic = new Ultrasonic(1, 2);
addChild("Ultrasonic", ultrasonic);
Jaguar elbow = new Jaguar(1);
addChild("Elbow", elbow);
Victor wrist = new Victor(2);
addChild("Wrist", wrist);
frc::Ultrasonic ultrasonic{1, 2};
AddChild("Ultrasonic", ultrasonic);
frc::Jaguar elbow{1};
AddChild("Elbow", elbow);
frc::Victor wrist{2};
AddChild("Wrist", wrist);
from wpilib import Jaguar, Ultrasonic, Victor
from commands2 import SubsystemBase
ultrasonic = Ultrasonic(1, 2)
SubsystemBase.addChild("Ultrasonic", ultrasonic)
elbow = Jaguar(1)
SubsystemBase.addChild("Elbow", elbow)
wrist = Victor(2)
SubsystemBase.addChild("Wrist", wrist)
Visualizar el display en la SmartDashboard
Los sensores y actuadores añadidos a LiveWindow se mostrarán agrupados por subsistema. El nombre del subsistema es sólo una agrupación arbitraria para organizar la visualización de los sensores. Los actuadores también pueden operarse, operando el intensificador para los dos controladores del motor.