Go to Post Success is the indescribable feeling you get when you see something you worked so hard on in front of thousands of people. - SlamminSammy [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 30-01-2009, 15:41
dnrobotics11 dnrobotics11 is offline
Registered User
FRC #2589
 
Join Date: Mar 2008
Location: Massachusetts
Posts: 55
dnrobotics11 is an unknown quantity at this point
C++ Functions

Is there a function in the WindRiver language that allows me to take the value of the joystick (speed of motor) and make it into a variable so that you can compare how fast you are intending to go based on joystick location and compare it to the actual speed?
Reply With Quote
  #2   Spotlight this post!  
Unread 30-01-2009, 16:38
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,112
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: C++ Functions

There's not a WPI library function for what you want, but there is a simple feature of the C language called an "assignment". It is implemented using the equals sign = character.
Code:
  variable = retrieve_value();
This takes the value returned by the retrieve_value() function and assigns it to the variable named variable. In order to make it work properly, the variable and the function must have the same type. (For joystick axis values, I think that type is float.)

If you didn't already know this, you should probably find and follow a basic C/C++ programming tutorial. Finding and following a knowledgeable mentor would be a good idea as well.

[edit] I'm focusing on LabVIEW this season, so I'm not confident in my ability to give correct examples using the C++ classes to an insufficiently experienced programmer. Would someone else please answer specific questions about reading Joystick data? [/edit]

Last edited by Alan Anderson : 30-01-2009 at 19:50. Reason: requesting C++ users to help out
Reply With Quote
  #3   Spotlight this post!  
Unread 30-01-2009, 19:05
dnrobotics11 dnrobotics11 is offline
Registered User
FRC #2589
 
Join Date: Mar 2008
Location: Massachusetts
Posts: 55
dnrobotics11 is an unknown quantity at this point
Re: C++ Functions

Thank you very much. So if I use the float variable of the retrieve_value() function I can get the joystick speed?
Reply With Quote
  #4   Spotlight this post!  
Unread 30-01-2009, 20:06
demosthenes2k8's Avatar
demosthenes2k8 demosthenes2k8 is offline
Graduated but not gone
AKA: Matt Soucy
FRC #0166 (Chop Shop 166)
Team Role: Mentor
 
Join Date: Jan 2009
Rookie Year: 2007
Location: Merrimack, NH
Posts: 589
demosthenes2k8 is a splendid one to beholddemosthenes2k8 is a splendid one to beholddemosthenes2k8 is a splendid one to beholddemosthenes2k8 is a splendid one to beholddemosthenes2k8 is a splendid one to beholddemosthenes2k8 is a splendid one to beholddemosthenes2k8 is a splendid one to beholddemosthenes2k8 is a splendid one to behold
Send a message via AIM to demosthenes2k8 Send a message via Yahoo to demosthenes2k8
Re: C++ Functions

No, I don't believe that there's a function called retrieve_value() function. Try looking at WPILib and seeing what functions there are for the joystick class.
Reply With Quote
  #5   Spotlight this post!  
Unread 31-01-2009, 01:40
virtuald's Avatar
virtuald virtuald is offline
RobotPy Guy
AKA: Dustin Spicuzza
FRC #1418 (), FRC #1973, FRC #4796, FRC #6367 ()
Team Role: Mentor
 
Join Date: Dec 2008
Rookie Year: 2003
Location: Boston, MA
Posts: 1,039
virtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant future
Re: C++ Functions

If you're using the SimpleRobot demo, then you would use the instance of the Joystick class to retrieve the value of the Joystick.

Code:
// assuming that there is an instance of the Joystick class called 'stick' in the current scope
float some_X = stick.GetX();
float some_Y = stick.GetY();
However, if you glance at how the joystick values are translated to motor speed (see RobotDrive.cpp), its probably not the stick values you want to look at, you'll want to look at the motor values -- which is harder if you use their RobotDrive class, which doesn't allow you to easily access the motor values unless you create the speed controller classes outside the RobotDrive class and pass it in through the constructor of RobotDrive. For this reason, we chose to write our own RobotDrive-like class.

Reading the WPILib source code is the best way to understand how things work underneath.
__________________
Maintainer of RobotPy - Python for FRC
Creator of pyfrc (Robot Simulator + utilities for Python) and pynetworktables/pynetworktables2js (NetworkTables for Python & Javascript)

2017 Season: Teams #1973, #4796, #6369
Team #1418 (remote mentor): Newton Quarterfinalists, 2016 Chesapeake District Champion, 2x Innovation in Control award, 2x district event winner
Team #1418: 2015 DC Regional Innovation In Control Award, #2 seed; 2014 VA Industrial Design Award; 2014 Finalists in DC & VA
Team #2423: 2012 & 2013 Boston Regional Innovation in Control Award


Resources: FIRSTWiki (relaunched!) | My Software Stuff
Reply With Quote
  #6   Spotlight this post!  
Unread 31-01-2009, 13:45
dnrobotics11 dnrobotics11 is offline
Registered User
FRC #2589
 
Join Date: Mar 2008
Location: Massachusetts
Posts: 55
dnrobotics11 is an unknown quantity at this point
Re: C++ Functions

Okay I'll try that. Thank you very much.
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
Accelerometer functions RJohnston Programming 3 03-05-2008 11:23
Camera functions. winners Programming 1 21-01-2006 19:42
Auton + Functions ten3brousone Programming 0 27-02-2005 20:11
Cordic functions... Zalumaskov Programming 1 13-02-2005 00:58
subs/functions maDGag Programming 2 16-02-2003 23:27


All times are GMT -5. The time now is 02:39.

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