Girl
Posts: 8
Joined: Wed Jun 27, 2018 1:26 pm

Remote control buggy project

Fri Jul 06, 2018 12:49 pm

I am trying to finish the remote control buggy project from the raspberryPi website.

The robot has a RPi2. The remote control is a RPi3B+.

On the robot, the command: sudo pigpiod does not work. I get the error:

"can't lock /var/run/pigpiod.pid, can't initiliase pigpio library".

I did a 'sudo upgrade' on the Pi to make sure I had the last version.

I tried the command on the remote control (the RPI3B+) and got the same error.

I think this error is the source of many other errors, but if not, here are the other errors. In Python, on the remote control (RPI3B+), I have the following:

Code: Select all

from gpiozero import Robot, Button
from gpiozero.pins.pigpio import PiGPIOFactory

factory = PiGPIOFactory(host="192.168.1.124")
robot = Robot(left=(factory.pin(7), factory.pin(8)), right=(factory.pin(9), factory.pin(10)))
this is the error when I run the script:
Traceback (most recent call last):
File "/home/pi/remotelycontrorobot.py", line 5, in <module>
robot = Robot(left=(factory.pin(7), factory.pin(8)), right=(factory.pin(9), factory.pin(10)))
File "/usr/lib/python3/dist-packages/gpiozero/devices.py", line 95, in __call__
self = super(GPIOMeta, cls).__call__(*args, **kwargs)
File "/usr/lib/python3/dist-packages/gpiozero/boards.py", line 1186, in __init__
left_motor=Motor(*left, pin_factory=pin_factory),
File "/usr/lib/python3/dist-packages/gpiozero/devices.py", line 95, in __call__
self = super(GPIOMeta, cls).__call__(*args, **kwargs)
File "/usr/lib/python3/dist-packages/gpiozero/output_devices.py", line 858, in __init__
forward_device=PinClass(forward, pin_factory=pin_factory),
File "/usr/lib/python3/dist-packages/gpiozero/devices.py", line 95, in __call__
self = super(GPIOMeta, cls).__call__(*args, **kwargs)
File "/usr/lib/python3/dist-packages/gpiozero/output_devices.py", line 327, in __init__
pin, active_high, initial_value=None, pin_factory=pin_factory
File "/usr/lib/python3/dist-packages/gpiozero/output_devices.py", line 47, in __init__
super(OutputDevice, self).__init__(pin, pin_factory=pin_factory)
File "/usr/lib/python3/dist-packages/gpiozero/mixins.py", line 69, in __init__
super(SourceMixin, self).__init__(*args, **kwargs)
File "/usr/lib/python3/dist-packages/gpiozero/devices.py", line 375, in __init__
pin = self.pin_factory.pin(pin)
File "/usr/lib/python3/dist-packages/gpiozero/pins/pi.py", line 69, in pin
n = self._to_gpio(spec)
File "/usr/lib/python3/dist-packages/gpiozero/pins/pi.py", line 81, in _to_gpio
if not 0 <= spec < 54:
TypeError: unorderable types: int() <= PiGPIOPin()
thank you

Zoe

gkaiseril
Posts: 446
Joined: Mon Aug 08, 2016 9:27 pm
Location: Chicago, IL

Re: Remote control buggy project

Fri Jul 06, 2018 3:25 pm

Have you checked to see if gpiozero library has been installed?

You may have to reinstall it.

gpiozero documentation

Girl
Posts: 8
Joined: Wed Jun 27, 2018 1:26 pm

Re: Remote control buggy project

Fri Jul 06, 2018 6:11 pm

Hello,
I installed the gpiozero library. The problem is still there. I still get the error "can't lock /var/run/pigpiod.pid, can not initiliase pigpio library".

Is there anything else I could try ??

Thank you

Zoe

User avatar
bensimmo
Posts: 3227
Joined: Sun Dec 28, 2014 3:02 pm
Location: East Yorkshire

Re: Remote control buggy project

Fri Jul 06, 2018 8:09 pm

I wonder if pigpio is already running, it can be set in raspi-config or the RaspberryPi Settings if at the Desktop.
I think you get that error of it is.

