User avatar
JonnyAlpha
Raspberry Pi Certified Educator
Raspberry Pi Certified Educator
Posts: 572
Joined: Sat Nov 02, 2013 2:06 pm

Switching Between Autonomous and Manual - Robot Control

Sun Aug 23, 2015 8:35 am

Hi, I am experimenting with a Web controlled Pi / Arduino Robot. The Pi and the Arduino communicate over an i2c Serial Bus.

I want to be able to switch between Autonomous and manual mode. To do this could I just use an 'if' statement that looks for Serial data (the manual control) and if nothing is received start autonomous mode. I'll incorporate a delay of about 5 minutes to prevent it switching mid manual mode.

Does this seem ok?
Raspberry Pi Certified Educator. Main Hardware - Raspberry Pi 1 model B revision 2, Raspberry Pi 2 model B, Pi Camera

User avatar
davef21370
Posts: 897
Joined: Fri Sep 21, 2012 4:13 pm
Location: Earth But Not Grounded

Re: Switching Between Autonomous and Manual - Robot Control

Mon Aug 24, 2015 4:36 pm

Sounds fine but just as a matter of interest what's doing what?
I'm guessing the Pi is controlling the robot by user commands in manual mode and the Arduino is handling sensors and sending commands to the Pi for automatic mode?
If so I'd drop the delay to say, 15 seconds, before it goes automatic but warn the user it's about to change (beep/flash/spin/whatever) and just detect a carriage-return to return to manual mode.

Dave.
Apple say... Monkey do !!

User avatar
JonnyAlpha
Raspberry Pi Certified Educator
Raspberry Pi Certified Educator
Posts: 572
Joined: Sat Nov 02, 2013 2:06 pm

Re: Switching Between Autonomous and Manual - Robot Control

Tue Aug 25, 2015 8:37 am

davef21370 wrote:Sounds fine but just as a matter of interest what's doing what?
I'm guessing the Pi is controlling the robot by user commands in manual mode and the Arduino is handling sensors and sending commands to the Pi for automatic mode?
If so I'd drop the delay to say, 15 seconds, before it goes automatic but warn the user it's about to change (beep/flash/spin/whatever) and just detect a carriage-return to return to manual mode.

Dave.
Dave thanks for the response - yes the Pi is serving a Web Page using WebIOPi which has a control panel and a video stream from a WebCam mounted on the Robot. This enables the user to remotely navigate and control the robot and send commands to the Nano to operate the motors. The Arduino has an HC-SR04 Ultrasonic Sensor mounted on it but handles the Auto mode itself.

I have a couple of issues with it at the moment:
1. The lag on the camera is way to slow to be useable to drive it around (I am using Mjpg-Streamer).
2. I cannot make fine turns left and right, when you click the 'Left' button on the Web Page and even if you immediately release the button which then sends a 'Stop' command the turn runs for about a second in which time the robot has spun 180 degrees!! I think this is because of a code induced delay of 1 second to avoid overload on the i2c Serial Bus, I may try and reduce it or play with the Arduino Code to run a command for a specified amount of Milliseconds using the Millis() function in Sketch which looks like it can be used to check how long a piece of code has been running and then do something? It is demonstrated here https://www.arduino.cc/en/Tutorial/BlinkWithoutDelay.
Raspberry Pi Certified Educator. Main Hardware - Raspberry Pi 1 model B revision 2, Raspberry Pi 2 model B, Pi Camera

Return to “Python”