Notifications
Clear all

Emergency Stop System Logic - Motor Control Board  

Page 5 / 6
  RSS

byron
(@byron)
Reputable Member
Joined: 1 year ago
Posts: 353
2020-04-30 4:26 pm  

 

Posted by: @frogandtoad

Anyway, give it a test

A worthy contribution I think, but if you are still minded to have each command as a class, then surely it would be better to await your final code, or risk Bill having to continually re-work his example.


ReplyQuote
starnovice
(@starnovice)
Estimable Member
Joined: 1 year ago
Posts: 169
2020-04-30 8:18 pm  

@byron I really think the code for the motor controller is too simple to benefit from the overhead of creating classes for the functions.

Pat Wicker (Portland, OR, USA)


ReplyQuote
starnovice
(@starnovice)
Estimable Member
Joined: 1 year ago
Posts: 169
2020-04-30 9:38 pm  

@dronebot-workshop Bill, I think you need two more functions.  One for receiving I2C data and one for respond to request for data over I2c. You probably have them in process and just haven't shown them yet because you don't really need them until you implement your loop() function.

Pat Wicker (Portland, OR, USA)


ReplyQuote
byron
(@byron)
Reputable Member
Joined: 1 year ago
Posts: 353
2020-05-01 12:31 am  
Posted by: @starnovice

I really think the code for the motor controller is too simple to benefit from the overhead of creating classes for the function

My view is that for programming these small memory Arduino microprocessors using classes is not the solution, both in terms of overheads and readability. Its a view that may not be correct, but it is the view I hold and the view I spout if the topic comes up where someone is asking for opinions. But others have expressed differing opinions including @frogandtoad.

So it is of interest to see how this sort of Arduino program would look like if coded with classes as our friend suggested, though this view may now have changed?  In expressing my view on the use of c++ classes I its a view expressed in lack of experience in c++ as I only have experience of C programming a rather long time ago, though augmented by tinkering with Arduinos over the past 5 years or so. So this seemed like a very good opportunity, when the use of classes for this motor control program was mooted, to examine any code produced to see if my view would change and I should start on some c++ tutorials.

I certainly don't want this to appear the I'm encouraging @frogandtoad to produce his code with classes just so I can knock it down, so whatever code is produced (if any) I will keep schtum. Though if I really like the class approach frogandtoad may produce he could get a large sloppy kiss and turn into Prince. 😀 


ReplyQuote
starnovice
(@starnovice)
Estimable Member
Joined: 1 year ago
Posts: 169
2020-05-01 12:39 am  

@byron I definitely should not be putting words into @frogandtoad mouth, but his messages did not really suggest that everything should be done in classes.  He only suggested that might be one solution for the race condition you can run into with the E-STOP.

Pat Wicker (Portland, OR, USA)


ReplyQuote
byron
(@byron)
Reputable Member
Joined: 1 year ago
Posts: 353
2020-05-01 12:50 am  

@starnovice - I was probably putting too much thought on

"Yes, I would envisage each command to be a class, with an internal command id for tracking, commands (incorporated as member functions (setPwm, accelerate, etc...)).  You would also need a brain/controller class, perhaps storing an array of these commands for tracking their execution!"

It was only a suggestion not a statement of intent,  and if @frogandtoad doesn't wish to peruse that thought thats fine.  I don't wish to pressurise anyone.  Time for me to shut up and leave this alone I think.


ReplyQuote
frogandtoad
(@frogandtoad)
Reputable Member
Joined: 1 year ago
Posts: 490
2020-05-02 1:02 pm  

@starnovice

Posted by: @starnovice

@byron I really think the code for the motor controller is too simple to benefit from the overhead of creating classes for the functions.

Actually, the goal of classes is to help to simplify ones code, rather than to complicate it.

By the way... what is the overhead you're referring to?


ReplyQuote
frogandtoad
(@frogandtoad)
Reputable Member
Joined: 1 year ago
Posts: 490
2020-05-02 1:39 pm  

@byron

Posted by: @byron

My view is that for programming these small memory Arduino microprocessors using classes is not the solution, both in terms of overheads and readability. Its a view that may not be correct, but it is the view I hold and the view I spout if the topic comes up where someone is asking for opinions. But others have expressed differing opinions including @frogandtoad.

Without classes, one can only go so far programming using a procedural methodology, and using classes actually improves readability... one just needs to take some time to learn how to use them.

Here comes that myth again regarding memory and overhead 🙂

Posted by: @byron

though this view may now have changed?

My view on using classes hasn't changed, as I think they can add value to any program one writes.  In this particular case, it was just an idea for addressing the resumption of code, post an interrupt taking place in a function.

The problem for this project is that there is still no settled direction as far as I can see, so it's not easy to just write code when you don't know what the end goal is.  If you know, then please tell us 🙂  For example, will the robot store commands in a pipeline/queue? or create them on the fly one at a time? Will there be set stored procedures?  Is the goal for the robot to interact with obstacle on the fly? or will the robot be hard coded to move along known/preset cartesian coordinates, etc...?

