View: 343|Reply: 2

Robot Kit PiCar-B - Software Queries

[Copy link]

1

Threads

3

Posts

13

Credits

Newbie

Rank: 1

Credits
13
Post time 2019-2-11 22:12:08 | Show all posts |Read mode
I have assembled this robot kit but it is not behaving as expected when I use the bundled software. For example, the controls for moving the camera left and right and up and down cause the opposite to happen, i.e. the left button causes the camera to move right.

I have looked at the mechanical setup and it seems to be okay. Note: I could still be wrong about this.

I started looking at the bundled software and a few things don't make sense to me. The servo motors in this kit are these

http://www.ee.ic.ac.uk/pcheung/t ... /sg90_datasheet.pdf

so a 1msec pulse = full left, 1.5msec = middle and 2.0msec = full right, based on a 50Hz period.

The first thing is that the PWM frequency which is set in the file turn.py is set to 60 which does not look to be correct?

Also, the logic of the turn left and turn right commands as shown below looks to be the opposite of what I would expect. To turn further left, it looks like the duration of the pulse is increased up to a maximum value. Based on the spec above, I would be expecting this to be the other way around?

        elif 'l_le' in data:                   #Camera look left
            if hoz_mid< look_left_max:
                hoz_mid+=turn_speed
            turn.ultra_turn(hoz_mid)
            tcpCliSock.send('7'.encode())

        elif 'l_ri' in data:                   #Camera look right
            if hoz_mid> look_right_max:
                hoz_mid-=turn_speed
            turn.ultra_turn(hoz_mid)
            tcpCliSock.send('8'.encode())

Reply

Use magic Report

0

Threads

5

Posts

39

Credits

Newbie

Rank: 1

Credits
39
Post time 2019-2-12 15:35:31 | Show all posts
Hello,
if the commands are opposite of what you expect, you can simply replace 'l_le' and 'l_ri' as below
        elif 'l_ri' in data:                   #Camera look left
            if hoz_mid< look_left_max:
                hoz_mid+=turn_speed
            turn.ultra_turn(hoz_mid)
            tcpCliSock.send('7'.encode())

        elif 'l_le' in data:                   #Camera look right
            if hoz_mid> look_right_max:
                hoz_mid-=turn_speed
            turn.ultra_turn(hoz_mid)
            tcpCliSock.send('8'.encode())


you can change PWM frequency to 50, but remenber to reset the default PWM so the camera would look forward

thanks
Reply

Use magic Report

1

Threads

5

Posts

47

Credits

Newbie

Rank: 1

Credits
47
Post time 2019-4-5 06:45:57 | Show all posts
Edited by Dr Pelforth at 2019-4-5 10:39 PM

Hi
Same for me, every single command get the reverse response from the 4 motors. Rear wheels, front wheels, head up/down, head right-left. First I switched the constant values in the motor.py file:
Dir_forward = 1
Dir_backward = 0
Reply

Use magic Report

You have to log in before you can reply Login | Sign Up

Points Rules