Hi, I have a few questions concerning the new WatchDog Service:

To Do:

I have 2 motors "m1" and m"m2" driven by an joystick service. They are not driven by being attached to the joystick (like in the sabertooth or work-e examples), beacause I implemented some differential steering logic to drive both motors with x,y of one Stick. This is done by getting the x and y value by an OnInput metho and transform them into motor speeds and directions for both motors. (I will post the code on detail on my blogpost following if its working as intended)

In the case the joystick does not send commands anymore it should automaticaly stop the motors. to do this GroG told me about the WatchDog service in the shoutbox and I tried to dig into the java code to see what it does.

But im not sure if this would work an why:

watchdog = Runtime.start(“watchdog”, “WatchDogTimer”)     

joystickCheck = Runtime.start(“joystickCheck”, “WatchDogTimer”)

 

#I guess this should have started the watchdog itself and an joystickCheck as one sort of "Timer"?

 

watchdog.addTimer(“joystickCheck”)

 

#Listen to the joystickTimer?

 

watchdog.addAction(“m1”, “stop”)

watchdog.addAction(“m2”, “stop”)

 

#If the last checkpoint is overdue do m1.stop() + m2.stop()?

 

joystickCheck.addCheckPoint(“watchdog”)

 

#Im not sure if this part is needed an what function it has?

 

#in onJoystickInput:
joystickCheck.checkpoint(“watchdog”)

 

#I guess  I can put this in the OnJoystickInput function and reset the watchdog or in other words send a #checkpoint everytime it gets a new keychange?

 

So afterall this is my question: Am I understanding the function correctly (italic blocks between code), and would this contain everythin to stop the motors x second (how do i change this) after the last received joystick valuechange?

 

GroG

5 years 9 months ago

Hi Kakadu,

I'm excited your working on this at the same time as myself.

I'm curious if your using a single process for the watchdogtime & checkpoint.

My Experiences :

  • laptop lid closes - it goes to sleep in hibernate mode, while the chair is going full tilt toward a wall 
  • usb cable from laptop to sabertooth controller gets pulled out

In both of these crashes - a WatchDogTimer service inside a single mrl instance would not have prevented the problems.  What would have is another process on another computer which had access to cut the power.

That's why I'm planning to have a raspi instance with control to cut the power with a relay (vs. stopping the motor with sabertooth which would not have helped)

I suppose if the joystick cable got unplugged a watchdogtimer/checkpoint running in the same instance might help...  Is this the use case your interested in ?

Hi GroG,

I'm actually working on this for a long time but at the moment my budget and time is limited. I had to rewrite some code to be avble to run the wheelbase with the joystick in the new Version. I will certaily take your way of a seperate watchdog in consideration in the future. At the moment I still use an old laptop which will definately be replaced in the future, maybe thats the moment for the more complicated but safer approach.

At the moment you are right, I want to shut the motors of if the joystick loses connection. The good side effect is that if the joystick doesnt jump back in its deadspot it would still block any further movement, when no new joysticksignals are received. For bigger errors I have a big red key in the front of the robot which is turned easy and will shut off the power of both motors. (You will see it once I make a blog post, which is planned soon but I also have to move so I will see if I can get to it before) Additionally, altough the motors are really strong, the wheels does not have enough torque indoor to move if I get a good grip and some force on the robot.

I'd be glad if you could help me doing this simple approach, as I have stated it in my post. =)

Ok,

The following script should work with the latest build...

[[service/WatchDogTimer.py]]

WatchDogTimer is a new service, therefore I'd like to do some more refactoring ..

Specifically, making a "default" checkpoint - this should reduce at least 2 lines of code in your simple case

I added comments to explain in the python, let me know if you have any issues.