Merge "Bug 581597 - [Robotics, ROS2] Support callback groups"
diff --git a/plugins/bt/org.eclipse.papyrus.robotics.bt.animation.zmq/src/org/eclipse/papyrus/robotics/bt/animation/zmq/core/ZMQBTReader.java b/plugins/bt/org.eclipse.papyrus.robotics.bt.animation.zmq/src/org/eclipse/papyrus/robotics/bt/animation/zmq/core/ZMQBTReader.java
index 2749267..bb74b27 100644
--- a/plugins/bt/org.eclipse.papyrus.robotics.bt.animation.zmq/src/org/eclipse/papyrus/robotics/bt/animation/zmq/core/ZMQBTReader.java
+++ b/plugins/bt/org.eclipse.papyrus.robotics.bt.animation.zmq/src/org/eclipse/papyrus/robotics/bt/animation/zmq/core/ZMQBTReader.java
@@ -1,5 +1,5 @@
 /*****************************************************************************
- * Copyright (c) 2020 CEA LIST.
+ * Copyright (c) 2020, 2023 CEA LIST.
  *
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License 2.0
@@ -10,6 +10,7 @@
  *
  * Contributors:
  *  Matteo MORELLI (CEA LIST) <matteo.morelli@cea.fr> - Initial API and implementation
+ *  Matteo MORELLI (CEA LIST) <matteo.morelli@cea.fr> - Bug #581828
  *****************************************************************************/
 
 package org.eclipse.papyrus.robotics.bt.animation.zmq.core;
@@ -25,7 +26,7 @@
 
 	protected ZContext _context;
 	protected Socket   _treeReader;
-	protected String   BT_READER_TCP = "tcp://*:1667";
+	protected String   BT_READER_TCP = "tcp://*:2667";
 	protected int      BT_READER_TIMEOUT_SEC = 60;
 	byte[]             _treeInfo;
 
diff --git a/plugins/bt/org.eclipse.papyrus.robotics.bt.animation.zmq/src/org/eclipse/papyrus/robotics/bt/animation/zmq/core/ZMQBehaviorTreeAnimator.java b/plugins/bt/org.eclipse.papyrus.robotics.bt.animation.zmq/src/org/eclipse/papyrus/robotics/bt/animation/zmq/core/ZMQBehaviorTreeAnimator.java
index 538e99c..045d497 100644
--- a/plugins/bt/org.eclipse.papyrus.robotics.bt.animation.zmq/src/org/eclipse/papyrus/robotics/bt/animation/zmq/core/ZMQBehaviorTreeAnimator.java
+++ b/plugins/bt/org.eclipse.papyrus.robotics.bt.animation.zmq/src/org/eclipse/papyrus/robotics/bt/animation/zmq/core/ZMQBehaviorTreeAnimator.java
@@ -1,5 +1,5 @@
 /*****************************************************************************
- * Copyright (c) 2020 CEA LIST.
+ * Copyright (c) 2020, 2023 CEA LIST.
  *
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License 2.0
@@ -10,6 +10,7 @@
  *
  * Contributors:
  *  Matteo MORELLI (CEA LIST) <matteo.morelli@cea.fr> - Initial API and implementation
+ *  Matteo MORELLI (CEA LIST) <matteo.morelli@cea.fr> - Bug #581828
  *****************************************************************************/
 
 package org.eclipse.papyrus.robotics.bt.animation.zmq.core;
@@ -36,7 +37,7 @@
 	protected ZMQBTReader _treeReader;
 	protected Socket      _logSubscriber;
 	protected Poller      _poller;
-	protected String      BT_LOG_SUBSCRIBER_TCP = "tcp://*:1666";
+	protected String      BT_LOG_SUBSCRIBER_TCP = "tcp://*:2666";
 	protected ByteBuffer  bb;
 	protected static final AnimationKind[] aks = { AnimationKind.VISITED, AnimationKind.RUNNING, AnimationKind.SUCCESS, AnimationKind.FAILURE };
 	protected boolean _node_status_update_required = true;
