done. In the previous commit I also updated all the distances/angles to be treated as floats to help avoid rounding errors when doing complex patterns (e.g. writing text).As a next step, aside from testing todays commits, I'd like to change the command queue to be "pre-compiled" - i.e. commands are parsed and then the parsed arguments are added to the queue. This will:
- Reduce the memory requirement of the queue and associated routines
- Make complex patterns more efficient to parse/execute
- Enable look-ahead path planning/acceleration
- Enable more efficient macro storage (i.e. by being packed into a more efficient binary structure)
From a fundamental architecture PoV... having each stepper motor independently controlled (and accelerated) is a limiting factor in implementing:
- ARC commands
- Look ahead path planning/acceleration
Because we need carefully synchronised motion between the wheels todo arcs.... the current arrangement only works because the turn commands spin on the spot.To achieve that, we'll need to rework/remove the AccelStepper library, and directly control the step sequences. Good news is that a lot of code can be re-used, and we can borrow quite a bit of acceleration planning from reprap firmwares (marlin, etc). We'll also need some maths to calculate correct wheel motion for arcs - key parameters are wheel circumference and wheel spacing. We've already calibrated wheel circumference, so just spacing to do. Given these parameters will vary slightly by bot, we should probably expose these at runtime and store them in EEPROM.Given this is rapidly growing in complexity... is everyone managing to follow along with what we're (me/Rob) doing? and/or should we organise a code walkthrough at some point soon? could also delve deeper into the various techniques being used.... particularly look ahead planning, which is a little more specialist than circular buffers ;)
Darn it, lost the hackspace cc again...
There are a few minor tweaks that could be done to the lettering, like R is just P with an extra line, but thats not going to save a great amount of space. And it might worth trying to remove the repeated variable declarations and assignment at the start of each letter function and pass them in instead, similarly move the final PU and NEXTLETTER calls into the parent function. I will have a play around.
"I've implemented the rest of the alphabet (may need some tweaks after testing) and the bad news is program memory is now 91% full!
I quickly tried replacing all the "PU" and "PD" with F("PU") but it actually used more memory :-(
Will have to look into other possible optimisations without doing too much obfuscation, but there is nothing screaming out at the minute that I can see"
On 24 July 2015 09:55:03 Damian Axford
On 24 July 2015 12:39:01 Damian Axford <dam...@axford.me.uk> wrote:
Yay and smeg :(Just grabbing some lunch and then will take a look... Nothing clever springs to mind
On Friday, July 24, 2015, Robert Longbottom <Robe...@iname.com> wrote:I've implemented the rest of the alphabet (may need some tweaks after testing) and the bad news is program memory is now 91% full!
I quickly tried replacing all the "PU" and "PD" with F("PU") but it actually used more memory :-(
Will have to look into other possible optimisations without doing too much obfuscation, but there is nothing screaming out at the minute that I can see
Wrt "12: use macros" wouldn't declaring a function as inline give the compiler the option to do this if worthwhile?
Nice :-)
On 24 July 2015 14:48:19 Damian Axford <dam...@axford.me.uk> wrote:
lol - declaring all the write a letter functions as static reduces program size to 23,154 bytes - over 5k reduction!!more to go...
--
and have rewritten the collision handling... fingers crossed it actually works :)
Looks like it should work, just need to also strip off the ! before queueing the command though.
Will test it in a bit.
On 24 July 2015 6:51:42 pm Damian Axford <dam...@axford.me.uk> wrote:
have committed an update that includes that form of ! handling... seems to fit in nicely - test please? :)
--
have committed an update that includes that form of ! handling... seems to fit in nicely - test please? :)
I'll give it a try.
In the mean time here is the video at last https://youtu.be/P9kLOJGm6V8
On 25 July 2015 01:04:38 Damian Axford <dam...@axford.me.uk> wrote:
committed a draft implementation of arcTo() and associated ARC command. It's a direct port from the simulator code, so should be fairly close to working...
--
Yes, it drifts up and down a bit, but somehow the errors cancel out over about 4-5 letters. I think it's quite good that it's a little quaint :-)
The backlash code doesn't
appear to work quite right. Redoing the calibration test is okay, the
dots end up pretty darn close (the difference there now is down to play in
the pen lift) but it makes a mess of writing. Lower line was from
last night, upper line this morning with latest code.
Looking at the changes you made
isn't it just adding the backlash correction on every time? When what
you want is to only add on the backlash correction when the motor direction
has changed? (I may be reading the code wrong, I've not looked at
accelstepper in any detail)
Also I cant make ARC do anything sensible. Whatever parameters I pass it just makes a tiny (few mm) move. What are they supposed to be? The logo spec says ARC a r. Where a is the angle, r is the radius. Yours appears to be draw an ARC to some x,y coords? (Which may be more useful for drawing text, but I think we should call it something else in that case) But even doing a reset followed by ARC 10 10 it barely moves.
I'll have more of an
investigate later....
On 25 July 2015 09:19:09 Damian Axford <dam...@axford.me.uk> wrote:
> Sweet :) impressed,
especially with how well is stays on a line!
>
Arc is more of an arcto command. It takes x y coordinates, and tries to calculate an appropriate move. If it's only moving a short distance, I've probably screwed up a conversion factor (deg to rad, wheel diameter, etc)
Atom is clearly having fun with the code :). Will see what I can do to stop the silliness...
Will draw a pic on wed for anyone that cares...
This diagram illustrates working from known wheel movements (in terms of distance to move, dR and dL) to determine the final pen/robot position. The same calculations work backwards, if you have a known final position and want to determine the wheel movements (i.e. an ARC command).
Approach:
Good explanation and pictures, I was thinking you were driving the robot round the cone, but the cone represents the robots wheels, which makes a lot more sense.
However I still don't really see what the cone is doing for you. It doesn't really model the robots wheels because IRL they are both the same diameter, in the cone model they aren't.
To calculate dR and dL "all" you need (and appear to be using?) is some circle segment geometry.
Hmm, maybe the cone is more
useful when you know the wheel moves and want to work out the final
position, which is the opposite of what we are need to do. Yeah, that makes
sense.
#include <CommandQueue.h>
CommandQueue cmdQ;
void someMethod() {
cmdQ.push("FD 50");
if (cmdQ.pending() > 0)
String nextCmd = cmdQ.pop();
....etc.
Having pondered that, it sounds like a good trade off... Thoughts?
Ps - everyone other than rob, you're welcome to join in on this discussion :)
Doh. Wrong box. :-)
Okay, will split out cmdq. Good point about enqueue, dequeue, will do that too.
TextClass, yeah I did think about just passing a pointer to the state object. I guess I was thinking that may change at some point, plus you'd need to move the struct defn into an .h file to be able to pass it and I see that as part of Logobot.h (the logobot library) and that's not there yet. But we could that later.
Logobot class, only speaks logo, hmm, yeah. I wasn't thinking about taking it that far at the minute, but we could do that. Maybe Logobot is a bad name for what I'm thinking. I guess I was thinking more just Bot. So you could use the Bot class to play around with driving about and reacting to bumpers while totally ignoring the "logo" thing. I guess in that case Logobot would potentially extend Bot. More complexity :-)
State info, yes agree it would
hurt to update it every step, I saw it as more of a request. So it
updates when you ask for it, rather than recalcing all the time.
Though thats probably quite tricky to work out. Once every 500ms
would work too, any more often and the ESP will probably struggle as
well. I'm not even sure what, if any use it has, except to provide a
funky display of position. Also if we start updating that all the
time we'd have to be careful about adding letters since that is part if the
input to generating commands. Let's worry about this later!
Hmm, yes. I go for simplicity for now.
I like that WT takes a word. It makes it usable over the Arduino Serial monitor if you're connected and dont have a WiFi module. Having to pass one per letter is painful. I think also the command q would get full too soon. Given A-z would take 26 instead of just 1 that seems like a backward step (no pun intended) to me.
If the stepper lib has a queue of moves, don't we just need to speed along the cmdq until we hit a PU or PD or the stepper queue fills up and then wait until there is space in the stepper queue again, or its empty if the next command is PU/PD ?
On a similar vein I introduced the concept of an immediately actioned command for the STATus command. I think we need to add stop and emergency stop into this category and do a bit more magic in those commands like (clear the text buffer for example or sending SE simply moves on to the next letter :-/)
Maybe we need to sit down and rework the processing of commands now we have more stuff going on....
Yeah, let's head in that direction and see what happens :-)
I also see Bot being used in some of the simpler examples maybe. Eg:
DrawSquare.ino
Bot logobot;
void loop() {
logobot.drive(10);
logobot.turn(90);
....
--
LogobotText::begin(cmdQ); // should be LogobotText.begin(cmdQ);
LogobotText::writeChar('A'); // should be LogobotText.writeChar('A');
Before: Binary sketch size: 28,616 bytes (used 93% of a 30,720 byte maximum) (1.36 secs) Minimum Memory Usage: 587 bytes (29% of a 2048 byte maximum) After: Binary sketch size: 24,756 bytes (used 81% of a 30,720 byte maximum) (0.92 secs) Minimum Memory Usage: 587 bytes (29% of a 2048 byte maximum)
Cool, I have 3 spare steppers we could use to build another one and a 5v pro mini. Might print another set of parts anyway.
On 31 July 2015 10:28:49 Damian Axford <dam...@axford.me.uk> wrote:
good work on the namespace - that's a hefty saving indeed!just ordered a whole bunch of parts for new logobots (10x arduinos, 20x steppers) - half from UK distros, rest from China. At least the UK portion should arrive in time for Bristol.
Cool, I'll try and test something later today.
Have added LogobotText::setFontSize() method and associated logo extension command "FS".
Costs what seems like a lot in memory because I've had to un-static the font size variables. But we're still "saving" so far today :-)
On 31 July 2015 12:38:40 Damian Axford <dam...@axford.me.uk> wrote:
have merged DifferentialStepper into the master branch - still standalone, subject to more testing. I've also added a basic example for DifferentialStepper, it'll show up in the Arduino IDE under examples.Rob - the namespace stuff has now hidden fontsize :( would be fun if that can be exposed, with a suitable command to alter it :)
bot.setBumperCallback(handleCollision)
...
static void handleCollision(byte collisionData)
{
....
Rob.
--
You received this message because you are subscribed to a topic in the Google Groups "swindon-hackspace" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/swindon-hackspace/IRnBNd07Qp4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to swindon-hacksp...@googlegroups.com.
You received this message because you are subscribed to the Google Groups "swindon-hackspace" group.
To unsubscribe from this group and stop receiving emails from it, send an email to swindon-hacksp...@googlegroups.com.
Yeah, I think something like that is probably the way to go. The only pity about that is that you need more variables to hold parameters, but hopefully it shouldn't hurt memory too much.
For now (post discussion with Damian) I've merged that branch but will update it to move the pin definitions out of the library at some point and into some kind of config.h that lives in the sketch folder.
Rob.
--
You received this message because you are subscribed to a topic in the Google Groups "swindon-hackspace" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/swindon-hackspace/IRnBNd07Qp4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to swindon-hacksp...@googlegroups.com.
Nice much better with driveTo and arcto in the bot and not needing to push back onto the queue.
Ill have a go with it tonight
and see how it works.
and now added look-ahead queueing
up-next: acceleration planning :)
Yes, I thought it seemed too simple, but it appears to work. It struggles for traction a bit when the circle size means one wheel is moving slowly, but apart from that it's pretty good.
On 9 August 2015 1:25:16 pm Damian Axford <dam...@axford.me.uk> wrote:
nice one! looks surprisingly simple :)
--
Could do, just implement a LogobotTextCurvy class with the same interface and make them interchangeable. I suspect it might be more error prone that straight lines and turns, but you never know until you try!
On 9 August 2015 13:35:14 Damian Axford <dam...@axford.me.uk> wrote:
and start converting letters to use arcTo - they'll look nicer, write faster and take less program space :)
--
What's left todo for Bristol... ?
Just make more of them?
Flyer also good plan... Might bring a printed copy of the assembly guide and wiring diagram... Perhaps a bunch of the pieces for people to fiddle with
Bot variants - in an ideal world we will have:
1) wifi scribbler
2) basic bot with bumpers, maybe a few of these in diff colours
3) line follower
4) ultrasonic follower
Will try and get a line follower working this week, then ultrasonic can be next week - needs 5v though. Want to try doing an ultrasonic variant? I've got a spare module...
There's also the LED to integrate somehow