From 4272594ef9b33fa8007cf6aa11f8f317a0d74157 Mon Sep 17 00:00:00 2001 From: Josh Date: Mon, 22 Nov 2021 14:15:07 -0500 Subject: [PATCH] Fixes issue with saving behaviors that contain other behaviors --- package.xml | 6 ------ src/io/io_codegenerator.js | 13 +++++++++++-- src/ros/ros_actionclient.js | 2 -- src/ros/ros_publisher.js | 2 -- src/ros/ros_subscriber.js | 1 - 5 files changed, 11 insertions(+), 13 deletions(-) diff --git a/package.xml b/package.xml index 9296ddc..b51dcbe 100644 --- a/package.xml +++ b/package.xml @@ -30,8 +30,6 @@ libnss3-dev - genpy - flexbe_onboard flexbe_mirror flexbe_widget @@ -47,8 +45,4 @@ ament_cmake - - diff --git a/src/io/io_codegenerator.js b/src/io/io_codegenerator.js index e13507a..9436c4d 100644 --- a/src/io/io_codegenerator.js +++ b/src/io/io_codegenerator.js @@ -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"; @@ -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 = []; @@ -117,7 +126,7 @@ IO.CodeGenerator = new (function() { } contained_behaviors.sort(compareKey(be => be.getStatePath())); for (var i=0; i