diff --git a/plugins/ros2/org.eclipse.papyrus.robotics.ros2.codegen.cpp/src/org/eclipse/papyrus/robotics/ros2/codegen/cpp/skillrealization/CreateSkillRealizationCppCode.xtend b/plugins/ros2/org.eclipse.papyrus.robotics.ros2.codegen.cpp/src/org/eclipse/papyrus/robotics/ros2/codegen/cpp/skillrealization/CreateSkillRealizationCppCode.xtend
index 1d8c846..d0c3e95 100644
--- a/plugins/ros2/org.eclipse.papyrus.robotics.ros2.codegen.cpp/src/org/eclipse/papyrus/robotics/ros2/codegen/cpp/skillrealization/CreateSkillRealizationCppCode.xtend
+++ b/plugins/ros2/org.eclipse.papyrus.robotics.ros2.codegen.cpp/src/org/eclipse/papyrus/robotics/ros2/codegen/cpp/skillrealization/CreateSkillRealizationCppCode.xtend
@@ -10,6 +10,7 @@
  * Contributors:
  *  Matteo MORELLI (CEA LIST) <matteo.morelli@cea.fr> - Bug #566899
  *  Matteo MORELLI (CEA LIST) <matteo.morelli@cea.fr> - Bug #581690
+ *  Matteo MORELLI (CEA LIST) <matteo.morelli@cea.fr> - Bug #581812
  *
  *****************************************************************************/
 
@@ -26,6 +27,7 @@
 
 import static extension org.eclipse.papyrus.robotics.core.utils.InteractionUtils.*
 import static extension org.eclipse.papyrus.robotics.ros2.codegen.common.utils.SkillUtils.*
