Shop OBEX P1 Docs P2 Docs Learn Events
HM55 — Parallax Forums

HM55

GaboGabo Posts: 10
edited 2008-03-05 22:37 in Learn with BlocklyProp
·HI, I`m using the Compass HM55 in a project, well I need some help and tips to·how to use the HM55. The thing that·I·need to acomplish·is that by the HM55 make a Boebot travel across·a Billiard`s Table. Any suggestions???·

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2007-09-28 01:16
    Have you gotten the HM55 to work? Can you get compass readings? There are plenty of sample programs and calibration programs ... look on the Parallax webstore page for the HM55 for the links to the documentation.

    The general idea for any navigation problem is that you begin in a stopped state, read the compass heading, compare that to the direction you want. If the BoeBot is pointing too far to the right, you move the BoeBot slightly to the left by moving the right wheel forward very briefly. If the BoeBot is pointing too far to the left, you move the BoeBot slightly to the right by moving the left wheel forward very briefly. You then check your position again. If it's correct, you move the BoeBot forward a short distance by moving both wheels forward at the same speed for a short period of time, then you start the cycle all over again.

    It's possible to make this whole process smoother, but start with what I've described since it's easier to program this way.

    You will need to experiment with the amount of time for each movement and the speed (pulse width) for each wheel servo to find what works best for you.
  • GaboGabo Posts: 10
    edited 2007-10-09 16:45
    Compass:

    GOSUB Compass_Get_Axes ' Get x, and y values

    angle = x ATN -y ' Convert x and y to brads
    angle = angle */ 361 ' Convert brads to degrees

    DEBUG HOME, "x-axis N(-S) = ",SDEC x, ' Display axes and degrees
    CLREOL, CR, "y-axis W(-E) = ",
    SDEC y, CLREOL, CR, CR, "angle = ",
    DEC angle, " degrees", CLREOL

    PAUSE 150 ' Debug delay for slower PCs
    RETURN

    How can I modify o compare the values that I obtain, with ones that I want, and make the boebot go to that coordinate or value???
  • Mike GreenMike Green Posts: 23,101
    edited 2007-10-09 17:23
    Let's say you want the BoeBot to go Northeast (compass angle 45 degrees). You take a reading and get an angle. Which way do you go? If the angle is less than 45 degrees, you want to turn right. If the angle is greater than 45 degrees, you want to turn left. Or do you? Basically, you subtract the two angles. If the result is less than zero, you add 360. That gives you the number of degrees to turn. If that is greater than 180 degrees, you can turn less in the opposite direction if you turn (180 - amount).

    Because you can't really make the BoeBot turn a specific number of degrees, you have to do this step-wise. If the number of degrees to turn is more than say 30 degrees, make one servo go in one direction and the other go in the opposite direction for a short period of time that by experimentation seems to turn the BoeBot maybe 20 degrees, then repeat the compass measurement and try again. If the amount to turn is more than say 10 degrees, turn the BoeBot at a slower speed and shorter time that maybe turns the BoeBot 5 degrees and repeat the measurement/movement cycle. If the amount to turn drops to less than 10 degrees, quit. You're not likely to do a lot better with the HB55. 10 degrees may even be too fine a measurement. Once the BoeBot has turned in approximately the right direction, you can drive it forward a short distance, then recheck the compass heading.

    The compass and timing of linear movements (forward and backward) are not accurate enough for "dead reckoning" navigation. There's also slippage of the wheels on the surface. You'll need some other source of information. You may be able to use other sensors (PING ultrasonic distance sensor or IR distance sensing) to look for walls or other expected objects and compare some kind of internal map against what the sensors find.
  • labheshrlabheshr Posts: 10
    edited 2008-03-05 22:37
    Hi ..

    Have any of u guys had probs with compass stability. For me the HM55 changes values very rapidly.
    The interference avoidance code give in HM55B prevents any measurements being taken by the boebot dynamically. It just finds the angle boebot is currently facing and doesnt change with change in boebot's position.

    Also I am trying to make the robot move from one set of co-ordinates to the other. Can anyone hint on how to figure out the angles and relate them to co-ordinates?

    Here is the subroutine I wrote:

    Align:

    'IF(angle >180) THEN
    'angle = angle - 180
    'ENDIF

    DO WHILE(angle > 47 OR angle < 42)
    IF (180-(angle + 45) < 0) THEN

    PULSOUT 13, 650
    PULSOUT 12, 650

    GOSUB Compass

    ELSEIF (angle >=40 AND angle <=50 ) THEN

    FOR cntr = 1 TO 122

    PULSOUT 13,850
    PULSOUT 12,650

    NEXT

    ELSE

    PULSOUT 13, 850
    PULSOUT 12, 850

    GOSUB Compass

    ENDIF

    This code makes the robot move straight wenever it approaches 45 degs. The idea is to make the robot move say from points (0,0) to (1,1), for this , as per Mike's idea, i need to make it move 45 degs and go straight. But how do i corelate angles to destination (x,y) coordinates? Any comments Mike and Gabo?
Sign In or Register to comment.