Skip to content

Commit 0350682

Browse files
committed
fix issues on the launch file generator
1 parent 398cfc7 commit 0350682

File tree

2 files changed

+92
-108
lines changed

2 files changed

+92
-108
lines changed

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

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -239,26 +239,34 @@ RosParameters{
239239
return node_name;
240240
}
241241

242+
def prefix(String NS){
243+
if(NS===""){
244+
return NS
245+
} else {
246+
return NS+"/"
247+
}
248+
}
249+
242250
def compile_topic_name(Publisher publisher, String NS){
243-
return NS+"/"+publisher.name;
251+
return prefix(NS)+publisher.name;
244252
}
245253
def compile_topic_name(Subscriber subscriber, String NS){
246-
return NS+"/"+subscriber.name;
254+
return prefix(NS)+subscriber.name;
247255
}
248256
def compile_service_name(ServiceServer serviceserver, String NS){
249-
return NS+"/"+serviceserver.name;
257+
return prefix(NS)+serviceserver.name;
250258
}
251259
def compile_service_name(ServiceClient serviceclient, String NS){
252-
return NS+"/"+serviceclient.name;
260+
return prefix(NS)+serviceclient.name;
253261
}
254262
def compile_action_name(ActionServer actionserver, String NS){
255-
return NS+"/"+actionserver.name;
263+
return prefix(NS)+actionserver.name;
256264
}
257265
def compile_action_name(ActionClient actionclient, String NS){
258-
return NS+"/"+actionclient.name;
266+
return prefix(NS)+actionclient.name;
259267
}
260268
def compile_param_name(Parameter param, String NS){
261-
return NS+"/"+param.name;
269+
return prefix(NS)+param.name;
262270
}
263271

