Go to Post It is not brains but desire that matters. - Lancer Robotics [more]
Home
Go Back   Chief Delphi > Technical > Programming > C/C++
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 26-01-2017, 16:43
ebernerrd ebernerrd is offline
Registered User
FRC #3236
 
Join Date: Jan 2017
Location: Franklin, MA
Posts: 8
ebernerrd is an unknown quantity at this point
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);
		}
However, Eclipse recognizes these functions when the code is written as such:
Code:
private:
		Teleop *TeleopControls;
		SendableChooser *autonomouschooser;
		Command *autonomousCommand;



		virtual void RobotInit() override {
			autonomouschooser->AddDefault("Basic Auto", new AutoDefault());
			SmartDashboard::PutData("Chooser", autonomouschooser);
		}
In this case, I get the error "invalid use of template-name 'frc::SendableChooser' without an argument list".

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
Reply With Quote
  #2   Spotlight this post!  
Unread 26-01-2017, 17:22
jreneew2's Avatar
jreneew2 jreneew2 is offline
Alumni of Team 2053 Tigertronics
AKA: Drew Williams
FRC #2053 (TigerTronics)
Team Role: Programmer
 
Join Date: Jan 2014
Rookie Year: 2013
Location: Vestal, NY
Posts: 213
jreneew2 has a spectacular aura aboutjreneew2 has a spectacular aura aboutjreneew2 has a spectacular aura about
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;
In Robot.cpp
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();
    }
}
Good luck with the season!

Best Wishes,
Drew

Last edited by jreneew2 : 26-01-2017 at 17:34.
Reply With Quote
  #3   Spotlight this post!  
Unread 26-01-2017, 17:38
ebernerrd ebernerrd is offline
Registered User
FRC #3236
 
Join Date: Jan 2017
Location: Franklin, MA
Posts: 8
ebernerrd is an unknown quantity at this point
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!
Reply With Quote
  #4   Spotlight this post!  
Unread 26-01-2017, 17:56
jreneew2's Avatar
jreneew2 jreneew2 is offline
Alumni of Team 2053 Tigertronics
AKA: Drew Williams
FRC #2053 (TigerTronics)
Team Role: Programmer
 
Join Date: Jan 2014
Rookie Year: 2013
Location: Vestal, NY
Posts: 213
jreneew2 has a spectacular aura aboutjreneew2 has a spectacular aura aboutjreneew2 has a spectacular aura about
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?
Reply With Quote
  #5   Spotlight this post!  
Unread 27-01-2017, 14:24
ebernerrd ebernerrd is offline
Registered User
FRC #3236
 
Join Date: Jan 2017
Location: Franklin, MA
Posts: 8
ebernerrd is an unknown quantity at this point
Re: SendableChoosers are causing me grief!

Quote:
Originally Posted by jreneew2 View Post
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?
I get the errors "Symbol SendableChooser could not be resolved" and "Type ::Command could not be resolved"
Reply With Quote
  #6   Spotlight this post!  
Unread 28-01-2017, 14:16
ebernerrd ebernerrd is offline
Registered User
FRC #3236
 
Join Date: Jan 2017
Location: Franklin, MA
Posts: 8
ebernerrd is an unknown quantity at this point
Re: SendableChoosers are causing me grief!

Quote:
Originally Posted by ebernerrd View Post
I get the errors "Symbol SendableChooser could not be resolved" and "Type ::Command could not be resolved"

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 *)
Reply With Quote
  #7   Spotlight this post!  
Unread 29-01-2017, 13:16
bob.wolff68's Avatar
bob.wolff68 bob.wolff68 is offline
Da' Mentor Man
FRC #1967
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2007
Location: United States
Posts: 158
bob.wolff68 is just really nicebob.wolff68 is just really nicebob.wolff68 is just really nicebob.wolff68 is just really nicebob.wolff68 is just really nice
Re: SendableChoosers are causing me grief!

Quote:
Originally Posted by ebernerrd View Post
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 *)
autonomousChoose was defined as a pointer already "SendableChooser<Command *> *autonomousChooser"

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()
__________________
~~~~~~~~~~~~~~~~~~~
Bob Wolff - Software from the old-school
Mentor / C / C++ guy
Team 1967 - The Janksters - San Jose, CA
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 20:22.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi