Using the PROP + MOTOR + HB-25 + PS2 REMOTE.
jmbertoncelli@USA
Posts: 48
Hello All,
I try to use a PS2 RC to remote control my rover but I do not find a good way to mix the PS2 channels in order to have a smooth ride.
the PS2 Channel# 1 is :· FULL FW 0 <
128 (neutral)
> 255 FULL BWD···
the PS2 Channel# 2 is· : FULL LEFT 0<
128 CENTER
> 255 FULL RIGHT
The parallax motor·kit with the position and·HB-25 motor controllers can accept command(S) for a single device or all.·
I can set the direction (TRVL -32768 <= number <= 32767)·with a + or -·value and the speed (SMAX 0 <= speed <= 65535).
I can control both motor at once or a single motor at a time.
Now I would like to use my rover like an RC car but I have some troubles on how to mix my PS2 channels in a proportinnal way like going fwd or bwd ·at a specific speed and of course turning to the left or right proportinnaly as well.
Any ideas are welcome.
jm.
·
I try to use a PS2 RC to remote control my rover but I do not find a good way to mix the PS2 channels in order to have a smooth ride.
the PS2 Channel# 1 is :· FULL FW 0 <
128 (neutral)
> 255 FULL BWD···
the PS2 Channel# 2 is· : FULL LEFT 0<
128 CENTER
> 255 FULL RIGHT
The parallax motor·kit with the position and·HB-25 motor controllers can accept command(S) for a single device or all.·
I can set the direction (TRVL -32768 <= number <= 32767)·with a + or -·value and the speed (SMAX 0 <= speed <= 65535).
I can control both motor at once or a single motor at a time.
Now I would like to use my rover like an RC car but I have some troubles on how to mix my PS2 channels in a proportinnal way like going fwd or bwd ·at a specific speed and of course turning to the left or right proportinnaly as well.
Any ideas are welcome.
jm.
·
Comments
Also I have attached what I use, its not for the hb25 but the combine routines should work. Look at the routines motorspeed, ratio and the tables intable/outtablexx. When you call Init you specify the turn sensitivity this picks which outtable to use. MotorSpeed uses ratio to go from foward/turn speeds to left/right motor speeds. MotorSpeed also biases forward for slow senstivity i.e. uses more of the joystick forward/back for slow forward speed.
There is only two parameters that I can use SMAX and TRVL and based on the documentation SMAX should not be changed when in motion...· TRVL is a distance parameter...?·· I do not see yet how to simulate a true analogic RC...
jm.
Thinking about it, this is not enough, if you keep trvl values fairly small then you can change smax when sending the next trvl command.
Try this forward speed is 0 to 255 (back is 0 to -255)
SMAX = forward speed/7 i.e. 0-36
trvl = forward speed//7
trvl command should finish in < 100ms so you can change speed every 100ms.
at slow speeds the forward movement will jump but the average will be correct.
Post Edited (Timmoore) : 8/3/2009 7:59:25 PM GMT
jm
The simplest answer is to use SSRR and set ramp rate to 255 this almost disables the ramping. Then you may want to put damping in the RC value so it doesn't change to quick.
A more complex answer is to adjust smax and trvl together, trying to keep trvl as large as possible for the response time you want to the rc controller. e.g. if the response time is 0.1 sec then you need to keep trvl less or equal to smax/5 (5 is .5/.1)
An even more complex answer is to use SSRR, SMAX and TRVL all together, calculate the SSRR to reach SMAX in some proportional of the time taken for TRVL at SMAX speed.
I don't know where you are on your project with the PS2 Controller and HB motor driver, but when I saw this thread recently I thought I give my recent experiences. I currently have a project that I trying to control two HB25's with a wireless version of the PS2 controller from Lynxmotion. I've included a couple of programs that I created, one is a test to ensure I was communicating with the controller properly, the other is the first attempt to get control of the HB25's. The "Test" program uses 6 LED's, three each representing a HB25. Through trial I determined the maximum output from the controller when the joystick is at full travel and at mid point. I set up the program to light the LED when the joystick is at either extreme or midpoint. When I run the program I notice that when both joysticks are at midpoint, the LED's representing the upper end flash intermitently. Otherwise the program does demonstrate I have communication. When I run the "HB25" program I get individual control of each motor, however with several anomolies.
If anybody can give guidance on what is causing these "querks" I would be greatly appreciated. Good luck on your project JM.
Brian
Also in your PS2Control_test the code
is wrong, the return from ps2.get_lefty is not a float it needs converted to float before used in fmul. try ffloat
Also the == in Light is comparing a float to an integer and will not work correctly - try fmath.round to convert float to int
An additional comment - this is how I convert joystick to motor speeds without float maths
RCMid,RCMax, RCMin are middle, max and min joystick values. Just change RCmin,mid,max and motor_max to suit.
Post Edited (Timmoore) : 8/8/2009 10:05:42 PM GMT
I have the PS2 from Lynxmotion and it is working just fine with my code.· In fact my issue is related to how channels LEFT/RIGHT vs. FORWARD/BACKWARD should be mixed to provide a proportional control when changing direction.· I think that there is a formula that one could apply but I have yet to find it...·· the PS2 value returned are from 0 to 255 for both LEFT/RIGHT 0<----128---->255 and FORWARD/BACKWARD 0<----128---->255.·· 128 is the neutral·value returned when the sticks are in center positions.·· Now as I have explained before the issue is how to mix and match·with the Parallax motor kit based on the fact that their interface does not provide a direct way to translate the PS2 values(0 to 255).
I am still testing...
jm.
Thank you so much for the input. Very helpful!!
Brian