Skip to content

Commit fe41a5d

Browse files
author
Juan Ignacio Ubeira
authored
Merge pull request rosjava#70 from exo-core/action-generation
Action generation
2 parents 608812f + 5a2cdcb commit fe41a5d

8 files changed

+282
-6
lines changed

message_generation/src/main/java/org/ros/internal/message/GenerateInterfaces.java

Lines changed: 44 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@
2424
import org.ros.internal.message.definition.MessageDefinitionProviderChain;
2525
import org.ros.internal.message.definition.MessageDefinitionTupleParser;
2626
import org.ros.internal.message.action.ActionDefinitionFileProvider;
27+
import org.ros.internal.message.action.ActionGenerationTemplateActionGoal;
28+
import org.ros.internal.message.action.ActionGenerationTemplateActionResult;
29+
import org.ros.internal.message.action.ActionGenerationTemplateActionFeedback;
30+
import org.ros.internal.message.action.ActionGenerationTemplateGoal;
31+
import org.ros.internal.message.action.ActionGenerationTemplateResult;
32+
import org.ros.internal.message.action.ActionGenerationTemplateFeedback;
2733
import org.ros.internal.message.service.ServiceDefinitionFileProvider;
2834
import org.ros.internal.message.topic.TopicDefinitionFileProvider;
2935
import org.ros.message.MessageDeclaration;
@@ -46,6 +52,15 @@ public class GenerateInterfaces {
4652
private final ActionDefinitionFileProvider actionDefinitionFileProvider;
4753
private final MessageDefinitionProviderChain messageDefinitionProviderChain;
4854
private final MessageFactory messageFactory;
55+
56+
private final MessageGenerationTemplate actionGenerationTemplateGoal = new ActionGenerationTemplateGoal();
57+
private final MessageGenerationTemplate actionGenerationTemplateResult = new ActionGenerationTemplateResult();
58+
private final MessageGenerationTemplate actionGenerationTemplateFeedback = new ActionGenerationTemplateFeedback();
59+
60+
private final MessageGenerationTemplate actionGenerationTemplateActionGoal = new ActionGenerationTemplateActionGoal();
61+
private final MessageGenerationTemplate actionGenerationTemplateActionResult = new ActionGenerationTemplateActionResult();
62+
private final MessageGenerationTemplate actionGenerationTemplateActionFeedback = new ActionGenerationTemplateActionFeedback();
63+
4964
static private final String ROS_PACKAGE_PATH = "ROS_PACKAGE_PATH";
5065

5166
public GenerateInterfaces() {
@@ -153,16 +168,39 @@ private void writeActionInterfaces(File outputDirectory, Collection<String> pack
153168
writeInterface(actionDeclaration, outputDirectory, false);
154169
List<String> goalResultAndFeedback = MessageDefinitionTupleParser.parse(definition, 3);
155170

156-
MessageDeclaration goalDeclaration =
157-
MessageDeclaration.of(actionType.getType() + "Goal", goalResultAndFeedback.get(0));
158-
MessageDeclaration resultDeclaration =
159-
MessageDeclaration.of(actionType.getType() + "Result", goalResultAndFeedback.get(1));
160-
MessageDeclaration feedbackDeclaration =
161-
MessageDeclaration.of(actionType.getType() + "Feedback", goalResultAndFeedback.get(2));
171+
MessageDeclaration goalDeclaration = MessageDeclaration.of(
172+
actionType.getType() + "Goal",
173+
actionGenerationTemplateGoal.applyTemplate(goalResultAndFeedback.get(0))
174+
);
175+
MessageDeclaration resultDeclaration = MessageDeclaration.of(
176+
actionType.getType() + "Result",
177+
actionGenerationTemplateResult.applyTemplate(goalResultAndFeedback.get(1))
178+
);
179+
MessageDeclaration feedbackDeclaration = MessageDeclaration.of(
180+
actionType.getType() + "Feedback",
181+
actionGenerationTemplateFeedback.applyTemplate(goalResultAndFeedback.get(2))
182+
);
183+
184+
MessageDeclaration actionGoalDeclaration = MessageDeclaration.of(
185+
actionType.getType() + "ActionGoal",
186+
actionGenerationTemplateActionGoal.applyTemplate(actionType.getType())
187+
);
188+
MessageDeclaration actionResultDeclaration = MessageDeclaration.of(
189+
actionType.getType() + "ActionResult",
190+
actionGenerationTemplateActionResult.applyTemplate(actionType.getType())
191+
);
192+
MessageDeclaration actionFeedbackDeclaration = MessageDeclaration.of(
193+
actionType.getType() + "ActionFeedback",
194+
actionGenerationTemplateActionFeedback.applyTemplate(actionType.getType())
195+
);
162196

163197
writeInterface(goalDeclaration, outputDirectory, true);
164198
writeInterface(resultDeclaration, outputDirectory, true);
165199
writeInterface(feedbackDeclaration, outputDirectory, true);
200+
201+
writeInterface(actionGoalDeclaration, outputDirectory, true);
202+
writeInterface(actionResultDeclaration, outputDirectory, true);
203+
writeInterface(actionFeedbackDeclaration, outputDirectory, true);
166204
}
167205
}
168206

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* Copyright (C) 2012 Google Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
5+
* use this file except in compliance with the License. You may obtain a copy of
6+
* the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13+
* License for the specific language governing permissions and limitations under
14+
* the License.
15+
*/
16+
17+
package org.ros.internal.message;
18+
19+
/**
20+
* @author arne.peters@tum.de (Arne Peters)
21+
*/
22+
public interface MessageGenerationTemplate {
23+
24+
/**
25+
* @return returns this {@link Message} as a {@link RawMessage}
26+
*/
27+
public String applyTemplate(String messageSource);
28+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
* Copyright (C) 2012 Google Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
5+
* use this file except in compliance with the License. You may obtain a copy of
6+
* the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13+
* License for the specific language governing permissions and limitations under
14+
* the License.
15+
*/
16+
17+
package org.ros.internal.message.action;
18+
19+
import org.ros.internal.message.MessageGenerationTemplate;
20+
21+
/**
22+
* @author arne.peters@tum.de (Arne Peters)
23+
*/
24+
public class ActionGenerationTemplateActionFeedback implements MessageGenerationTemplate {
25+
26+
/**
27+
* @return returns this {@link Message} as a {@link RawMessage}
28+
*/
29+
public String applyTemplate(String messageSource) {
30+
return "# ====== DO NOT MODIFY! AUTOGENERATED FROM AN ACTION DEFINITION ======\n" +
31+
"\n" +
32+
"Header header\n" +
33+
"actionlib_msgs/GoalStatus status\n" +
34+
messageSource + "Feedback feedback";
35+
}
36+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
* Copyright (C) 2012 Google Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
5+
* use this file except in compliance with the License. You may obtain a copy of
6+
* the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13+
* License for the specific language governing permissions and limitations under
14+
* the License.
15+
*/
16+
17+
package org.ros.internal.message.action;
18+
19+
import org.ros.internal.message.MessageGenerationTemplate;
20+
21+
/**
22+
* @author arne.peters@tum.de (Arne Peters)
23+
*/
24+
public class ActionGenerationTemplateActionGoal implements MessageGenerationTemplate {
25+
26+
/**
27+
* @return returns this {@link Message} as a {@link RawMessage}
28+
*/
29+
public String applyTemplate(String messageSource) {
30+
return "# ====== DO NOT MODIFY! AUTOGENERATED FROM AN ACTION DEFINITION ======\n" +
31+
"\n" +
32+
"Header header\n" +
33+
"actionlib_msgs/GoalID goal_id\n" +
34+
messageSource + "Goal goal";
35+
}
36+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
* Copyright (C) 2012 Google Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
5+
* use this file except in compliance with the License. You may obtain a copy of
6+
* the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13+
* License for the specific language governing permissions and limitations under
14+
* the License.
15+
*/
16+
17+
package org.ros.internal.message.action;
18+
19+
import org.ros.internal.message.MessageGenerationTemplate;
20+
21+
/**
22+
* @author arne.peters@tum.de (Arne Peters)
23+
*/
24+
public class ActionGenerationTemplateActionResult implements MessageGenerationTemplate {
25+
26+
/**
27+
* @return returns this {@link Message} as a {@link RawMessage}
28+
*/
29+
public String applyTemplate(String messageSource) {
30+
return "# ====== DO NOT MODIFY! AUTOGENERATED FROM AN ACTION DEFINITION ======\n" +
31+
"\n" +
32+
"Header header\n" +
33+
"actionlib_msgs/GoalStatus status\n" +
34+
messageSource + "Result result";
35+
}
36+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
* Copyright (C) 2012 Google Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
5+
* use this file except in compliance with the License. You may obtain a copy of
6+
* the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13+
* License for the specific language governing permissions and limitations under
14+
* the License.
15+
*/
16+
17+
package org.ros.internal.message.action;
18+
19+
import org.ros.internal.message.MessageGenerationTemplate;
20+
21+
/**
22+
* @author arne.peters@tum.de (Arne Peters)
23+
*/
24+
public class ActionGenerationTemplateFeedback implements MessageGenerationTemplate {
25+
26+
/**
27+
* @return returns this {@link Message} as a {@link RawMessage}
28+
*/
29+
public String applyTemplate(String messageSource) {
30+
return "# ====== DO NOT MODIFY! AUTOGENERATED FROM AN ACTION DEFINITION ======\n" +
31+
"#feedback definition\n" +
32+
messageSource;
33+
}
34+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
* Copyright (C) 2012 Google Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
5+
* use this file except in compliance with the License. You may obtain a copy of
6+
* the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13+
* License for the specific language governing permissions and limitations under
14+
* the License.
15+
*/
16+
17+
package org.ros.internal.message.action;
18+
19+
import org.ros.internal.message.MessageGenerationTemplate;
20+
21+
/**
22+
* @author arne.peters@tum.de (Arne Peters)
23+
*/
24+
public class ActionGenerationTemplateGoal implements MessageGenerationTemplate {
25+
26+
/**
27+
* @return returns this {@link Message} as a {@link RawMessage}
28+
*/
29+
public String applyTemplate(String messageSource) {
30+
return "# ====== DO NOT MODIFY! AUTOGENERATED FROM AN ACTION DEFINITION ======\n" +
31+
"#goal definition" +
32+
messageSource;
33+
}
34+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
* Copyright (C) 2012 Google Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
5+
* use this file except in compliance with the License. You may obtain a copy of
6+
* the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13+
* License for the specific language governing permissions and limitations under
14+
* the License.
15+
*/
16+
17+
package org.ros.internal.message.action;
18+
19+
import org.ros.internal.message.MessageGenerationTemplate;
20+
21+
/**
22+
* @author arne.peters@tum.de (Arne Peters)
23+
*/
24+
public class ActionGenerationTemplateResult implements MessageGenerationTemplate {
25+
26+
/**
27+
* @return returns this {@link Message} as a {@link RawMessage}
28+
*/
29+
public String applyTemplate(String messageSource) {
30+
return "# ====== DO NOT MODIFY! AUTOGENERATED FROM AN ACTION DEFINITION ======\n" +
31+
"#result definition" +
32+
messageSource;
33+
}
34+
}

0 commit comments

Comments
 (0)