MotorController is missing an attach !

I'm trying to get Sabertooth service working again .. 
In the process I noticed MotorContoller is missing this method .. 

public void attach(MotorController controller) throws Exception;  

to go along with the other Controller interfaces and to follow the Attach Pattern !

Hopefully I can implement this (and perhaps others) with Java 8 "default" interface methods .. allowing all common, repetitive and routine code to live in just one space.

Arduino, AdafruitMotorShield, Adafruit16ServoDrive & Sabertooth would potentially be affected, unless all functionality can be implemented in "default" behavior.

References :


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Kakadu31's picture

Altough missing the attach

Altough missing the attach method, Sabetooth was working fine ffor me with 2105. If you need any Tests after your polish i can help if you want GroG.

GroG's picture

Hi Kakadu, Can you post the

Hi Kakadu,
Can you post the script you are using for the Sabertooth ?  I'm very curious how you set things up

Also does it work with the latest, (Its currently not working with a test script of mine so I'm wondering if I'll be fixing something recently borked)

Thanks !.  

Kakadu31's picture

I will have to update it on

I will have to update it on my linux to see if it is working with the newest build, and I really need to keep up with work work to get time to make the tutorial, you're the second one now who would have benefited from it:

https://github.com/MyRobotLab/pyrobotlab/blob/master/home/kakadu31/saber...

The joystick is an artefact and is there because this script became the other script I uploaded on pyrobotlab:

https://github.com/MyRobotLab/pyrobotlab/blob/master/home/kakadu31/Contr...

UPDATE:

I tested both scripts with 2234 and they worked like expected. I already changed the new working version in the comments.
I use an ftdi-cable from the usb port of an old Sony Vaio with Ubuntu 16.xxx and connected the Sabertooth fto the ftdi like shown in he picture:

The controller is attached to a 12V battery and 2 wheelchair motors.

You can check if you have the riht Configuration from the 6 little switches?

GroG's picture

Thanks for posting Kakadu -

Thanks for posting Kakadu - this helps.  I can see you are using (what I would call) Sabertooths "native" interface.  Which is great.  Are you currently driving it around inside your house ?  

I too have a wheelchair. Its for a large person, so its a bit large for driving around in the house.  And our house is old, so many of the doorways are narrow compared with modern buildings standards.  Regardless, I hope to be able to provide fine control to it so it can navigate about without turning doorframes to splinters.

Mats and I have worked on the MotorControl interface.  It allows you to control your motor through a "common" interface.  The advantage of this would be if a service was created to control a motor, it would probably use this interface. Also, it would allow you to switch your motor, or motorcontroller without having to change code (except for initial configuration) ...   At least that's the plan.

Mats's picture

MotorController vs MotorControl

When I built the DiyServo service I was also looking for that method, since I had been told that it should exist. But I didn't find it. I think it doesn't exist, for the simple reason, that it isn't needed.

The MotorControl ( i.e. the Motor service ) needs an attach(MotorController) method to know what MotorController to use. And the same goes for the DiyServo. It also needs to know what MotorController to use.

I prefer to think about resources ( xxControllers ) and resource users ( xxxControls ). In many cases the resource doesn't need to know about who is using the resource, but thd resource user needs to know.

For example the MotorController doesn't need to know if it's beeing used by the Motor or the DiyServo service. But both Motor and DiyServo neeed to know what MotorController to use. The MotorController can be either an Arduino service or the Adafruit16CServoDriver, since they both implement the MotorController interface. 

Just my 5 cents.

/Mats

Mats's picture

Motor

I'm a bit surprised to see that the SaberTooth service is beeing used without the Motor service. I was expecting it to be a service at the same level as the Arduino and Adafruit16CServoDriver.  

GroG's picture

I agree Mats.  It is my

I agree Mats.  It is my intent to get it working with MotorControl and that was part of the reason I posted.  I'm glad Kakadu has been able to use "Sabertooth specific methods", but the preference I'm sure would be to use MotorControl in the future.

 

GroG's picture

Hi Mats, I'd like to hear

Hi Mats, I'd like to hear your 10 cents here http://myrobotlab.org/content/service-attaching-diving-deeper :D