OnExecute () not called :(

NodeCanvas Forums Support OnExecute () not called :(

Tagged: , ,

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #12859
    alexander wieser
    Participant

    Hey,

    I have stumbled upon an issue I can’t seem to be able to solve.

    This is my graph with an Idle state and the two relevant actions marked in red.
    2

    Each of those actions look like this. In essense, hooking up an event within OnInit(), executing the event within OnExecute() and finishing the task within the event handler.
    1

    Each of those marked actions work as expected when triggered individually multiple times.
    The problem surfaces when alternating between those two actions.
    As an example:

    1. Transition #1 => OnExecute() invoked
    2. Transition #1 => OnExecute() invoked
    3. Transition #1 => OnExecute() invoked
    4. Transition #2 => OnExecute() not invoked
    5. Transition #2 => OnExecute() invoked
    6. Transition #2 => OnExecute() invoked

    I have identified the part of the code which is responsible for not executing the OnExecute() method, but I have no clue why that is or how to fix it without additional insights about the framework.

    As can be seen below the reason why transition #4 is not executed is because the latch variable is set to true and escapes the function prematurely, thus not executing the OnExecute() method.
    3

    Any help is greatly appreciated.

    Regards
    Alexander

    Attachments:
    You must be logged in to view attached files.
    #12863
    zsoik
    Participant

    Not sure which kind of event handling you’re using, but do you unsubscribe from the events when the action is actually stopped? I had a similar oversight in our own codebase where I subscribed to events during initialization but forgot to unsubscribe when the action was over, so the events still called into the dormant action, causing funny side-effects.

    Edit: 1. You’re not supposed to call EndAction() before OnExecute() is called. So subscribing to events is best done in OnExecute() end then unsubscribe when the action finishes (OnStopped?). OnInit will AFAIR be called really early in the lifecycle of the action and it may be a good place to install handlers, but you have to be sure that the handlers only affect the action result state when the action is only actually executing.

    #12864
    alexander wieser
    Participant

    Hi there,

    thank you for the hint, it was exactly what happened. The events where caught by all tasks listening for them.
    Instead of attaching the event inside the OnExecute and detaching it afterwards we decided to use a different approach since this solution will still fail should two event tasks run asynchronously at the same time. We simply added a token to be passed along the event which the task can then use to identify itself as the originator and ignore all other events.

    Thank you very much 🙂
    4

    Alex

    Attachments:
    You must be logged in to view attached files.
Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.