Skip to content

Commit 9314cc6

Browse files
committed
Fix duplicated remapings on launch files for ROS2
1 parent aca2b50 commit 9314cc6

File tree

1 file changed

+20
-10
lines changed

1 file changed

+20
-10
lines changed

plugins/de.fraunhofer.ipa.rossystem.xtext/src/de/fraunhofer/ipa/rossystem/generator/LaunchFileCompiler_ROS2.xtend

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import ros.impl.ParameterBooleanImpl
2323
import ros.impl.ParameterSequenceImpl
2424
import ros.impl.ParameterStructImpl
2525
import ros.impl.ParameterStructMemberImpl
26+
import java.util.ArrayList
2627

2728
class LaunchFileCompiler_ROS2 {
2829

@@ -145,16 +146,10 @@ def generate_launch_description():
145146
var to_sub = new Object
146147
var to_srv = new Object
147148
var to_action = new Object
149+
var remapped_interfaces = new ArrayList
148150
149151
var rename = ""
150-
151-
for (interface : node.rosinterfaces){
152-
var origin = interface.reference.eCrossReferences.toString
153-
var origin_name = origin.substring(origin.indexOf("name: ") + 6, origin.lastIndexOf(")]"))
154-
if (interface.name !== origin_name){
155-
remap_str += "\t(\"" + origin_name + "\", \"" + interface.name + "\"),\n";
156-
}
157-
}
152+
158153
159154
for (connection : connections){
160155
var rosconnection = connection as RosSystemConnectionImpl
@@ -170,13 +165,15 @@ def generate_launch_description():
170165
if ( (interface as RosInterfaceImpl).reference.toString.contains("RosPublisherReferenceImpl")){
171166
if ((interface as RosInterfaceImpl).reference == from_pub){
172167
if ((from_pub as RosPublisherReferenceImpl).from.name != interface.name) {
168+
remapped_interfaces.add(interface)
173169
remap_str += "\t(\"" + (from_pub as RosPublisherReferenceImpl).from.name + "\", \"" + rename + "\"),\n";
174170
}
175171
}
176172
}
177173
if ( (interface as RosInterfaceImpl).reference.toString.contains("RosSubscriberReferenceImpl")){
178174
if ((interface as RosInterfaceImpl).reference == to_sub){
179175
if ((to_sub as RosSubscriberReferenceImpl).from.name != from_pub) {
176+
remapped_interfaces.add(interface)
180177
remap_str += "\t(\"" + (to_sub as RosSubscriberReferenceImpl).from.name + "\", \"" + rename + "\"),\n";
181178
}
182179
}
@@ -195,13 +192,15 @@ def generate_launch_description():
195192
if ( (interface as RosInterfaceImpl).reference.toString.contains("RosServiceServerReferenceImpl")){
196193
if ((interface as RosInterfaceImpl).reference == from_srv){
197194
if ((from_srv as RosServiceServerReferenceImpl).from.name != interface.name) {
195+
remapped_interfaces.add(interface)
198196
remap_str += "\t(\"" + (from_srv as RosServiceServerReferenceImpl).from.name + "\", \"" + rename + "\"),\n";
199197
}
200198
}
201199
}
202200
if ( (interface as RosInterfaceImpl).reference.toString.contains("RosServiceClientReferenceImpl")){
203201
if ((interface as RosInterfaceImpl).reference == to_srv){
204202
if ((to_srv as RosServiceClientReferenceImpl).from.name != from_srv) {
203+
remapped_interfaces.add(interface)
205204
remap_str += "\t(\"" + (to_srv as RosServiceClientReferenceImpl).from.name + "\", \"" + rename + "\"),\n";
206205
}
207206
}
@@ -220,21 +219,32 @@ def generate_launch_description():
220219
if ( (interface as RosInterfaceImpl).reference.toString.contains("RosActionServerReferenceImpl")){
221220
if ((interface as RosInterfaceImpl).reference == from_action){
222221
if ((from_action as RosActionServerReferenceImpl).from.name != interface.name) {
222+
remapped_interfaces.add(interface)
223223
remap_str += "\t(\"" + (from_action as RosActionServerReferenceImpl).from.name + "\", \"" + rename + "\"),\n";
224224
}
225225
}
226226
}
227227
if ( (interface as RosInterfaceImpl).reference.toString.contains("RosActionClientReferenceImpl")){
228228
if ((interface as RosInterfaceImpl).reference == to_action){
229229
if ((to_action as RosActionClientReferenceImpl).from.name != from_action) {
230+
remapped_interfaces.add(interface)
230231
remap_str += "\t(\"" + (to_action as RosActionClientReferenceImpl).from.name + "\", \"" + rename + "\"),\n";
231232
}
232233
}
233234
}
234235
}
235236
}
236-
// if ( con_publishers.contains(interface) ){
237-
// }
237+
238+
}
239+
240+
for (interface : node.rosinterfaces){
241+
if (!remapped_interfaces.contains(interface)){
242+
var origin = interface.reference.eCrossReferences.toString
243+
var origin_name = origin.substring(origin.indexOf("name: ") + 6, origin.lastIndexOf(")]"))
244+
if (interface.name !== origin_name){
245+
remap_str += "\t(\"" + origin_name + "\", \"" + interface.name + "\"),\n";
246+
}
247+
}
238248
}
239249
// for (rosPublisher : interfaces.toList) {
240250
// if (!((prefix(NS)+rosPublisher.name).equals(compile_topic_name(rosPublisher.publisher, NS)))) {

0 commit comments

Comments
 (0)