Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable local variables in sub-tree #706

Closed
galou opened this issue Nov 30, 2023 · 6 comments
Closed

Enable local variables in sub-tree #706

galou opened this issue Nov 30, 2023 · 6 comments
Assignees
Labels
enhancement New feature or request

Comments

@galou
Copy link
Contributor

galou commented Nov 30, 2023

As sub-trees get more complicated, I tend to always use _autoremap="true" rather than writing a long list of remappings. Even if I would be OK with not using _autoremap, I cannot ensure that other users of the sub-tree I write also avoid to use it.

Now, I have a case where I compute some small trajectories identified with a shared prefix and then combine them. I do not know in advance how many of these trajectories will be in the blackboard but what I know for sure is that I don't want to share these small trajectories with other calls to the sub-tree.

I see two solutions:

  • use a prefix to identify a local variable, e.g. local{var}
  • add an attribute to the BehaviorTree element to list the variables that should not be shared even if _autoremap is used. Not so nice, IMHO.

I can implement something but I'd like to have some guidance on what to implement.

@galou
Copy link
Contributor Author

galou commented Dec 1, 2023

My work-around is to create 2 BehaviorTree elements for each sub-tree, one being "private". For example:

<BehaviorTree ID="SaySomethingTwice"/>
  <Sequence>
    SubTree ID="SaySomethingTwiceImpl"
     _autoremap="false"
     message="{message}" />
  </Sequence>
</BehaviorTree>

<BehaviorTree ID="SaySomethingTwiceImpl"/>
  <Sequence>
   <SaySomething message="{message}" />
   <SaySomething message="{message}" />
  </Sequence>
</BehaviorTree>

@facontidavide
Copy link
Collaborator

facontidavide commented Dec 2, 2023

this seems like a very specific use case. I understand that in your case could be annoying, but it is hard for me to find an elegant solution.

The prefix is doable, but seems too specific.

What about excluding from auto-remapping all the port names that start with "_",

{public_port}
{_private_port}

This feels very familiar for people developing C++

@facontidavide facontidavide self-assigned this Dec 2, 2023
@facontidavide facontidavide added the enhancement New feature or request label Dec 2, 2023
@facontidavide
Copy link
Collaborator

What do you think?

@galou
Copy link
Contributor Author

galou commented Dec 6, 2023

This would be a useful addition that would help avoiding potential issues when using subtrees.

@facontidavide
Copy link
Collaborator

done

@galou
Copy link
Contributor Author

galou commented Dec 6, 2023

Woah, that was quick! Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants