State machine initialization in XOD 0.18.1


#1

I have obstacle avoidance code that was working in 0.17.1, but in 0.18.1 during initialization, the motors & servo go spastic trying to process multiple values in quick succession. Once initialization is complete, the code seems to execute normally. The motor & servo nodes should not activate if a pulse is not fed into them and all was quiet during initialization in 0.17.1 XOD.

Here is the code I tested with:
obstacle-avoidance.xodball (57.4 KB)

The good news: This program had <100 Bytes of dynamic memory free in 0.17.1 & I could not add LCD nodes. In 0.18.1, I can add my LCD-init library to display forward distance on line1 & left/right distance on line2 and still have 939 Bytes free!


#2

Thanks for the report, I will investigate.


#3

Any update on this? I see 0.19.0 has same issue. I assume available time was dedicated to fixing variadic nodes…

I just tried from the browser IDE, copied code into Arduino IDE & downloaded…same result.


#4

Yeah, sorry for the delay. I was on vacation and the guys were very focused on 0.19.0. We’ll try to find the problem at the beginning of next week, before starting a new development sprint.


#5

No problem, I’m getting more than my money’s worth for support :slight_smile:

Mostly I wanted to make sure it hadn’t just been forgotten. I’d really like to use the latest version for my class, but they are already having trouble understanding code; they don’t need a bug like this to confuse them more :-(. The down-side of using beta software to teach a class… Still an awesome product that is much easier for them to understand than straight Arduino IDE!


#6

@gweimer I’ve carefully compared node evaluation order between 0.17 and 0.19 and found a critical bug introduced while switching to the optimized code generator:

Since 0.18 any defer-pulse node emits an extraneous pulse on boot. I think that is the problem you’ve stumbled upon.

Could you verify it is the root cause? To check it:

  • Generate C++ for your main-0 patch
  • Find evaluate function definition in the xod__core__defer_pulse namespace
  • Apply a change to the single line:
diff --git a/workspace/__lib__/xod/core/defer-pulse/patch.cpp b/workspace/__lib__/xod/core/defer-pulse/patch.cpp
index 62341a59..1ed690e7 100644
--- a/workspace/__lib__/xod/core/defer-pulse/patch.cpp
+++ b/workspace/__lib__/xod/core/defer-pulse/patch.cpp
@@ -6,7 +6,7 @@ struct State {
 void evaluate(Context ctx) {
     if (isInputDirty<input_IN>(ctx)) { // This happens only when all nodes are evaluated
         setTimeout(ctx, 0);
-    } else {
+    } else if (isTimedOut(ctx)) {
         emitValue<output_OUT>(ctx, true);
     }
 }

#7

That seems to be the issue. Motors & servo were quite during initialization with this change.


#8

Fixed in 0.19.2


#9

So sad…fix not really included…

void evaluate(Context ctx) {
    if (isInputDirty<input_IN>(ctx)) { // This happens only when all nodes are evaluated
        setTimeout(ctx, 0);
    } else {
        emitValue<output_OUT>(ctx, true);
    }
}

} // namespace xod__core__defer_pulse

#10

It should. I guess you have forked the xod/core unintentionally. Take a look at your workspace libraries (~/xod/__lib__) if the xod/core is here, just remove it and the system would use the core library bundled with IDE itself.


#11

Good call. That was the issue. I had updated range-finder code to return a big number if no ping returned (nothing in front of us) instead of the default to not change the output on error.

Startup is clean now. I’ll have to change my code to work with core or create a new library instead of changing core.


#12

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.