Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   C/C++ (http://www.chiefdelphi.com/forums/forumdisplay.php?f=183)
-   -   SmartDashboard with CommandBasedRobot Template (http://www.chiefdelphi.com/forums/showthread.php?t=114938)

CardcaptorRLH85 13-03-2013 04:47

SmartDashboard with CommandBasedRobot Template
 
Since all of the tweaking of our robot code with regards to its proper operation are done, I've been working on customizing the dashboard using SmartDashboard. However, as I'm using the CommandBasedRobot template, I've run into a puzzling issue. I have no idea where to put all of my SmartDashboard::PutNumber... commands.

I've come up with three ideas, and reasons why each of them may not work properly.

1) Place the SmartDashboard output commands in the Subsystem functions that access the required objects.
Problem: I end up with SmartDashboard code everywhere and that seems a bit messy.

2) Create a SmartDashboardOutput Command. (This is what I was doing before posting this topic.)
Problem: It 'Requires' every Subsystem that I want output from and I'm worried that those requirements (and the interrupts that they will cause) will stop the robot from functioning correctly.

3) Put copies of all the SmartDashboard commands in the appropriate functions (DisabledPeriodic, AutonomousPeriodic, and TeleopPeriodic) of the CommandBasedRobot.cpp file.
Problem: This seems to make the most sense but I'm not sure that this is where these things should go. Also, I'd end up with three copies of each output line.

I've read the SmartDashboard guide but all of its code examples seem to use the SimpleRobot template so I haven't been able to use that as a reference for this purpose.

Normally, if I couldn't figure something like this out, I'd just write it all three ways and test by trial-and-error but, we only have so many 'Robot Access Period' hours before this weekend and I'd rather not waste any driver practice time with unnecessary flashing.

Thanks for any help you can provide ^_^

Jefferson 13-03-2013 09:34

Re: SmartDashboard with CommandBasedRobot Template
 
We created a function to hold all the SmartDashboard calls in the robot class. It is hooked to a GetRawButton on the joystick inside each of the appropriate functions. That way we aren't sending all the data when we don't have to have it.

AlexBrinister 13-03-2013 15:45

Re: SmartDashboard with CommandBasedRobot Template
 
We just have it in our TeleopPeriodic() loop running at whatever interval we set it to from the Dashboard. Personally, I would just make a function and put it in a vxWorks task instead of thinking about it too hard. But then again, that would defeat the purpose of Command-based robot, which is to eliminate any reason why you would worry about relatively complex things like threading.

Alex Brinister

BigJ 13-03-2013 16:33

Re: SmartDashboard with CommandBasedRobot Template
 
Quote:

Originally Posted by CardcaptorRLH85 (Post 1247508)
2) Create a SmartDashboardOutput Command. (This is what I was doing before posting this topic.)
Problem: It 'Requires' every Subsystem that I want output from and I'm worried that those requirements (and the interrupts that they will cause) will stop the robot from functioning correctly.

You don't have to "require" the subsystems. If all you are doing is reading from them, it is fine. Because the Command extends CommandBase, you have access to the subsystem. the only thing that requires() does is stop other commands that require the subsystem because you are ostensibly going to affect the subsystems outputs.

TL;DR: If you are using a subsystem as read-only it is probably safe not to require it, AFAIK.

CardcaptorRLH85 13-03-2013 16:37

Re: SmartDashboard with CommandBasedRobot Template
 
Quote:

Originally Posted by BigJ (Post 1247715)
You don't have to "require" the subsystems. If all you are doing is reading from them, it is fine. Because the Command extends CommandBase, you have access to the subsystem. the only thing that requires() does is stop other commands that require the subsystem because you are ostensibly going to affect the subsystems outputs.

TL;DR: If you are using a subsystem as read-only it is probably safe not to require it, AFAIK.

Really? If that's true then I should be good. Thanks ^_^

Jefferson 13-03-2013 20:53

Re: SmartDashboard with CommandBasedRobot Template
 
I have not been able to get commands to run in disabled. If you are able to, I'd like to know how.

Joe Ross 13-03-2013 21:27

Re: SmartDashboard with CommandBasedRobot Template
 
Quote:

Originally Posted by Jefferson (Post 1247837)
I have not been able to get commands to run in disabled. If you are able to, I'd like to know how.

In Java, there is a setRunWhileDisabled method, that you can call in the constructor of the command. You also need to call the scheduler in the disabledPeriodic. I assume it's similar in C++.

Jefferson 13-03-2013 21:40

Re: SmartDashboard with CommandBasedRobot Template
 
Quote:

Originally Posted by Joe Ross (Post 1247852)
In Java, there is a setRunWhileDisabled method, that you can call in the constructor of the command. You also need to call the scheduler in the disabledPeriodic. I assume it's similar in C++.

Ah. Probably. I was running the scheduler, but didnt know about the setRunWhileDisabled option. I'll check it out tonight.

Thanks

CardcaptorRLH85 13-03-2013 21:42

Re: SmartDashboard with CommandBasedRobot Template
 
Quote:

Originally Posted by Jefferson (Post 1247837)
I have not been able to get commands to run in disabled. If you are able to, I'd like to know how.

Quote:

Originally Posted by Joe Ross (Post 1247852)
In Java, there is a setRunWhileDisabled method, that you can call in the constructor of the command. You also need to call the scheduler in the disabledPeriodic. I assume it's similar in C++.

Yup, in C++ it works like this:

Code:

        virtual void RobotInit() {
                CommandBase::init();
                lw = LiveWindow::GetInstance();
               
                RandomCommand->SetRunWhenDisabled(true);
        }
        .
        .
        .
        virtual void DisabledPeriodic() {
                RandomCommand->Run();
                Scheduler::GetInstance()->Run();
        }



All times are GMT -5. The time now is 12:49.

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