+import org.eclipse.papyrus.designer.languages.common.base.file.ProtSection
 
 /**
  * Create the C++ code of a skill realization executed
@@ -61,6 +63,9 @@
 		// Generated by Papyrus4Robotics
 		//
 
+		// «ProtSection.protSection("BtActionNode header files")»
+		// «ProtSection.protSection»
+		#include "bt_utils/generic_types_conversions.hpp"
 		«FOR tp : skill.uniqueSkillParameterTypes»
 			#include "«tp.ROS2TypeIncludePath»"
 		«ENDFOR»
@@ -81,6 +86,7 @@
 		  «IF !skill.ins.isNullOrEmpty»
 		  void on_tick() override
 		  {
+		  	// «ProtSection.protSection("BtActionNode on_tick()")»
 		    «FOR param : skill.ins»
 		    «param.type.getROS2TypeFromMsgName» «param.name»;
 		    getInput("«param.name»", «param.name»);
@@ -88,12 +94,14 @@
 		      goal_.«prop.name» = «param.name».«prop.name»;
 		    «ENDFOR»
 		  «ENDFOR»
+		  	// «ProtSection.protSection»
 		  }
 		  «ENDIF»
 
 		  «IF !skill.outs.isNullOrEmpty»
 		  BT::NodeStatus on_success() override
 		  {
+		  	// «ProtSection.protSection("BtActionNode on_success()")»
 		  	«FOR param : skill.outs»
 		  	«param.type.getROS2TypeFromMsgName» «param.name»;
 		  	«FOR prop : param.type.ownedAttributes»
@@ -102,10 +110,14 @@
 		  	setOutput("«param.name»", «param.name»);
 		  	«ENDFOR»
 		  	return BT::NodeStatus::SUCCESS;
+		  	«ProtSection.protSection»
 		  }
 		  «ENDIF»
 
-		  «createProvidedPortsMethod(skill)»
+		  «createProvidedPortsMethod(skill,true)»
+
+		// «ProtSection.protSection("- BtActionNode other class methods and attributes (if any)")»
+		// «ProtSection.protSection»
 		};
 
 		#include "behaviortree_cpp_v3/bt_factory.h"
@@ -125,6 +137,9 @@
 		// Generated by Papyrus4Robotics
 		//
 
+		// «ProtSection.protSection("BtConditionNode header files")»
+		// «ProtSection.protSection»
+		#include "bt_utils/generic_types_conversions.hpp"
 		«FOR tp : skill.uniqueSkillParameterTypes»
 			#include "«tp.ROS2TypeIncludePath»"
 		«ENDFOR»
@@ -145,6 +160,7 @@
 		  «IF !skill.ins.isNullOrEmpty»
 		  void on_tick() override
 		  {
+		  	// «ProtSection.protSection("BtConditionNode on_tick()")»
 		    «FOR param : skill.ins»
 		    «param.type.getROS2TypeFromMsgName» «param.name»;
 		    getInput("«param.name»", «param.name»);
@@ -152,6 +168,7 @@
 		      request_->«prop.name» = «param.name».«prop.name»;
 		    «ENDFOR»
 		  «ENDFOR»
+		  	// «ProtSection.protSection»
 		  }
 		  «ENDIF»
 
@@ -175,7 +192,10 @@
 		    return BT::NodeStatus::FAILURE;
 		  }
 
-		  «createProvidedPortsMethod(skill)»
+		  «createProvidedPortsMethod(skill,true)»
+
+		// «ProtSection.protSection("- BtConditionNode other class methods and attributes (if any)")»
+		// «ProtSection.protSection»
 		};
 
 		#include "behaviortree_cpp_v3/bt_factory.h"
@@ -196,13 +216,16 @@
 		// ...
 
 		#include <string>
+		// «ProtSection.protSection("ActionNodeBase header files")»
+		// «ProtSection.protSection»
 		#include "rclcpp/rclcpp.hpp"
+		#include "bt_utils/generic_types_conversions.hpp"
 		«FOR tp : skill.uniqueSkillParameterTypes»
 			#include "«tp.ROS2TypeIncludePath»"
 		«ENDFOR»
 		#include "behaviortree_cpp_v3/action_node.h"
 		
-		class «skill.name»Action : public BT::SyncActionNode
+		class «skill.name»Action : public BT::ActionNodeBase
 		{
 		
 		public:
@@ -210,14 +233,15 @@
 		  «skill.name»Action(
 		    const std::string& name,
 		    const BT::NodeConfiguration& config)
-		  : SyncActionNode(name, config)
+		  : ActionNodeBase(name, config)
 		  {
 		  }
 		
-		  «createProvidedPortsMethod(skill)»
+		  «createProvidedPortsMethod(skill,false)»
 		
 		  BT::NodeStatus tick() override
 		  {
+		  	// «ProtSection.protSection("ActionNodeBase tick()")»
 			«IF !skill.ins.isNullOrEmpty»
 			  // Read from input ports
 			  //
@@ -253,8 +277,12 @@
 				«ENDFOR»
 			«ENDIF»
 		  	return BT::NodeStatus::SUCCESS;
+		  	// «ProtSection.protSection»
 		  }
-		
+
+		// «ProtSection.protSection("- ActionNodeBase other class methods and attributes (if any)")»
+		// «ProtSection.protSection»
+
 		};
 		
 		#include "behaviortree_cpp_v3/bt_factory.h"
@@ -267,22 +295,21 @@
 		}
 	'''
 
-	static def createProvidedPortsMethod(SkillDefinition skill) '''
-		«IF !skill.ins.isNullOrEmpty || !skill.outs.isNullOrEmpty»
-			// «skill.name» has in/out parameters => must provide a providedPorts method
-			static BT::PortsList providedPorts()
-			{
-			  return providedBasicPorts(
-			  {
-			    «FOR param : skill.ins SEPARATOR ','»
-			      BT::InputPort<«param.type.getROS2TypeFromMsgName»>("«param.name»")
-			    «ENDFOR»
-			    «FOR param : skill.outs SEPARATOR ','»
-			      BT::OutputPort<«param.type.getROS2TypeFromMsgName»>("«param.name»")
-		        «ENDFOR»
-			  });
-			}
-		«ENDIF»
+	static def createProvidedPortsMethod(SkillDefinition skill, boolean need_basic_ports) '''
+		// «skill.name» has a constructor in the form (const std::string&, const NodeConfiguration&) => must provide a providedPorts method
+		static BT::PortsList providedPorts()
+		{
+		  return«IF need_basic_ports» providedBasicPorts(«ENDIF»
+		  {
+		  	«createPortConstructionCommands(skill)»
+		  }«IF need_basic_ports»)«ENDIF»;
+		}
+	'''
+
+    static def createPortConstructionCommands(SkillDefinition skill) '''
+		«FOR param : skill.ins + skill.outs SEPARATOR ','»
+		«IF skill.ins.contains(param)»BT::InputPort<«ELSE»BT::OutputPort<«ENDIF»«param.type.getROS2TypeFromMsgName»>("«param.name»")
+		«ENDFOR»
 	'''
 
 	static def genCode(IPFileSystemAccess fileAccess, Map<SkillDefinition, SkillSemantic> skdefToSemanticsMap, Map<Interface, String> serviceToNameMap) {
diff --git a/releng/org.eclipse.papyrus.robotics.ros2.feature/feature.xml b/releng/org.eclipse.papyrus.robotics.ros2.feature/feature.xml
index d52565d..5863aad 100644
--- a/releng/org.eclipse.papyrus.robotics.ros2.feature/feature.xml
+++ b/releng/org.eclipse.papyrus.robotics.ros2.feature/feature.xml
@@ -124,4 +124,11 @@
          version="0.0.0"
          unpack="false"/>
 
+   <plugin
+         id="org.eclipse.papyrus.robotics.ros2.library.nav2"
+         download-size="0"
+         install-size="0"
+         version="0.0.0"
+         unpack="false"/>
+
 </feature>