264272
def compile_rosparam_value(ParameterValue paramValue){

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

Lines changed: 77 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ class LaunchFileCompiler {
1616
ParameterValue ParamValue
1717
String str_output=""
1818
String tab_tmp=""
19+
String component_ns=""
1920

2021
List<Integer> sizes_list = new ArrayList<Integer>();
2122
List<EObject> param_list = new ArrayList<EObject>();
@@ -47,142 +48,114 @@ class LaunchFileCompiler {
4748
<param name="«ROSParameter.name»" value="«compile_param_value(ROSParameter.value)»"/>
4849
«ENDIF»
4950
«ENDFOR»
50-
«FOR component:system.rosComponent»
51+
«FOR component:system.rosComponent»«IF component.hasNS»«set_ns(component.get_ns)»«ELSE»«set_ns("")»«ENDIF»
5152
«FOR rosPublisher:component.rospublisher»
52-
«IF component.hasNS»
53-
«IF !rosPublisher.name.equals(compile_topic_name(rosPublisher.publisher,component.get_ns))»
54-
<remap from=«compile_topic_name(rosPublisher.publisher,component.get_ns)» to=«rosPublisher.name» />
55-
«ENDIF»
56-
«ENDIF»
53+
«IF component.hasNS»«IF !rosPublisher.name.equals(compile_topic_name(rosPublisher.publisher,component_ns))»
54+
<remap from=«compile_topic_name(rosPublisher.publisher,component_ns)» to=«rosPublisher.name» />
55+
«ENDIF»«ENDIF»
5756
«ENDFOR»
5857
«FOR rosSubscriber:component.rossubscriber»
59-
«IF component.hasNS»
60-
«IF !rosSubscriber.name.equals(compile_topic_name(rosSubscriber.subscriber,component.get_ns))»
61-
<remap from=«compile_topic_name(rosSubscriber.subscriber,component.get_ns)» to=«rosSubscriber.name» />
62-
«ENDIF»
63-
«ENDIF»
58+
«IF component.hasNS»«IF !rosSubscriber.name.equals(compile_topic_name(rosSubscriber.subscriber,component_ns))»
59+
<remap from=«compile_topic_name(rosSubscriber.subscriber,component_ns)» to=«rosSubscriber.name» />
60+
«ENDIF»«ENDIF»
6461
«ENDFOR»
6562
«FOR rosServiceServer:component.rosserviceserver»
66-
«IF component.hasNS»
67-
«IF !rosServiceServer.name.equals(compile_service_name(rosServiceServer.srvserver,component.get_ns))»
68-
<remap from=«compile_service_name(rosServiceServer.srvserver,component.get_ns)» to=«rosServiceServer.name» />
69-
«ENDIF»
70-
«ENDIF»
63+
«IF component.hasNS»«IF !rosServiceServer.name.equals(compile_service_name(rosServiceServer.srvserver,component_ns))»
64+
<remap from=«compile_service_name(rosServiceServer.srvserver,component_ns)» to=«rosServiceServer.name» />
65+
«ENDIF»«ENDIF»
7166
«ENDFOR»
7267
«FOR rosServiceClient:component.rosserviceclient»
73-
«IF component.hasNS»
74-
«IF !rosServiceClient.name.equals(compile_service_name(rosServiceClient.srvclient,component.get_ns))»
75-
<remap from=«compile_service_name(rosServiceClient.srvclient,component.get_ns)» to=«rosServiceClient.name» />
76-
«ENDIF»
77-
«ENDIF»
68+
«IF component.hasNS»«IF !rosServiceClient.name.equals(compile_service_name(rosServiceClient.srvclient,component_ns))»
69+
<remap from=«compile_service_name(rosServiceClient.srvclient,component_ns)» to=«rosServiceClient.name» />
70+
«ENDIF»«ENDIF»
7871
«ENDFOR»
7972
«FOR rosActionServer:component.rosactionserver»
80-
«IF component.hasNS»
81-
«IF !rosActionServer.name.equals(compile_action_name(rosActionServer.actserver,component.get_ns))»
82-
<remap from=«compile_action_name(rosActionServer.actserver,component.get_ns)» to=«rosActionServer.name» />
83-
«ENDIF»
84-
«ENDIF»
73+
«IF component.hasNS»«IF !rosActionServer.name.equals(compile_action_name(rosActionServer.actserver,component_ns))»
74+
<remap from=«compile_action_name(rosActionServer.actserver,component_ns)» to=«rosActionServer.name» />
75+
«ENDIF»«ENDIF»
8576
«ENDFOR»
8677
«FOR rosActionClient:component.rosactionclient»
87-
«IF component.hasNS»
88-
«IF !rosActionClient.name.equals(compile_action_name(rosActionClient.actclient,component.get_ns))»
89-
<remap from=«compile_action_name(rosActionClient.actclient,component.get_ns)» to=«rosActionClient.name» />
90-
«ENDIF»
91-
«ENDIF»
78+
«IF component.hasNS»«IF !rosActionClient.name.equals(compile_action_name(rosActionClient.actclient,component_ns))»
79+
<remap from=«compile_action_name(rosActionClient.actclient,component_ns)» to=«rosActionClient.name» />
80+
«ENDIF»«ENDIF»
9281
«ENDFOR»
9382
«ENDFOR»
94-
«FOR component:system.rosComponent»
9583

84+
85+
86+
«FOR component:system.rosComponent»
9687
<node pkg="«component.compile_pkg»«init_pkg»" type="«component.compile_art»«init_comp()»" name="«component.name»"«IF component.hasNS» ns="«component.get_ns»"«ENDIF» cwd="node" respawn="false" output="screen">«init_comp()»«init_pkg»
9788
«FOR rosPublisher:component.rospublisher»
89+
«IF !rosPublisher.name.equals(compile_topic_name(rosPublisher.publisher,component_ns))»
90+
<remap from="«rosPublisher.publisher.name»" to="«rosPublisher.name»" />
91+
«ENDIF»
9892
«FOR topicConnection:system.topicConnections»
9993
«IF topicConnection.from.contains(rosPublisher
100-
«IF component.hasNS»
101-
«IF !topicConnection.topicName.equals(compile_topic_name(rosPublisher.publisher,component.get_ns))»
102-
<remap from="«rosPublisher.publisher.name»" to="«topicConnection.topicName»" />
103-
«ENDIF»
104-
«ELSE»
105-
«IF !topicConnection.topicName.equals(rosPublisher.publisher.name
106-
<remap from="«rosPublisher.publisher.name»" to="«topicConnection.topicName»" />
107-
«ENDIF»
108-
«ENDIF»
94+
«IF !topicConnection.topicName.equals(rosPublisher.name
95+
<remap from="«rosPublisher.name»" to="«topicConnection.topicName»" />
96+
«ENDIF»
10997
«ENDIF»
11098
«ENDFOR»
11199
«ENDFOR»
112100
«FOR rosSubscriber:component.rossubscriber»
113-
«FOR topicConnection:system.topicConnections»
114-
«IF topicConnection.to.contains(rosSubscriber
115-
«IF component.hasNS»
116-
«IF !topicConnection.topicName.equals(compile_topic_name(rosSubscriber.subscriber,component.get_ns))»
117-
<remap from="«rosSubscriber.subscriber.name»" to="«topicConnection.topicName»" />
118-
«ENDIF»
119-
«ELSE»
120-
«IF !topicConnection.topicName.equals(rosSubscriber.subscriber.name
121-
<remap from="«rosSubscriber.subscriber.name»" to="«topicConnection.topicName»" />
122-
«ENDIF»
123-
«ENDIF»
101+
«IF !rosSubscriber.name.equals(compile_topic_name(rosSubscriber.subscriber,component_ns))»
102+
<remap from="«rosSubscriber.subscriber.name»" to="«rosSubscriber.name»" />
124103
«ENDIF»
125-
«ENDFOR»
104+
«FOR topicConnection:system.topicConnections»
105+
«IF topicConnection.from.contains(rosSubscriber
106+
«IF !topicConnection.topicName.equals(rosSubscriber.name
107+
<remap from="«rosSubscriber.name»" to="«topicConnection.topicName»" />
108+
«ENDIF»
109+
«ENDIF»
110+
«ENDFOR»
126111
«ENDFOR»
127112
«FOR rosServiceServer:component.rosserviceserver»
128-
«FOR serviceConnection:system.serviceConnections»
129-
«IF serviceConnection.from.contains(rosServiceServer
130-
«IF component.hasNS»
131-
«IF !serviceConnection.serviceName.equals(compile_service_name(rosServiceServer.srvserver,component.get_ns))»
132-
<remap from="«rosServiceServer.srvserver.name»" to="«serviceConnection.serviceName»" />
133-
«ENDIF»
134-
«ELSE»
135-
«IF !serviceConnection.serviceName.equals(rosServiceServer.srvserver.name
136-
<remap from="«rosServiceServer.srvserver.name»" to="«serviceConnection.serviceName»" />
137-
«ENDIF»
113+
«IF !rosServiceServer.name.equals(compile_service_name(rosServiceServer.srvserver,component_ns))»
114+
<remap from="«rosServiceServer.srvserver.name»" to="«rosServiceServer.name»" />
138115
«ENDIF»
139-
«ENDIF»
140-
«ENDFOR»
116+
«FOR topicConnection:system.topicConnections»
117+
«IF topicConnection.from.contains(rosServiceServer
118+
«IF !topicConnection.topicName.equals(rosServiceServer.name
119+
<remap from="«rosServiceServer.name»" to="«topicConnection.topicName»" />
120+
«ENDIF»
121+
«ENDIF»
122+
«ENDFOR»
141123
«ENDFOR»
142124
«FOR rosServiceClient:component.rosserviceclient»
143-
«FOR serviceConnection:system.serviceConnections»
144-
«IF serviceConnection.to.equals(rosServiceClient
145-
«IF component.hasNS»
146-
«IF !serviceConnection.serviceName.equals(compile_service_name(rosServiceClient.srvclient,component.get_ns))»
147-
<remap from="«rosServiceClient.srvclient.name»" to="«serviceConnection.serviceName»" />
148-
«ENDIF»
149-
«ELSE»
150-
«IF !serviceConnection.serviceName.equals(rosServiceClient.srvclient.name
151-
<remap from="«rosServiceClient.srvclient.name»" to="«serviceConnection.serviceName»" />
152-
«ENDIF»
153-
«ENDIF»
125+
«IF !rosServiceClient.name.equals(compile_service_name(rosServiceClient.srvclient,component_ns))»
126+
<remap from="«rosServiceClient.srvclient.name»" to="«rosServiceClient.name»" />
154127
«ENDIF»
155-
«ENDFOR»
128+
«FOR topicConnection:system.topicConnections»
129+
«IF topicConnection.from.contains(rosServiceClient
130+
«IF !topicConnection.topicName.equals(rosServiceClient.name
131+
<remap from="«rosServiceClient.name»" to="«topicConnection.topicName»" />
132+
«ENDIF»
133+
«ENDIF»
134+
«ENDFOR»
156135
«ENDFOR»
157136
«FOR rosActionServer:component.rosactionserver»
158-
«FOR actionConnection:system.actionConnections»
159-
«IF actionConnection.from.equals(rosActionServer
160-
«IF component.hasNS»
161-
«IF !actionConnection.actionName.equals(compile_action_name(rosActionServer.actserver,component.get_ns))»
162-
<remap from="«rosActionServer.actserver.name»" to="«actionConnection.actionName»" />
163-
«ENDIF»
164-
«ELSE»
165-
«IF !actionConnection.actionName.equals(rosActionServer.actserver.name
166-
<remap from="«rosActionServer.actserver.name»" to="«actionConnection.actionName»" />
167-
«ENDIF»
168-
«ENDIF»
137+
«IF !rosActionServer.name.equals(compile_action_name(rosActionServer.actserver,component_ns))»
138+
<remap from="«rosActionServer.actserver.name»" to="«rosActionServer.name»" />
169139
«ENDIF»
170-
«ENDFOR»
140+
«FOR topicConnection:system.topicConnections»
141+
«IF topicConnection.from.contains(rosActionServer
142+
«IF !topicConnection.topicName.equals(rosActionServer.name
143+
<remap from="«rosActionServer.name»" to="«topicConnection.topicName»" />
144+
«ENDIF»
145+
«ENDIF»
146+
«ENDFOR»
171147
«ENDFOR»
172148
«FOR rosActionClient:component.rosactionclient»
173-
«FOR actionConnection:system.actionConnections»
174-
«IF actionConnection.to.equals(rosActionClient
175-
«IF component.hasNS»
176-
«IF !actionConnection.actionName.equals(compile_action_name(rosActionClient.actclient,component.get_ns))»
177-
<remap from="«rosActionClient.actclient.name»" to="«actionConnection.actionName»" />
178-
«ENDIF»
179-
«ELSE»
180-
«IF !actionConnection.actionName.equals(rosActionClient.actclient.name
181-
<remap from="«rosActionClient.actclient.name»" to="«actionConnection.actionName»" />
182-
«ENDIF»
149+
«IF !rosActionClient.name.equals(compile_action_name(rosActionClient.actclient,component_ns))»
150+
<remap from="«rosActionClient.actclient.name»" to="«rosActionClient.name»" />
183151
«ENDIF»
184-
«ENDIF»
185-
«ENDFOR»
152+
«FOR topicConnection:system.topicConnections»
153+
«IF topicConnection.from.contains(rosActionClient
154+
«IF !topicConnection.topicName.equals(rosActionClient.name
155+
<remap from="«rosActionClient.name»" to="«topicConnection.topicName»" />
156+
«ENDIF»
157+
«ENDIF»
158+
«ENDFOR»
186159
«ENDFOR»
187160
«FOR rosParameter:component.rosparameter»
188161
«IF rosParameter.parameter.type.toString.contains("ParameterStructType")»«str_output=""»
@@ -202,6 +175,9 @@ class LaunchFileCompiler {
202175
</launch>
203176
'''
204177

178+
def set_ns(String ns){
179+
component_ns=ns;
180+
}
205181
def String compile_struct_param(List<EObject> paramMembers,Boolean sub){
206182
if (!sub){
207183
sizes_list.add(paramMembers.size);

0 commit comments

Comments
 (0)