As you can see... without knowing these details (I'm not even sure if any of the ideas being bandied around have been settled on), it's not so simple to start coding for an unknown.


ReplyQuote
frogandtoad
(@frogandtoad)
Reputable Member
Joined: 1 year ago
Posts: 490
2020-05-02 1:43 pm  

@byron, @starnovice

Posted by: @byron

@starnovice - I was probably putting too much thought on

"Yes, I would envisage each command to be a class, with an internal command id for tracking, commands (incorporated as member functions (setPwm, accelerate, etc...)).  You would also need a brain/controller class, perhaps storing an array of these commands for tracking their execution!"

It was only a suggestion not a statement of intent,  and if @frogandtoad doesn't wish to peruse that thought thats fine.  I don't wish to pressurise anyone.  Time for me to shut up and leave this alone I think

starnovice is correct... As I said in my previous post, it was just an example for that condition, and the text you've quoted is obviously and example of how I would envisage it to work, should such an idea be adopted.


ReplyQuote
byron
(@byron)
Reputable Member
Joined: 1 year ago
Posts: 353
2020-05-02 2:54 pm  

@frogandtoad

I appreciate that your suggested code was only how you envisaged it would work.  I recognise my lack of appreciating the use of classes in this instance may well be flawed through ignorance as I have chosen, thus far, not to peruse getting to grips with C++ as my C type coding has so far done the job.  

As Bill invited anyone to fork his code and rework it I would take this also to mean completely redo it if desired.  Reworking  the code as you envisaged will probably not go any further unless you, or someone else with suitable expertise, undertakes to do so.  I'm sure Bill will happily promote the best solution, as he sees it, for the future DB1 code. 

As this  example program is really quite small, I thought it would not take so long for you to present a fully worked example.  I do hope consider doing so.  Getting the code structure right at this stage could be fundamental to the whole success of the project and I'm sure your input would be welcome by all.


ReplyQuote
frogandtoad
(@frogandtoad)
Reputable Member
Joined: 1 year ago
Posts: 490
2020-05-02 3:51 pm  

@byron

Initially, I wasn't interested in building a robot, so I hadn't been following along and just became interested in it recently, hence the reason for my earlier questions. Have any design aspects been established or accepted at this stage, or is everyone still trying to nail down the design?

Any documentation, i.e:- DFD?

As for C++, it's just a tool, but classes are a very powerful aspect of any language... I'm sure you use them a plenty in python, so not sure of the resistance 🙂


ReplyQuote
starnovice
(@starnovice)
Estimable Member
Joined: 1 year ago
Posts: 169
2020-05-02 4:11 pm  

@frogandtoad

Here is a posting Bill made describing the function of the processors:

https://forum.dronebotworkshop.com/navigation-layer/code-and-wiring-for-db1-motor-control/paged/3/#post-10401

And here is a link to Bill's initial overall design concept: https://dronebotworkshop.com/real-robot-001/  

Frankly, at this point a lot of this is a work in progress and I am sure that is why Bill appreciates thoughts on design direction although I pretty sure he has an overall direction he would like things to go.  Also keep in mind that is supposed to be a video series for Bill and apparently it hasn't been well received so far.

Pat Wicker (Portland, OR, USA)


ReplyQuote
frogandtoad
(@frogandtoad)
Reputable Member
Joined: 1 year ago
Posts: 490
2020-05-02 4:14 pm  

@starnovice

Thanks for the links... will check them out! 🙂

 


ReplyQuote
byron
(@byron)
Reputable Member
Joined: 1 year ago
Posts: 353
2020-05-02 4:35 pm  
Posted by: @frogandtoad

As for C++, it's just a tool, but classes are a very powerful aspect of any language... I'm sure you use them a plenty in python, so not sure of the resistance

Its not so much a resistance as a doubt garnered over the course of the past few years as I took up the electronics, arduino, Rpi et al as a hobby in retirement.  The first book I bought on the subject was by Simon Monk, but other free books and internet examples I have perused do not make use of classes.   Bills excellent code does not make use of classes.   So, when you suggest that one should get fully to grips with C++ and make use of classes when using the small Arduino boards I have doubts. (and I stress using the small Arduino boards - using classes is highly desirable in any large program and in collaborative programming situations of course).  But, as said, I'm no expert.  So to see a fully worked example using classes in the context of small Arduino programs would be of interest, and maybe a revelation. 

As you know, there is no specification of DB1 apart from what you see in Bills video's and documents recently put into this forum.   It seems to be a 'suck it and see' approach and a 'build as go'.  Not good for a commercial project, but just the ticket for a bunch of hobby types like most of us.   So you will probably not get the design aspects you seek, at least not for a while (but I don't know what Bill is planning).  I think you will have to relax on your desire to nail down a complete design.

However we do have a motor control program.  I think we can consider the design for this complete.  Its a black box to the rest of the robot design.  We have been invited to improve it.  An example using classes along the lines you suggested, at this stage, could set the framework (not a framework 😎) for the subsequent coding methodology to use going forward.  As the project progresses the appetite for restructuring existing code will doubtless diminish.  That is why your reworked example at this stage could prove interesting.


ReplyQuote
frogandtoad
(@frogandtoad)
Reputable Member
Joined: 1 year ago
Posts: 490
2020-05-02 4:59 pm  

@byron

Posted by: @byron

 I think you will have to relax on your desire to nail down a complete design.

I didn't ask for a complete design.  I understand how difficult a project such as this can be to implement, so I don't want to waste anyone's time if they're not interested in a particular direction.

By the way... you keep referring to this as being a small program, but the code has yet to begin, and IMO, it will not be small by the time it's finished.  What do you consider small?

Posted by: @byron

So to see a fully worked example using classes in the context of small Arduino programs would be of interest, and maybe a revelation. 

I have written and posted many small examples here already, but if you prefer another, I just performed a quick search found this one which is quite reasonably explained: A simple C++ class example

Hopefully when you look through the loop of the before and after in this tutorial, you might realise the benefits, even for a small program 😉


ReplyQuote
Page 5 / 6