ThunderBorg monsterweb.py for diablo

Forums:

Love the web UI monsterweb.py for ThunderBorg, sure wish I could get it working on diablo! I have tried based on http://forum.piborg.org/node/2643 but struggling to make it work. Did manage to get a keyboard version working based on http://forum.piborg.org/diablo/examples/users (danger turn down the motor commands!) but the issue is the rover does not time out if Wi-Fi and/or command is lost.

Would be sweet if PiBorg had an official GitHub for diablo similar to ThunderBorg. They are both wonderful boards! With bigger motors comes bigger rovers and the fun for us is the build but we struggle with the code as I'm sure do many others. With the bigger rover it can be a serious issue if the thing runs away! We plan to add a solar panel/charger and leave the thing outside to patrol the garden at night (pesky deer) but the wife will NOT be impressed if it plows over her veggies:-/

web UI control with buttons that stop motors when released same as http://my_pi_ip/hold would be the hot ticket...

Images: 
piborg's picture

We have a GitHub for all of the versions of the WebUI code here: https://github.com/piborg/diddyborg-web

I have added diabloWeb.py, which is diddyWeb.py modified to control a Diablo instead of a PicoBorg Reverse. I do not have a Diablo to test with (working from home), but the changes are fairly simple (see here).

Before you run the script remember to change the values in the "Power settings" section to match your battery and motors :)

There are two versions of the page which should move while the buttons are held:

  • http://my_pi_ip/hold is the original version - it works well on PCs, but does not work correctly on some mobile devices
  • http://my_pi_ip/touch is a newer version added by wingers999 - this version works better on most mobile devices

If one of them does not work correctly give the other one a try.

I would recommend testing the script first by placing your robot so the wheels do not touch the ground. That way you can avoid any veg related incidents :)

Finally got a chance to test, happy to report it's working with both Joystick and Web control at the same time even!

Only issue so far is the button mapping, for example Spin Left drives forward. Not sure where it's what's easiest to change, diabloJoystick.py or diabloWeb.py but at the moment they don't jive:-/ Maybe just move the buttons around and relabel if the commands are indeed the same in both files. Haven't had a chance to look yet...

Also, line 395 has an extra space and gives a syntax error.

piborg's picture

Thanks for pointing out the indentation error, it seems some of the other scripts were also wrong :)
I have pushed corrections for these scripts.

I have also changed the motor outputs in diabloWeb.py to match the diabloJoystick.py script as it was a fairly simple change:
https://github.com/piborg/diddyborg-web/commit/027dcdf60b4bf7c7646845ea3...

Thanks for the update, hold works great!

I do get a pesky Timed out, Reconnected error; not sure if it's my Wi-Fi dongle, AP or just from sitting while mucking about with the hardware. Guess the real test will be once it's roving about in the garden.

Swapped out the zero (no camera) for a 3B with camera. Planned to have several cameras anyway, one fixed fwd low rez low latency FPV and several high rez PTZ on their own PiZero's. Bits hanging out everywhere just now needs some work to make it all weatherproof again.

Can't wait to plow up some veggies!

piborg's picture

The timeout is controlled by measuring how long it has been since the last message from the web browser. Since the web browser loads images regularly it keeps sending messages while open.

The timeout checking is entirely controlled by this thread:

# Timeout thread
class Watchdog(threading.Thread):
    def __init__(self):
        super(Watchdog, self).__init__()
        self.event = threading.Event()
        self.terminated = False
        self.start()
        self.timestamp = time.time()

    def run(self):
        timedOut = True
        # This method runs in a separate thread
        while not self.terminated:
            # Wait for a network event to be flagged for up to one second
            if timedOut:
                if self.event.wait(1):
                    # Connection
                    print 'Reconnected...'
                    timedOut = False
                    self.event.clear()
            else:
                if self.event.wait(1):
                    self.event.clear()
                else:
                    # Timed out
                    print 'Timed out...'
                    timedOut = True
                    DIABLO.MotorsOff()

You can increase how long it waits for the next message which should reduce the amount of false timeout detections. The downside is that it will also increase how long the robot runs for before it detects a real disconnection.

To increase the delay change the 1 in the if self.event.wait(1): lines for a larger number. The number is how many seconds to wait.

Nice and thanks again for all your help. Think the Pi was jammed up, there was lots of 'experimental' (don't know what I'm doing) stuff on it, would skip pings just sitting there for some reason. Fresh OS install and only the PiBorg essentials loaded seemed to make it happy. Got a good run around the yard yesterday, everything works with no issues, so sweet! Will post some pics once the machine is cleaned up a bit, still a prototype but once we're sorta happy with the general layout going to build a few more likely with a proper welded frame. Kids are already talking about a bigger machine!

Awesome, thank you very much!

Have not had opportunity to test yet (busy week ahead) but will let you know when I do...

Subscribe to Comments for "ThunderBorg monsterweb.py for diablo"