Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   C/C++ (http://www.chiefdelphi.com/forums/forumdisplay.php?f=183)
-   -   command line input... (http://www.chiefdelphi.com/forums/showthread.php?t=84619)

Zme 24-03-2010 13:05

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?

byteit101 24-03-2010 15:40

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

Zme 24-03-2010 15:50

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?

mikets 24-03-2010 17:59

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.

Bongle 24-03-2010 18:54

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


Zme 25-03-2010 10:21

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

gvarndell 25-03-2010 10:39

Re: command line input...
 
Quote:

Originally Posted by Zme (Post 942536)
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

Zme 25-03-2010 11:54

Re: command line input...
 
willing to work hard check
very good, not so much,

Thanks for the help

virtuald 25-03-2010 22:10

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/

Joe Hershberger 25-03-2010 23:26

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.

gvarndell 25-03-2010 23:39

Re: command line input...
 
Quote:

Originally Posted by Joe Hershberger (Post 943296)
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?

mikets 26-03-2010 00:50

Re: command line input...
 
Quote:

Originally Posted by Joe Hershberger (Post 943296)
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.


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

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