-
Notifications
You must be signed in to change notification settings - Fork 94
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
Implement Goto Node, Extract Leaf Node from Action Node, CheckPoint Node is a Leaf #622
base: develop
Are you sure you want to change the base?
Conversation
d65f7d1
to
25c8bc9
Compare
import us.ihmc.tools.io.WorkspaceResourceDirectory; | ||
|
||
public class RDXCheckPointNode extends RDXActionNode<CheckPointNodeState, CheckPointNodeDefinition> | ||
public class RDXCheckPointNode extends RDXLeafNode<CheckPointNodeState, CheckPointNodeDefinition> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Checkpoint extends leaf (I wish checkpoint was spelled as one word, but whatever)
@@ -159,7 +159,7 @@ public void render3DPanelImGuiOverlays() | |||
{ | |||
if (isMouseHovering) | |||
{ | |||
tooltip.render("%s Action\nIndex: %d\nName: %s".formatted(getActionTypeTitle(), state.getActionIndex(), definition.getName())); | |||
tooltip.render("%s Action\nIndex: %d\nName: %s".formatted(getLeafTypeTitle(), state.getLeafIndex(), definition.getName())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Action -> Leaf almost everywhere
import us.ihmc.tools.io.WorkspaceResourceDirectory; | ||
|
||
public class RDXGotoNode extends RDXBehaviorTreeNode<GotoNodeState, GotoNodeDefinition> | ||
public class RDXGotoNode extends RDXLeafNode<GotoNodeState, GotoNodeDefinition> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Goto node is a leaf
|
||
/** | ||
* The UI representation of a robot behavior action. It provides a base | ||
* template for implementing an interactable action. | ||
*/ | ||
public abstract class RDXActionNode<S extends ActionNodeState<D>, | ||
D extends ActionNodeDefinition> | ||
extends RDXBehaviorTreeNode<S, D> | ||
extends RDXLeafNode<S, D> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actions are leaves
@@ -17,7 +17,7 @@ public class RDXActionProgressWidgetsManager | |||
{ | |||
private final ImGuiUniqueLabelMap labels = new ImGuiUniqueLabelMap(getClass()); | |||
private final ImGuiLabelledWidgetAligner widgetAligner = new ImGuiLabelledWidgetAligner(); | |||
private final SortedSet<RDXActionNode<?, ?>> sortedActionNodesToRender = new TreeSet<>(Comparator.comparingInt(node -> node.getState().getActionIndex())); | |||
private final SortedSet<RDXActionNode<?, ?>> sortedActionNodesToRender = new TreeSet<>(Comparator.comparingInt(node -> node.getState().getLeafIndex())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Progress widgets still only render actions, because leaves don't take time
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Root node (sequence) deals primarily with leaves, not actions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AI2R needs to be tested. I don't know how to do it. @LuigiPenco93?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we'd need a python example similar to what Dex has done for the scene graph
{ | ||
LogTools.warn("Actions failed, fallback actions are next for execution."); | ||
LogTools.warn("Leaves failed, fallback leaves are next for execution."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Leaves
subscriptionNode.setBehaviorTreeNodeStateMessage(gotoNodeStateMessage.getState()); | ||
subscriptionNode.setBehaviorTreeNodeDefinitionMessage(gotoNodeStateMessage.getDefinition().getDefinition()); | ||
subscriptionNode.setBehaviorTreeNodeStateMessage(gotoNodeStateMessage.getState().getState()); | ||
subscriptionNode.setBehaviorTreeNodeDefinitionMessage(gotoNodeStateMessage.getDefinition().getDefinition().getDefinition()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually don't know why these lines are here
private final CRDTBidirectionalBoolean gotoNext; | ||
private final CRDTBidirectionalLong gotoNodeID; | ||
/** We use this to save the goto node name to file instead of the number for human readability. */ | ||
private String gotoNodeName = GOTO_NEXT; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very similar implementation to executeAfter
@Override | ||
public void validateFields(List<LeafNodeState<?>> leafNodes) | ||
{ | ||
super.validateFields(leafNodes); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This validation step also validates the executeAfter fields
bool goto_next | ||
|
||
# The ID of the node to goto | ||
uint32 goto_node_id |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Goto node message fields
2a9af87
to
83069a8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Left a couple of thoughts
private final S state; | ||
private final D definition; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A whole bunch of classes that extend the RDXBehaviorTreeNode
and BehaviorTreeNodeExecutor
also store the state and definition, which they get from the super class... What about making the state and definition fields protected? Not in this PR though. Just a thought.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's actually a great idea, I'll add a JIRA ticket
// int j = i + 1; | ||
// for (; j < state.getActionChildren().size() | ||
// && state.getActionChildren().get(j).calculateExecuteAfterActionIndex(state.getActionChildren()) < i; j++); | ||
// for (; j < state.getLeafChildren().size() | ||
// && state.getLeafChildren().get(j).calculateExecuteAfterLeafIndex(state.getLeafChildren()) < i; j++); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason to keep this commented code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
this.leafIndex = leafIndex; | ||
} | ||
|
||
public int getLeafIndex() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs javadoc, I wouldn't have any clue what a leaf index is from this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added doc
return isExecuting.getValue(); | ||
} | ||
|
||
public int calculateExecuteAfterLeafIndex() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs javadoc, what does this mean and when do you call it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added doc and changed to getExecuteAfterLeafIndex. I named it calculate to warn that it's not a basic getter, but I don't want to cache the calculation
return leafIndex - 1; // previous | ||
} | ||
|
||
public LeafNodeState<?> findExecuteAfterLeaf() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs javadoc, what does this mean and when do you call it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added doc and changed to getExecuteAfterLeaf. I named it find to warn that it's not a basic getter, but I don't want to cache the calculation
this.state = state; | ||
} | ||
|
||
public String getCantExecuteMessage() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getCantExecuteMessage()
-> getExecuteFailureMessage()
or something
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a message to print when the canExecute pre-condition is false (i.e. the action is not valid to even attempt execution) I've added doc.
private final ImGuiFlashingColors isExecutingFlashingColor = new ImGuiFlashingColors(0.1, ImGuiTools.PURPLE, ImGuiTools.DARK_PURPLE); | ||
private final ImGuiHollowArrowRenderer hollowArrowRenderer = new ImGuiHollowArrowRenderer(); | ||
private final ImGuiFlashingText flashingDescriptionColor = new ImGuiFlashingText(ImGuiTools.RED); | ||
private boolean wasFailed = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a comment about what wasFailed
represents? e.g. Used in update() for sending notifications
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@@ -92,24 +97,24 @@ public void fromMessage(BehaviorTreeRootNodeStateMessage message) | |||
} | |||
|
|||
@Nullable | |||
public <T extends ActionNodeState<?>> T findNextPreviousAction(Class<T> actionClass, int queryIndex, @Nullable RobotSide side) | |||
public <T extends LeafNodeState<?>> T findNextPreviousLeaf(Class<T> leafClass, int queryIndex, @Nullable RobotSide side) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Out of scope for this PR but I still really do not like the name findNextPreviousLeaf
8eeaf8e
to
a3d3d16
Compare
…d implement most of goto node.
a3d3d16
to
ab7c8e8
Compare
No description provided.