Society of Robots - Robot Forum

Software => Software => Topic started by: Tomas on March 19, 2009, 11:06:43 AM

Title: Steering robot with computer, need some tips and tricks
Post by: Tomas on March 19, 2009, 11:06:43 AM
Hi. Im currently working on my robot, and Im thinking about having it remote controlled with my computer. I've gotten the bluetooth functioning and so on, and I am now working on the remote control software. Now I have a little problem. The robot is a hobby grade rc car, which I removed the rc part and just controlled it with the axon.

Now I want to steer the car like one does in for example computer games.

Im looking to steering the car with the letters W A S D, you know the setup. Typical gaming.

The thing is that I want to, for now, use hyperterminal to steer it. I want it center steering and reduce engine power to 0% when no controls are clicked, and center steering when neither a nor d is pressed. Now here's the problem, I want the person controlling the car to be able to press both forward and steering to one side simultaniously. I've managed to get the car going forward, backward and turning, and centering\stopping when no buttons are pushed, but I havent got turning and forward\backward at the same time. I am only able to do one at a time. Now thats pretty useless...

I think Im using the wrong concept here, anyone got a good example on how this can be done? Source code, pseudocode, anything? :)

Thanks

(Will post my source code if necassary, but I really think my angle of approach is way off..)
Title: Re: Steering robot with computer, need some tips and tricks
Post by: paulstreats on March 19, 2009, 11:31:57 AM
the trouble is you can only send 1 char at a time.

a couple of solution:

1)use "Q" for forward/left - use "E" for forward and right

2)use "W" and "S" for forwards/backwards. pressing W will make the robot keep moving forwards until you recieve another command. in this case you will need to use "Q" To stop the robot completely. when "A" or "D" is pressed, 1 servo slows down and the other speeds up to make it turn. press W again to carry on forwards.(maybe make it default to either the forward/backward command if a direction isnt pressed anymore)

There are a few different solutions to the problem, just find one that works the way you want it to.
Title: Re: Steering robot with computer, need some tips and tricks
Post by: superchiku on March 19, 2009, 12:10:38 PM
aas paulstreet said....if u want to make the bot go only lft or only right then simple keep f and g fr that...f means only left g means only right...ie(rotating)
Title: Re: Steering robot with computer, need some tips and tricks
Post by: offy on March 19, 2009, 05:51:55 PM
First you need to make the strearing wheel go into ascii characters.

once you have that, you set up the pedal.
if(pedal < 100) PWM lower than if pedal is over 100 make the PWM higher. I don't know how the pedal will send out numbers of speed, but you will have to do some research on that.

Some sample code to use keys to move a robot is below (NOT MY CODE)
Code: [Select]
Defines:
// *************** Bluetooth Lights ****************
#define blue_on PORT_ON(PORTC,0)
#define yellow_on PORT_ON(PORTC,1)
#define red_on PORT_ON(PORTC,2)
#define white_on PORT_ON(PORTC,3)
void all_off(void)
{
PORT_OFF(PORTC,0);
PORT_OFF(PORTC,1);
PORT_OFF(PORTC,2);
PORT_OFF(PORTC,3);
} // end routine
// *************END BLUETOOTH Setup******************


Code (example show is for blue only , just change the letter and color for the others):

char cByte = uart0GetByte(); // get byte from UART0 on the axon
if (cByte == 'b') // if character received is b then
{
all_off(); // turn all LEDs off
blue_on; // turn only blue LED on
}

From Narobo.com (http://narobo.com/projects/electronics/bluetooth_lights/bluetooth_lights.html (http://narobo.com/projects/electronics/bluetooth_lights/bluetooth_lights.html))

For more help I am doing this same project, well close to it.

http://www.societyofrobots.com/robotforum/index.php?topic=7387.0 (http://www.societyofrobots.com/robotforum/index.php?topic=7387.0)
Title: Re: Steering robot with computer, need some tips and tricks
Post by: madchimp on March 19, 2009, 08:02:36 PM
I don't know how you would do it with a normal keyboard but some game pads like the belkin nostromo allow you to program what happens when you push a key perhaps you could program it so when you press a key it sends w then when you release the key it could send either another w or some other key to tell it to stop moving forward.
Title: Re: Steering robot with computer, need some tips and tricks
Post by: Tomas on March 20, 2009, 03:58:50 PM
So there isnt really any easy solution to my problem here. I'll try some of your workarounds, thanks :)
Title: Re: Steering robot with computer, need some tips and tricks
Post by: Resilient on March 20, 2009, 04:12:44 PM
you could cook something up using wxpython or pygame pretty quickly.
Title: Re: Steering robot with computer, need some tips and tricks
Post by: zozie on March 21, 2009, 04:51:32 PM
IF you can give us some more details on your setup, meaning servo controller and compiler you're using I'm sure we'll be able to help you out.
Title: Re: Steering robot with computer, need some tips and tricks
Post by: Tomas on March 22, 2009, 01:26:59 PM
I've started now just making a simple visual basic 2008 express edition application. Easy to create gui and easy to send data over bluetooth(I hope, I havent tested the function yet but I will tomorrow).

But does anyone know how I can get keyboard input from two keys at the same time in this programming language? Im, for now, just creating a simple windows application, but I've only managed it to get one keyboard input, and I've tested mostly everything google would throw at me.

This is basically what I want to do for now; if I press W and A at the same time, the variable "Input" will change to WA. Anyone know how to do this?

Thanks
Title: Re: Steering robot with computer, need some tips and tricks
Post by: offy on March 23, 2009, 05:11:46 PM
Does it have to be in VB? I know how to do this in Perl I think.
Title: Re: Steering robot with computer, need some tips and tricks
Post by: paulstreats on March 23, 2009, 06:02:35 PM
can you access the serial port with Perl?

 Ive used it for database traversal and manipulation but i didnt think its powers extended so far. Nor did I think you could key capture with it.

Maybe I should look into Perl a bit more rather than just use what I need (I really like the scalar variable system in Perl it takes the difficulty out of basic type management)
Title: Re: Steering robot with computer, need some tips and tricks
Post by: offy on March 27, 2009, 06:55:07 PM
Perl can capture keys, and I am 90% sure it can connect to a serial port.
Title: Re: Steering robot with computer, need some tips and tricks
Post by: GearMotion on March 28, 2009, 04:16:42 PM
Perl can capture keys, and I am 90% sure it can connect to a serial port.

Here is an example of Perl and Arduino:

http://www.windmeadow.com/node/38 (http://www.windmeadow.com/node/38)
Title: Re: Steering robot with computer, need some tips and tricks
Post by: Tomas on March 29, 2009, 02:42:09 PM
Thanks for the help guys, but I've figured out most of it in visual basic. I'll probably post all my source code for my project here later when its all finished.