Setting duration/speed of Motors using minidriver

The brains of your robot

Setting duration/speed of Motors using minidriver

Postby pageauc » Thu Sep 11, 2014 7:40 pm

Alan

I have got my opencv python script working with the Dawn Robot camera module and can control pan/tilt to follow a face. I am trying to program a wheel to turn slightly if the pan goes past a specific point. This would allow the robot to turn and center the pan. Eg someone moving left or right past the normal pan so the robot would rotate using one wheel to keep person in view.
I would like to control the duration of the motor to make it proportional to the cumulative pan of the camera in a particular direction. Eg If the camera pans past a certain amount one wheel should move slightly to turn the robot so the camera can keep the face in the camera frame. Not sure if my programming is correct. used minidirver command to turn one wheel forward or backward depending on the pan. Waited 1.0 then send wheel a minidirver wheel stop value 0. This does not seem to work. The wheel turns for about 3 seconds and I can't figure out why. I would like to be able to send it a short duration pulse to turn the robot maybe 30-60 degrees or so at a time.
Here is a code snippet. direction variable is -1 or +1 depending on wheel direction to turn. The wheel turns in correct direction OK but runs far too long. Looked at minidriver python code but still can't figure out how to control duration. I know web interface can move robot a little bit at a time if the joystick is move a little bit. Can you help me out?
Thanks Claude ...

Here is a code snippet that I am using. right_wheel_min is set to 130.
if ( abs(Nav_LR)>3 or abs(Nav_UD)>3 ):
if Nav_LR < 0:
direction = 1
elif Nav_LR > 0:
direction = -1

miniDriver.setOutputs( left_wheel_stop, (right_wheel_min + (abs(Nav_LR))) * direction, current_pan_pos, current_tilt_pos )
time.sleep( 1.0 )
miniDriver.setOutputs( left_wheel_stop, right_wheel_stop , current_pan_pos, current_tilt_pos )
pageauc
 
Posts: 31
Joined: Tue Aug 19, 2014 2:11 pm

Re: Setting duration/speed of Motors using minidriver

Postby pageauc » Thu Sep 11, 2014 8:44 pm

Well I have had a little more luck by lowering the motor speed values. Motor duration is still about the same. Looks like I will have to control by using motor speed instead of speed/duration. If I send the wheel a very low number is turns more slowly (speed) and seems to keep the duration the same but due to the speed does not move as far. I guess this will need to be calibrated. I had to do the same thing with the face tracking pan/tilt since the image, pan/tilt and world have coordinate system differences.
One problem is that at lower speeds the robot may not be able to overcome friction to rotate, so a higher speed might sometimes be needed. Will need a feedback loop to make sure wheels are in the correct position without needless oscillations back and forth . Might need to calibrate one wheel robot rotation values to get roughly the angle I want.
It still seems eerie to see the robot wake up from motion detection, then find and track your face. Anyway having some fun.
Sorry to disturb you. BTW I will shortly edit part4 of my robot project and upload to YouTube. Will post URL when it is available for anyone who might be interested.
Claude ...
pageauc
 
Posts: 31
Joined: Tue Aug 19, 2014 2:11 pm

Re: Setting duration/speed of Motors using minidriver

Postby pageauc » Fri Sep 12, 2014 12:42 am

Here is my latest project update for the Self-Balancing Autonomous Robot project
http://youtu.be/Lc0isSkMcZA

Here is a playlist for the previous updates and the video that inspired me
https://www.youtube.com/playlist?list=PLLXJw_uJtQLYspXORG_To3sDPQ3N1BIFB
pageauc
 
Posts: 31
Joined: Tue Aug 19, 2014 2:11 pm

Re: Setting duration/speed of Motors using minidriver

Postby pageauc » Fri Sep 12, 2014 12:33 pm

BTW
I posted the current python opencv code under projects section of this forum if anyone is interested. Also there are a few mistakes. Realized the speed value range to the wheels is 256 between -128 and +128. Originally thought it was +- 256. Correct me if I am wrong. Will change the variables. Was sometimes getting python trackback invalid value errors from minidriver and that is probably why. I would still like to be able to control the wheel duration as well as the speed. Just struggling a little at this point since I am new to robotics. Any help would be appreciated.
Regards
Claude ..
pageauc
 
Posts: 31
Joined: Tue Aug 19, 2014 2:11 pm

Re: Setting duration/speed of Motors using minidriver

Postby Alan » Fri Sep 12, 2014 1:50 pm

Hi Claude,

Sorry for the delayed reply on this.

With your wheel motion, you may be falling foul of the 'dead man's switch' that is implemented on the mini driver. Basically if it doesn't recieve motion commands for about 2 seconds it will shut down the motors, to stop the robot from driving into walls if comms go down.

The recommended way to work around this is to have a control loop that constantly checks the state you want your robot to be in and then updates the motor outputs accordingly. I'd put a small delay at the end of each loop to avoid flooding the mini driver with commands. Something like

time.sleep( 0.01 )

Regards

Alan
Alan
Site Admin
 
Posts: 311
Joined: Fri Jun 14, 2013 10:09 am


Return to Software

Who is online

Users browsing this forum: No registered users and 1 guest