Type
pigs t
At the terminal on the Pi2 (since that's where it needs to be running).
It should give some number iirc.

User avatar
bensimmo
Posts: 3227
Joined: Sun Dec 28, 2014 3:02 pm
Location: East Yorkshire

Re: Remote control buggy project

Fri Jul 06, 2018 8:15 pm

Can you run that python program but use 127.0.0.1 on the Pi2 itself (as it will be run on the local Pi2 it'll need local host.).
That should check the code.

Also check the IP address of the Pi2.

Girl
Posts: 8
Joined: Wed Jun 27, 2018 1:26 pm

Re: Remote control buggy project

Sat Jul 07, 2018 2:19 am

Hello,

Thank you for your help.

I made the first step to suggest (pigs t on the RPi2 - robot) and I get a different number each time. Then I put the 127.0.0.1 on the python program that I transferred to the RPi2. I received this error:
Traceback (most recent call last):
File "/home/pi/testrobot.py", line 5, in <module>
robot = Robot(left=(factory.pin(7), factory.pin(8)), right=(factory.pin(9), factory.pin(10)))
File "/usr/lib/python3/dist-packages/gpiozero/devices.py", line 95, in __call__
self = super(GPIOMeta, cls).__call__(*args, **kwargs)
File "/usr/lib/python3/dist-packages/gpiozero/boards.py", line 1166, in __init__
left_motor=Motor(*left, pin_factory=pin_factory),
File "/usr/lib/python3/dist-packages/gpiozero/devices.py", line 95, in __call__
self = super(GPIOMeta, cls).__call__(*args, **kwargs)
File "/usr/lib/python3/dist-packages/gpiozero/output_devices.py", line 855, in __init__
forward_device=PinClass(forward, pin_factory=pin_factory),
File "/usr/lib/python3/dist-packages/gpiozero/devices.py", line 95, in __call__
self = super(GPIOMeta, cls).__call__(*args, **kwargs)
File "/usr/lib/python3/dist-packages/gpiozero/output_devices.py", line 327, in __init__
pin, active_high, initial_value=None, pin_factory=pin_factory
File "/usr/lib/python3/dist-packages/gpiozero/output_devices.py", line 47, in __init__
super(OutputDevice, self).__init__(pin, pin_factory=pin_factory)
File "/usr/lib/python3/dist-packages/gpiozero/mixins.py", line 69, in __init__
super(SourceMixin, self).__init__(*args, **kwargs)
File "/usr/lib/python3/dist-packages/gpiozero/devices.py", line 374, in __init__
pin = self.pin_factory.pin(pin)
File "/usr/lib/python3/dist-packages/gpiozero/pins/pi.py", line 69, in pin
n = self._to_gpio(spec)
File "/usr/lib/python3/dist-packages/gpiozero/pins/pi.py", line 81, in _to_gpio
if not 0 <= spec < 54:
TypeError: unorderable types: int() <= PiGPIOPin()
thanks again,

Zoe

User avatar
bensimmo
Posts: 3227
Joined: Sun Dec 28, 2014 3:02 pm
Location: East Yorkshire

Re: Remote control buggy project

Sat Jul 07, 2018 9:39 am

A number means pigpiod is up and running fine.
So your other error message when trying to run sudo pigpiod is correct as it is already in use.


It's something wrong with the python3 code or the way it is being run.
Not sure but it seems to be erroring on a gpio number check, testing if the number is probably a gpio number. (Sanity check?)


Do the simpler examples work?

User avatar
bensimmo
Posts: 3227
Joined: Sun Dec 28, 2014 3:02 pm
Location: East Yorkshire

Re: Remote control buggy project

Sat Jul 07, 2018 9:50 am

Code: Select all

from gpiozero import Button, Robot
from gpiozero.pins.pigpio import PiGPIOFactory
from signal import pause

factory = PiGPIOFactory(host='192.168.1.124')
robot = Robot(left=(7, 8), right=(9, 10), pin_factory=factory)

# local buttons
left = Button(26)
right = Button(16)
fw = Button(21)
bw = Button(20)


fw.when_pressed = robot.forward
fw.when_released = robot.stop

left.when_pressed = robot.left
left.when_released = robot.stop

right.when_pressed = robot.right
right.when_released = robot.stop

bw.when_pressed = robot.backward
bw.when_released = robot.stop

pause()

Does this code work (check IP address and button pin numbers etc..)

User avatar
bensimmo
Posts: 3227
Joined: Sun Dec 28, 2014 3:02 pm
Location: East Yorkshire

Re: Remote control buggy project

Mon Jul 09, 2018 10:55 am

For the info, there must be a problem with the tutorial, or something we are missing.
Using the same code you use in that tutorial, I get the same error.


The tutorial does not work.
https://projects.raspberrypi.org/en/pro ... ol-buggy/5

User avatar
mahjongg
Forum Moderator
Forum Moderator
Posts: 10944
Joined: Sun Mar 11, 2012 12:19 am
Location: South Holland, The Netherlands

Re: Remote control buggy project

Mon Jul 09, 2018 12:18 pm

bensimmo wrote:
Mon Jul 09, 2018 10:55 am
For the info, there must be a problem with the tutorial, or something we are missing.
Using the same code you use in that tutorial, I get the same error.


The tutorial does not work.
https://projects.raspberrypi.org/en/pro ... ol-buggy/5
Of the bottom of the page there is a button you can use to give direct feedback to whoever wrote the tutorial.

P.S. You *are* using Python3 right?

User avatar
bensimmo
Posts: 3227
Joined: Sun Dec 28, 2014 3:02 pm
Location: East Yorkshire

Re: Remote control buggy project

Mon Jul 09, 2018 1:15 pm

mahjongg wrote:
Mon Jul 09, 2018 12:18 pm
bensimmo wrote:
Mon Jul 09, 2018 10:55 am
For the info, there must be a problem with the tutorial, or something we are missing.
Using the same code you use in that tutorial, I get the same error.


The tutorial does not work.
https://projects.raspberrypi.org/en/pro ... ol-buggy/5
Of the bottom of the page there is a button you can use to give direct feedback to whoever wrote the tutorial.

P.S. You *are* using Python3 right?
I am. (and so is girl)
I'm just helping Zoe (girl) here.

So people do read the comment on there, the problem is you never get any feedback from it. I suppose there is github, but sending her there means also learning github. (edit i've done there too) I was hoping the Foundation may come and help out with problems on their article in their support forum :-) I know some of them do read in here from time to time, so reporting it seemed the best way as you cannot directly contact specific people now.

Although I believe Ben Nuttall does make sure gpiozero runs on both Python versions, so that shouldn't be a problem.
Last edited by bensimmo on Tue Jul 10, 2018 3:23 pm, edited 1 time in total.

User avatar
mahjongg
Forum Moderator
Forum Moderator
Posts: 10944
Joined: Sun Mar 11, 2012 12:19 am
Location: South Holland, The Netherlands

Re: Remote control buggy project

Tue Jul 10, 2018 11:33 am

I have done a general call to moderators, to have a look at it.

Girl
Posts: 8
Joined: Wed Jun 27, 2018 1:26 pm

Re: Remote control buggy project

Wed Jul 11, 2018 12:54 pm

Hi,

Thank you very much for your help!

I used the command that you proposed to me on python 3. The remote control is working well except that it is only making the robot turn left and right. I have 2 buttons that is making the robot turn left and 2 that is making the robot turn right. I can't go forward or backward.

This is the script I used:

Code: Select all

from gpiozero import Button, Robot
from gpiozero.pins.pigpio import PiGPIOFactory
from signal import pause

factory = PiGPIOFactory(host='192.168.1.123')
robot = Robot(left=(7, 8), right=(9, 10), pin_factory=factory)

# local buttons
left = Button(21)
right = Button(13)
forward = Button(17)
backward = Button(4)


forward.when_pressed = robot.forward
forward.when_released = robot.stop

left.when_pressed = robot.left
left.when_released = robot.stop

right.when_pressed = robot.right
right.when_released = robot.stop

backward.when_pressed = robot.backward
backward.when_released = robot.stop

pause()
Thanks again

Zoe

martinohanlon
Posts: 2
Joined: Thu Jul 12, 2018 2:18 pm

Re: Remote control buggy project

Thu Jul 12, 2018 2:19 pm

Hi

I have fixed the issue in the project and also made a few changes to make it a little easier to follow.

https://projects.raspberrypi.org/en/pro ... ol-buggy/5

Apologies for the problem and thanks a lot for bringing it to our attention and to those who help in finding a solution :)

Martin

Return to “Automation, sensing and robotics”

Who is online

Users browsing this forum: No registered users and 13 guests