|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
SendableChoosers are causing me grief!
Hello! My name is Eric, and I am the lead programmer for team 3236. This is my first year, and so far, things are going good!
I am attempting to add radio buttons to my SmartDashboard so that I can choose the autonomous mode to run at a specific time. I am running it through a Command based system, as it seemed the easiest and most logical to my head. In Eclipse, functions like "AddDefault" or "AddObject" do not work when written like this: Code:
private:
Teleop *TeleopControls;
SendableChooser<Command *> *autonomouschooser;
Command *autonomousCommand;
virtual void RobotInit() override {
autonomouschooser->AddDefault("Basic Auto", new AutoDefault());
SmartDashboard::PutData("Chooser", autonomouschooser);
}
Code:
private:
Teleop *TeleopControls;
SendableChooser *autonomouschooser;
Command *autonomousCommand;
virtual void RobotInit() override {
autonomouschooser->AddDefault("Basic Auto", new AutoDefault());
SmartDashboard::PutData("Chooser", autonomouschooser);
}
I know that this is not because of an issue of "AutoDefault()" not existing, or anything along those lines. If anyone has a possible solution or explanation, we'd greatly appreciate it! Thank you! -Eric |
|
#2
|
||||
|
||||
|
Re: SendableChoosers are causing me grief!
This worked for us:
In Robot.h Code:
private:
frc::SendableChooser<frc::Command*> autoChooser;
std::unique_ptr<frc::Command> selectedMode;
Code:
Robot::RobotInit() {
autoChooser.AddDefault("Do Nothing", new DoNothing(15));
autoChooser.AddObject("Gear Align Center", new GearAlignCenter());
SmartDashboard::PutData("Auto Chooser", &autoChooser);
}
Robot::AutonomousInit() {
selectedMode.reset(autoChooser.GetSelected());
if(selectedMode != nullptr) {
selectedMode->Start();
}
}
Best Wishes, Drew Last edited by jreneew2 : 26-01-2017 at 17:34. |
|
#3
|
|||
|
|||
|
Re: SendableChoosers are causing me grief!
Are you including any other libraries? I get some errors with that setup.
Thanks for the quick reply btw! |
|
#4
|
||||
|
||||
|
Re: SendableChoosers are causing me grief!
I'm including
#include "WPILib.h" #include "RobotMap.h" in Robot.h and #include "Robot.h" in Robot.cpp What is the error your getting? |
|
#5
|
|||
|
|||
|
Re: SendableChoosers are causing me grief!
I get the errors "Symbol SendableChooser could not be resolved" and "Type ::Command could not be resolved"
|
|
#6
|
|||
|
|||
|
Re: SendableChoosers are causing me grief!
Quote:
I've actually gone and fixed these issues. When I write the code as you did, I get an error on SmartDashboard: utData("Auto modes", &autonomousChooser);The error I have is: invalid arguments Candidates are: void PutData(llvm::StringRef, frc::Sendable *) void PutData(frc::NamedSendable *) |
|
#7
|
||||
|
||||
|
Re: SendableChoosers are causing me grief!
Quote:
while the other team's example was NOT a pointer (no * before the variable name). As such, PutData is looking for a pointer to be sent to it... so you should not preceed it with & but instead just give the name of the variable (the pointer). The other team needs the & in order to give an address (pointer) to PutData. I believe if you remove the & you'll be good there. BTW, don't forget to 'new' any pointers before using them and 'delete' them at the end in some destructor like ~Robot() |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|