Re: Action to manually drive the robot
You can just use ArActionKeydrive, it already does exactly these
things... ArKeyHandler does the keyboard input too, if you want to
just use that straight up or see how to do it... basically getc is a
blocking command or waits for enter or something along those
lines... so you have to do some termios stuff to set it up right in
Linux and check 'kbhit' in Windows.
You should upgrae to the latest version for this... I only put this in
in release like 1.0.2 or so.
Matt LaFary
ActivMedia Robotics
On Thu, Mar 21, 2002 at 12:23:50PM -0500, Laurel D. Riek wrote:
> Hi,
>
> So, I wrote an action to manually drive the robot via the
> keyboard, using getchar. However,
> I noticed 1) there was a lot of lag, 2) my actions were not always
> immediately accepted by the program, and 3) the entire system would often
> lock up
> Should this be a user task instead of an action? Is there
> something I should use instead of getchar?
>
> Thanks,
> Laurel
2 Re: Keyboard input.
If you set this up right you shouldn't have any problems... check out
the demo that comes with the latest ARIA, it'll control gripper,
camera, everthing (one mode at once though)...
I'm taking a stab at how you're using things here... if this isn't how
you're using things then just describe how you're using them and we'll
sort it out. Since you're using a user task I gather you're calling
getKey, which you're right in saying you shouldn't mix with an
ArActionKeyDrive... The right way to do this is to give some functors
to the ArKeyHandler that is already set up by ArActionKeyDrive, or to
make a key handler and populate it with your own functors before you
addAction your keydrive action. To add functors make or use an
existing key handler like so:
ArKeyHandler *keyHandler;
if ((keyHandler = Aria::getKeyHandler()) == NULL)
{
keyHandler = new ArKeyHandler;
Aria::setKeyHandler(keyHandler);
if (myRobot != NULL)
myRobot->attachKeyHandler(keyHandler);
else
ArLog::log(ArLog::Terse, "ArMode: No robot to attach a keyHandler to");
}
keyHandler->addKeyHandler('z', someFunctor);
I have just modified the comments about getKey a little, so that if
the docs note its internal and what functions to use... I didn't make
getKeys protected because I can see cases where someone would want to
take care of the keyhandling and such themselves... but I added
comments (documentation) clarifying.
And again, if I described a method you aren't using and you are
already using this method describe in a little more detail what you're
doing and we'll sort out the trouble.
Matt LaFary
ActivMedia Robotics