Go to Post Teams that TRY to win and TRY to do their best end up having students that learn more, learn the value of hard work, and are inspired by the process. - Chris Hibner [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 11-01-2017, 15:14
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: 157
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
SendableChooser changes and errors

It appears that SendableChooser is now a template based class. Is there any documentation on how to use it?

We made some changes to use it as:
Code:
SendableChooser<int> *pChoice;
pChoice = new SendableChooser<int>();
And once instantiated and objects are added, wanted to check it via:
Code:
int ch = pChoice->GetSelected();
or
Code:
int ch = (int)pChoice->GetSelected();
Both have been unsuccessful. Errors from compilation are:
Code:
arm-frc-linux-gnueabi-g++ -std=c++1y -I/Users/rwolff/wpilib/cpp/current/include -I/Users/rwolff/dev/robotics/FRCTeam1967/code/NatSndChTestJig/src -I/Users/rwolff/dev/robotics/FRCTeam1967/code/include -I/Users/rwolff/wpilib/user/cpp/include -O0 -g3 -Wall -c -fmessage-length=0 -o src/Robot.o ../src/Robot.cpp 
In file included from /Users/rwolff/wpilib/cpp/current/include/SmartDashboard/SendableChooser.h:51:0,
                 from /Users/rwolff/wpilib/cpp/current/include/WPILib.h:72,
                 from ../src/Robot.cpp:1:
/Users/rwolff/wpilib/cpp/current/include/SmartDashboard/SendableChooser.inc: In instantiation of 'T frc::SendableChooser<T>::GetSelected() [with T = int]':
../src/Robot.cpp:38:42:   required from here
/Users/rwolff/wpilib/cpp/current/include/SmartDashboard/SendableChooser.inc:60:12: error: cannot convert 'std::nullptr_t' to 'int' in return
     return nullptr;
            ^
/Users/rwolff/wpilib/cpp/current/include/SmartDashboard/SendableChooser.inc: In member function 'T frc::SendableChooser<T>::GetSelected() [with T = int]':
I'm not sure if maybe it's only intended to be used with classes or class pointers and not something simple like an int possibly? Or if there's something more basic in err here.

Thanks!
roboBob
__________________
~~~~~~~~~~~~~~~~~~~
Bob Wolff - Software from the old-school
Mentor / C / C++ guy
Team 1967 - The Janksters - San Jose, CA
Reply With Quote
  #2   Spotlight this post!  
Unread 11-01-2017, 17:02
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,572
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
Re: SendableChooser changes and errors

http://wpilib.screenstepslive.com/s/...smartdashboard shows how to use it with an object. Personally, I think SendableChooser is overkill for basic types that are supported by SmartDashboard, and would just use the SmartDashboard methods.
Reply With Quote
  #3   Spotlight this post!  
Unread 11-01-2017, 17:09
euhlmann's Avatar
euhlmann euhlmann is offline
CTO, Programmer
AKA: Erik Uhlmann
FRC #2877 (LigerBots)
Team Role: Leadership
 
Join Date: Dec 2015
Rookie Year: 2015
Location: United States
Posts: 361
euhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud of
Re: SendableChooser changes and errors

Quote:
Originally Posted by bob.wolff68 View Post
It appears that SendableChooser is now a template based class. Is there any documentation on how to use it?

We made some changes to use it as:
Code:
SendableChooser<int> *pChoice;
pChoice = new SendableChooser<int>();
And once instantiated and objects are added, wanted to check it via:
Code:
int ch = pChoice->GetSelected();
or
Code:
int ch = (int)pChoice->GetSelected();
Both have been unsuccessful. Errors from compilation are:
Code:
arm-frc-linux-gnueabi-g++ -std=c++1y -I/Users/rwolff/wpilib/cpp/current/include -I/Users/rwolff/dev/robotics/FRCTeam1967/code/NatSndChTestJig/src -I/Users/rwolff/dev/robotics/FRCTeam1967/code/include -I/Users/rwolff/wpilib/user/cpp/include -O0 -g3 -Wall -c -fmessage-length=0 -o src/Robot.o ../src/Robot.cpp 
In file included from /Users/rwolff/wpilib/cpp/current/include/SmartDashboard/SendableChooser.h:51:0,
                 from /Users/rwolff/wpilib/cpp/current/include/WPILib.h:72,
                 from ../src/Robot.cpp:1:
/Users/rwolff/wpilib/cpp/current/include/SmartDashboard/SendableChooser.inc: In instantiation of 'T frc::SendableChooser<T>::GetSelected() [with T = int]':
../src/Robot.cpp:38:42:   required from here
/Users/rwolff/wpilib/cpp/current/include/SmartDashboard/SendableChooser.inc:60:12: error: cannot convert 'std::nullptr_t' to 'int' in return
     return nullptr;
            ^
/Users/rwolff/wpilib/cpp/current/include/SmartDashboard/SendableChooser.inc: In member function 'T frc::SendableChooser<T>::GetSelected() [with T = int]':
I'm not sure if maybe it's only intended to be used with classes or class pointers and not something simple like an int possibly? Or if there's something more basic in err here.

Thanks!
roboBob
nullptr is std::nullptr_t while you set the return type to int. Make it return the correct type. You can use specialized template functions
__________________
Creator of SmartDashboard.js, an extensible nodejs/webkit replacement for SmartDashboard


https://ligerbots.org

Last edited by euhlmann : 11-01-2017 at 17:11.
Reply With Quote
  #4   Spotlight this post!  
Unread 11-01-2017, 17:33
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: 157
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: SendableChooser changes and errors

Joe - thanks for the pointer. I'll take a look at it working with an object instead of a int, but that seems a bug to me if it only works with objects. As for your statement about overkill ... this is being used for picking an autonomous 'mode' prior to match start ... how can you utilize SmartDashboard to do that? I don't see any way to choose from a list or a set of radio buttons or just buttons to do that.

Euhlmann - while I understand the error notes the different types, this is a template class now and as such, looking at the definition of GetSelected() shows that the type "T" of the template is used as the return type for that function. I templated it with <int> and yet the return of GetSelected() isn't returning that int.

roboBob
__________________
~~~~~~~~~~~~~~~~~~~
Bob Wolff - Software from the old-school
Mentor / C / C++ guy
Team 1967 - The Janksters - San Jose, CA
Reply With Quote
  #5   Spotlight this post!  
Unread 13-01-2017, 16:53
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: 157
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: SendableChooser changes and errors

BTW, I did get a good clean compile by changing the template type from<int> to <int*>. Seems a deficiency of the template class to me, but it compiled at least.
__________________
~~~~~~~~~~~~~~~~~~~
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 13:59.

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