Go to Post So I usually end up looking pensive or confused. :) - Karthik [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 24-03-2010, 13:05
Zme Zme is offline
Registered User
FRC #2619
 
Join Date: Jan 2009
Location: Michigan
Posts: 83
Zme is on a distinguished road
command line input...

This is going to sound very very crazy but...

Is there a way for a text input to be taken into the robot from the DS and have it function like a command prompt of sorts, ie. we have a function called runmotorx that takes in a float so we type in runmotorx (float value) and it takes it in and executes it.

is something like this done with reasonable ease? hopefully with out 100's of if statements.

any ideas on how to do this?
Reply With Quote
  #2   Spotlight this post!  
Unread 24-03-2010, 15:40
byteit101's Avatar
byteit101 byteit101 is offline
WPILib maintainer (WPI)
AKA: Patrick Plenefisch
no team (The Cat Attack (Formerly))
Team Role: Programmer
 
Join Date: Jan 2009
Rookie Year: 2009
Location: Worcester
Posts: 699
byteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of light
Re: command line input...

can it be done? yes
is it competition legal? most likely not
what would you need to do? lots

you would need to manage a socket connection, and listen for incoming data, once you heard the enter key, the proceed to a switch or if's which would get the first word, and call that function (optional), then process the rest of the input and do the function. why you would want this (aside from the coolness factor) is beyond me. unless you have a expert typist, i would not want to control a robot like this

this would definitely go in the summer project bin
__________________
Bubble Wrap: programmers rewards
Watchdog.Kill();
printf("Watchdog is Dead, Celebrate!");
How to make a self aware robot: while (∞) cout<<(sqrt(-∞)/-0);
Previously FRC 451 (The Cat Attack)
Now part of the class of 2016 at WPI & helping on WPILib

Last edited by byteit101 : 24-03-2010 at 15:40. Reason: typo
Reply With Quote
  #3   Spotlight this post!  
Unread 24-03-2010, 15:50
Zme Zme is offline
Registered User
FRC #2619
 
Join Date: Jan 2009
Location: Michigan
Posts: 83
Zme is on a distinguished road
Re: command line input...

i was more thinking as a debugging tool, think about it, instead of having to remap buttons to do certain functions especially for debugging you could just type in the command and away you go,

the hangup on me just going off and playing is i have no idea how to evaluate a text input without large amounts of if statements which i was hoping to avoid,

as for it being legal, if it was in the bandwidth for the dashboard wouldn't it fall in under the rule of being able to modify that code?
Reply With Quote
  #4   Spotlight this post!  
Unread 24-03-2010, 17:59
mikets's Avatar
mikets mikets is offline
Software Engineer
FRC #0492 (Titan Robotics)
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2008
Location: Bellevue, WA
Posts: 671
mikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of light
Re: command line input...

If it is for debugging, why do you need to enter it through the DS? I was planning to develop an interactive debugger through the debug console (i.e. give you a prompt so that you can enter some debugger commands to the robot to do things such as turning on tracing, changing PID constants without recompiling code, dump some important states on demand etc.). But I do not have time to do it this season. So may be a summer project... The only difficult part was to figure out how I can prevent the input go into the cRIO kernel debugger instead of my interactive debugger.
__________________
Reply With Quote
  #5   Spotlight this post!  
Unread 24-03-2010, 18:54
Bongle's Avatar
Bongle Bongle is offline
Registered User
FRC #2702 (REBotics)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2002
Location: Waterloo
Posts: 1,069
Bongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond repute
Send a message via MSN to Bongle
Re: command line input...

You could probably bypass the whole socket/command-line thing and have it periodically check the robot's local storage for a text file with a certain name.

Something like
Code:
while(true)
{
  // not shown: feeding watchdog or disabling it
  ifstream in;
  in.open("commands.txt");
  while(!in.fail() && !in.eof) // if we managed to open the file, and it has contents...
  {
    int motorChannel;
    float motorPower;
    in>>motorChannel; // loads the channel we want to output on
    in>>motorPower; // loads how fast we want to run the output
    PWM pwm(motorChannel); // declares an interface to the channel
    pwm.Set(motorPower); // outputs the desired amount
    Wait(5.0);  // lets it run for awhile
    pwm.Set(0.0); // turns the motor off
  }

  Wait(5.0); // don't constantly check the storage device.
}
You could then just FTP the commands.txt file to your robot whenever you wanted to run something.

The commands.txt file would just look like <motor channel> <motor power>. i.e.
Code:
4 0.5
4 -0.5
3 1.0
3 0.5
3 0.25
3 0.0
Reply With Quote
  #6   Spotlight this post!  
Unread 25-03-2010, 10:21
Zme Zme is offline
Registered User
FRC #2619
 
Join Date: Jan 2009
Location: Michigan
Posts: 83
Zme is on a distinguished road
Re: command line input...

the reason for not using a command text file is that it requires a specified format, and order for the inputs, if any functions are added then the function that needs to read in the text file will also have to be changed, and it will always run everything in it, as for the input not having to be on the DS, no it doesn't have to be but i figured that since it already is connected to the robot, it couldn't hurt to use it over another laptop, but in the long run i don't think it matters
Reply With Quote
  #7   Spotlight this post!  
Unread 25-03-2010, 10:39
gvarndell's Avatar
gvarndell gvarndell is offline
Software Engineer
AKA: Addi's and Georgie's Dad
FRC #1629 (GaCo)
Team Role: Parent
 
Join Date: Jan 2009
Rookie Year: 2008
Location: Grantsville, Maryland
Posts: 350
gvarndell has a reputation beyond reputegvarndell has a reputation beyond reputegvarndell has a reputation beyond reputegvarndell has a reputation beyond reputegvarndell has a reputation beyond reputegvarndell has a reputation beyond reputegvarndell has a reputation beyond reputegvarndell has a reputation beyond reputegvarndell has a reputation beyond reputegvarndell has a reputation beyond reputegvarndell has a reputation beyond repute
Re: command line input...

Quote:
Originally Posted by Zme View Post
This is going to sound very very crazy but...

Is there a way for a text input to be taken into the robot from the DS and have it function like a command prompt of sorts, ie. we have a function called runmotorx that takes in a float so we type in runmotorx (float value) and it takes it in and executes it.

is something like this done with reasonable ease? hopefully with out 100's of if statements.

any ideas on how to do this?
vxWorks has a facility that allows the execution of commands from a text file as if it were a script.
What you can do with it is execute the same commands you would execute at the vxWorks shell prompt -- no more.
The text file(s) need to be in a file system -- FTP them.
It is not junior programmer stuff though and the interpreter doesn't know how to parse floating point arguments :-(.
Search through Workbench Help for "shell commands" and "ptyDevCreate'.
Unless you are very good *and* willing to work very hard, you probably won't be able to utilize it this year.
Consider making it an off season project.

I can help you with it -- I have example C code I can share.
If you want it, send me an email gvarndell@hotmail.com
__________________
Robots never, ever, ever, ever break -- The Robot Repairman (Backyardigans)

Last edited by gvarndell : 25-03-2010 at 11:26. Reason: clarify, offer real help...
Reply With Quote
  #8   Spotlight this post!  
Unread 25-03-2010, 11:54
Zme Zme is offline
Registered User
FRC #2619
 
Join Date: Jan 2009
Location: Michigan
Posts: 83
Zme is on a distinguished road
Re: command line input...

willing to work hard check
very good, not so much,

Thanks for the help
Reply With Quote
  #9   Spotlight this post!  
Unread 25-03-2010, 22:10
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,082
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: command line input...

I've got a web server running on our robot, allows us to change values and stuff like that. No text input at the moment, but doesn't mean you can't extend it to allow it. *Extremely* useful for debugging.

http://code.google.com/p/webdma/
__________________
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
  #10   Spotlight this post!  
Unread 25-03-2010, 23:26
Joe Hershberger Joe Hershberger is offline
National Instruments
AKA: jhersh
FRC #2468 (Appreciate)
Team Role: Mentor
 
Join Date: Nov 2005
Rookie Year: 1997
Location: Austin, TX
Posts: 148
Joe Hershberger is a name known to allJoe Hershberger is a name known to allJoe Hershberger is a name known to allJoe Hershberger is a name known to allJoe Hershberger is a name known to allJoe Hershberger is a name known to all
Re: command line input...

Surely you are aware of the NetConsole application... it is a C interpreter that allows you to call C entry-points directly. It is not competition legal.

You can also use the dashboard video tcp connection, but that will require you defining your own set of commands (your many if statements). This is competition legal, but more work.
Reply With Quote
  #11   Spotlight this post!  
Unread 25-03-2010, 23:39
gvarndell's Avatar
gvarndell gvarndell is offline
Software Engineer
AKA: Addi's and Georgie's Dad
FRC #1629 (GaCo)
Team Role: Parent
 
Join Date: Jan 2009
Rookie Year: 2008
Location: Grantsville, Maryland
Posts: 350
gvarndell has a reputation beyond reputegvarndell has a reputation beyond reputegvarndell has a reputation beyond reputegvarndell has a reputation beyond reputegvarndell has a reputation beyond reputegvarndell has a reputation beyond reputegvarndell has a reputation beyond reputegvarndell has a reputation beyond reputegvarndell has a reputation beyond reputegvarndell has a reputation beyond reputegvarndell has a reputation beyond repute
Re: command line input...

Quote:
Originally Posted by Joe Hershberger View Post
the NetConsole application... it is a C interpreter that allows you to call C entry-points directly.
I get so little time on a robot.
Does it parse floating point arguments?

It's just a shell with re-wired stdin and stdout, right?
__________________
Robots never, ever, ever, ever break -- The Robot Repairman (Backyardigans)
Reply With Quote
  #12   Spotlight this post!  
Unread 26-03-2010, 00:50
mikets's Avatar
mikets mikets is offline
Software Engineer
FRC #0492 (Titan Robotics)
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2008
Location: Bellevue, WA
Posts: 671
mikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of light
Re: command line input...

Quote:
Originally Posted by Joe Hershberger View Post
Surely you are aware of the NetConsole application... it is a C interpreter that allows you to call C entry-points directly. It is not competition legal.
You can also use the dashboard video tcp connection, but that will require you defining your own set of commands (your many if statements). This is competition legal, but more work.
Ahh, does it mean I could have a Debugger object defined in the Robot code with the method "PromptDebuggerCommand()" that will interpret my own debugger commands. So I can invoke the method in the NetConsole or debugger console? How? It could be very handy when debugging code.
__________________
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
Dashboard command line? Phoenix.14 Programming 3 13-03-2010 10:13
command listfor c??? jfrank Programming 12 22-01-2008 20:16
assembly command tseres Programming 3 18-01-2008 08:13
2.5 is alive !!!! (input ! .. more input ! ) Lloyd Burns Programming 2 14-01-2003 19:15
New Line Input Parsing Trashed20 Website Design/Showcase 6 30-09-2002 10:46


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

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