Skip to content

Commit

Permalink
Fixes issue with saving behaviors that contain other behaviors
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshZ18 committed Nov 22, 2021
1 parent f4d0360 commit 4272594
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 13 deletions.
6 changes: 0 additions & 6 deletions package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@

<exec_depend>libnss3-dev</exec_depend>

<exec_depend>genpy</exec_depend>

<exec_depend>flexbe_onboard</exec_depend>
<exec_depend>flexbe_mirror</exec_depend>
<exec_depend>flexbe_widget</exec_depend>
Expand All @@ -47,8 +45,4 @@
<export>
<build_type>ament_cmake</build_type>
</export>

<!-- <export>
<build_type>ament_python</build_type>
</export> -->
</package>
13 changes: 11 additions & 2 deletions src/io/io_codegenerator.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,12 @@ IO.CodeGenerator = new (function() {
import_list.push("from " + imported_states[i].getStateImport() + " import " + imported_states[i].getStateClass()
+ " as " + imported_states[i].getStatePackage() + "__" + imported_states[i].getStateClass());
}
state_init_list.push(ws + ws + imported_states[i].getStateClass() + ".initialize_ros(node)")

if (!imported_states[i].getStateClass().includes("SM") &&
!state_init_list.includes(ws + ws + imported_states[i].getStateClass() + ".initialize_ros(node)")) {

state_init_list.push(ws + ws + imported_states[i].getStateClass() + ".initialize_ros(node)")
}
}
// put together
code += "from flexbe_core import Behavior, Autonomy, OperatableStateMachine, ConcurrencyContainer, PriorityContainer, Logger\n";
Expand Down Expand Up @@ -107,6 +112,10 @@ IO.CodeGenerator = new (function() {
code += ws+ws+ "PriorityContainer" + ".initialize_ros(node)" + "\n"
code += ws+ws+ "Logger" + ".initialize(node)" + "\n"
code += state_init_list.sort().join("\n");
code += "\n";

// Need to clear state_init_list in case of saving multiple times
state_init_list = []


var contained_behaviors = [];
Expand All @@ -117,7 +126,7 @@ IO.CodeGenerator = new (function() {
}
contained_behaviors.sort(compareKey(be => be.getStatePath()));
for (var i=0; i<contained_behaviors.length; ++i) {
code += ws+ws+"self.add_behavior(" + contained_behaviors[i].getStateClass() + ", '" + contained_behaviors[i].getStatePath().substr(1) + "')\n";
code += ws+ws+"self.add_behavior(" + contained_behaviors[i].getStateClass() + ", '" + contained_behaviors[i].getStatePath().substr(1) + "', node)\n";
}
code += "\n";
// manual
Expand Down
2 changes: 0 additions & 2 deletions src/ros/ros_actionclient.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ from rclpy.action import ActionClient
import sys
import importlib
import json
import genpy
import flexbe_core.message
import yaml
import rosidl_runtime_py.convert
import rosidl_runtime_py.set_message
Expand Down
2 changes: 0 additions & 2 deletions src/ros/ros_publisher.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ import os
import sys
import importlib
import json
import genpy
import flexbe_core.message
import yaml
import rosidl_runtime_py.set_message
Expand Down
1 change: 0 additions & 1 deletion src/ros/ros_subscriber.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import rclpy
import sys
import importlib
import json
import genpy
import rosidl_runtime_py.convert
import yaml
Expand Down

0 comments on commit 4272594

Please sign in to comment.