Version ‘alamak’ of the remote control cart (buggy)
There are some limitation using the Python robot library together with this buggy. The right and left function resulted in the buggy doing a spot turn, which in this case is not what I wanted. So in the code you can see that the turn right/left function is use together with forward and sleep function to smoothen the turning.
In Line 39 , the ‘bd.when_moved’ command is commented out because I do not want the Blue Dot remote control to register a long press as a command to sent continuous loops. In this way the RPi will only run one ‘move’ function per one press of the Blue Dot. The next ‘move function will only run when the user finger is lifted and repress the bluedot. This, to me is necessary, so as to have better control on the turning of the buggy.
A video to show the buggy doing donuts around a table leg. ↓
from bluedot import BlueDot from gpiozero import Robot from time import sleep bd = BlueDot() bd.wait_for_press() #Just a message to confirm interface print("You pressed the blue dot!") #GPIO pins to motors connection robot = Robot(left=(7, 8), right=(9, 10)) def move(pos): if pos.top: robot.forward() elif pos.bottom: robot.backward() elif pos.right: #the right/left turn fn use together robot.left() #with forward and sleep function sleep(0.05) #to smoothen the turning robot.forward(0.8) sleep(0.1) elif pos.left: robot.right() sleep(0.05) robot.forward(0.8) sleep(0.1) #robot.forward() #robot.left(0.8) def stop(): robot.stop() bd.when_pressed = move #below when_moved command removed to prevent bluedot continuous #sending message to Rpi #bd.when_moved = move bd.when_released = stop
So the next step is to add a front (and maybe back) camera to the buggy and make it a surveillance buggy. Good thing the range of the bluetooth can be up to 100m.