Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   C/C++ (http://www.chiefdelphi.com/forums/forumdisplay.php?f=183)
-   -   Need SmartDashboard Help (http://www.chiefdelphi.com/forums/showthread.php?t=90512)

sircedric4 30-01-2011 11:56

Need SmartDashboard Help
 
I really like the looks and simplicity of the SmartDashboard listed in the WPI user's guide but I can't figure out how to get it setup and working.

How do I get the dashboard program to load on the Classmate in place of the Labview default. The readme for SmartDashboard does not describe how to setup it up on the Classmate.

Simple step by step instructions would be best. I tried simply deleteing the Dashboard.exe within the FRC Dashboard folder and replacing it with the Smartdashboard.jar file renamed to Dashboard.exe but it did not load when I brought up the Driver Station.

Once I have it working on the Classmate, we are using C++, the Users Guide only shows java code for example. How would I use it in C++?

I tried:
Code:

class IterativeDemo : public IterativeRobot
{
        SmartDashboard *dash;

public:
        IterativeDemo(void)        {
                dash = new SmartDashboard();
            }


        void DisabledInit(void) {
                dash->init();
              }

        void DisabledPeriodic(void)  {
                        dash->log(ElevatorCommand,"Elevator Command");
            }

but I got this error about the first declaration: "C:/WindRiver/workspace/Team2992_2011_Code_4/IterativeDemo.cpp:254: error: no matching function for call to `SmartDashboard::SmartDashboard()'"

so I need help getting it working codewise too. For the SmartDashboard folks, a quick "Getting Started" guide with the assumption that we have never changed dashboards before would be very valuable.

demosthenes2k8 30-01-2011 12:38

Re: Need SmartDashboard Help
 
Aah, I see your problem.
You never have to actually create a SmartDashboard pointer. Instead, what you have to do is
Code:

SmartDashboard::init();
Then you log with
Code:

SmartDashboard::Log(value,"name");

sircedric4 30-01-2011 12:44

Re: Need SmartDashboard Help
 
Quote:

Originally Posted by demosthenes2k8 (Post 1011668)
Aah, I see your problem.
You never have to actually create a SmartDashboard pointer. Instead, what you have to do is
Code:

SmartDashboard::init();
Then you log with
Code:

SmartDashboard::Log(value,"name");

Sweet, thanks. I still can't understand when you are supposed to use pointer and when you are not. Nothing is consistent and so it seems impossible to get the hang of C++ coding by example.

Do you know how to setup it up on the Classmate so its uses a custom dashboard instead of the default? I still need help there.

demosthenes2k8 30-01-2011 14:06

Re: Need SmartDashboard Help
 
Well, SmartDashboard is supposed to have static members - this means you don't have to have an object of the type to use them. This is denoted with the "::". A few things do this, often getInstance functions to get singleton instances of a class. I'm willing to help answer any questions you may have, so please, just ask!

One of 166's team members made a simple launcher for the SmartDashboard, and he's posting it now.
EDIT: It's here

sircedric4 31-01-2011 07:40

Re: Need SmartDashboard Help
 
Quote:

Originally Posted by demosthenes2k8 (Post 1011748)
Well, SmartDashboard is supposed to have static members - this means you don't have to have an object of the type to use them. This is denoted with the "::". A few things do this, often getInstance functions to get singleton instances of a class. I'm willing to help answer any questions you may have, so please, just ask!

One of 166's team members made a simple launcher for the SmartDashboard, and he's posting it now.
EDIT: It's here

Thanks for the link to the launcher, we'll give that a try tonight. It will be so nice to get a simple dashboard without all the clusters and formatting and other associated claptrap. We are still amateurs at our coding, so just being able to pop up the variables we are looking for is going to be so handy for debugging.

We were having to squeeze them all into the dsLCD area of the Driverstation which is a big pain.

demosthenes2k8 31-01-2011 08:55

Re: Need SmartDashboard Help
 
My team made a function (it's part of our framework) to make an interface for that dsLCD that behaves essentially exactly like printf.

Code:

/**
 * Send text to DS LCD display
 */
int DriverStationDisplay(const char* format, ...)
{
        va_list args;
        static string dash_string[6];
        static bool init=true;
        char formatted_string[DASHBOARD_BUFFER_MAX];
        if(init) {
                //Initializes it first call.
                for(int i=0;i<6;i++) {
                        dash_string[i] = "                    ";
                }
                init=false;
        }
        va_start( args, format );
        vsnprintf(formatted_string, DASHBOARD_BUFFER_MAX, format, args);
        va_end(args);
       
        //Move lines up to make room for the newline
        for(int i=5; i>=1; i--) {
                dash_string[i] = dash_string[i-1];
        }
        dash_string[0] = formatted_string;

        for(int i=0; i<6; i++) {
                dsHandleLCD->PrintfLine((DriverStationLCD::Line)i, dash_string[i].c_str());
        }
        dsHandleLCD->UpdateLCD();
        return 0;
}

Feel free to use it, or even the whole framework, from http://framework.chopshop166.com/

And you're welcome for the launcher, Ben wrote it really quickly, but it's small and works very well!


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

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