Go to Post it's shadows and fog and stormy skies and a reminder that things are rarely black and white but instead, the places in between. - MissInformation [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 19-07-2009, 11:49
Dave Scheck's Avatar
Dave Scheck Dave Scheck is offline
Registered User
FRC #0111 (WildStang)
Team Role: Engineer
 
Join Date: Feb 2003
Rookie Year: 2002
Location: Arlington Heights, IL
Posts: 574
Dave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond repute
C++ Dashboard Usage

After some recent questions regarding getting a dashboard connected to C++ code, I decided to share the class that we used this year to interface to our dashboard and the way we used it. Our version had more than 100 data members, so the attached example is much more simplified, but it should give a good starting point for people looking to use the dashboard.

The attached zip file contains the following
WsRobot.h - A very simple robot definition that includes a WsDashboard object

WsRobot.cpp - The implementation of the robot. It has a very simple, rather useless TeleopPeriodic function. Values are read from Joystick 1 and internal variables based on those values are then written to the dashboard object.

WsDashboard.h - Contains a class that abstracts the WPILib Dashboard class. Data type classes are also defined here.

WsDashboard.cpp - The implementation of the dashboard class. It defines what pieces of data are to be sent to the dashboard as well as what data type each element is.

In the Dashboard directory, the DashboardMain.vi file is a stripped down version of the dashboard that we used this year, which was based on the dashboard example provided with Labview. I included a few supporting VI files that came from the example that handle the communication protocols.

Focusing on the C++ side first, the code should be fairly straight forward, but here are a few general comments.

We chose this approach because early on when we were experimenting we found that we were constantly adding new data elements. We wanted to make this data addition as easy as possible, so we designed the classes to be as flexible as possible.

We found that we only needed 3 data types (float, bool, UINT32). If a different data type is needed (must be supported by WPILib Dashboard class), the following should be done:
- Add it to the DashboardDataType enum
- Create a new class based on DashboardDataBase to handle the setting/getting/resetting of the data.
- Add a mapping in WsDashboard::update()

When adding a new parameter, the following is done
- Add an index to the DashboardIndexT enum
- Instantiate the index with the correct data type in WsDashboard::WsDashboard
- Set the value where needed (in our case WsRobot.cpp)

On the LabView side of things, we simply took the example and stripped out their processing and added our own. The key to the whole process is the packet parsing which is done via the data structure on the far left. The order that the data is packed on the C++ side must match the order that the elements are in the LabView data container. Once the data packet format is set up, it's as easy as adding the necessary processing on the right side of the diagram. You can make it as simple or complex as you'd like.

Hopefully this will give programmers that are intimidated by the dashboard a good point to jump in from.

As a disclaimer, the code in the zip file is copied from the production code for our 2009 robot, but has been stripped down. Same goes for the LabView diagram. While I have compiled the C++ code, I haven't tested it on a robot. If you come across problems let me know and I can put out an update.

If you have questions, I'll do what I can to answer them.

Enjoy.
Attached Files
File Type: zip DashboardExample.zip (105.9 KB, 92 views)
Reply With Quote
  #2   Spotlight this post!  
Unread 19-07-2009, 12:32
Dave Scheck's Avatar
Dave Scheck Dave Scheck is offline
Registered User
FRC #0111 (WildStang)
Team Role: Engineer
 
Join Date: Feb 2003
Rookie Year: 2002
Location: Arlington Heights, IL
Posts: 574
Dave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond repute
Re: C++ Dashboard Usage

I realized that there may be people here that are interested in seeing the labview side of things that don't have immediate access to it. I've attached a screenshot of both the front and back end diagrams.
Attached Thumbnails
Click image for larger version

Name:	FrontPanel.png
Views:	78
Size:	24.8 KB
ID:	8044  Click image for larger version

Name:	DashboardBackend.png
Views:	81
Size:	57.9 KB
ID:	8045  
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

Similar Threads
Thread Thread Starter Forum Replies Last Post
RS-385 usage jgannon Motors 5 20-02-2008 19:40
Electromagent usage robogeek753 Rules/Strategy 7 05-01-2008 22:36
Camera Usage Jaime65 Technical Discussion 5 02-02-2007 21:39
Labview Dashboard and updated IFI dashboard spec Joe Ross LabView and Data Acquisition 1 04-04-2006 02:04
STAMP Usage Raven_Writer Programming 3 12-08-2003 08:35


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

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