View Single Post
  #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