Skip to content
This repository was archived by the owner on Jan 14, 2023. It is now read-only.

Commit d91274e

Browse files
committed
added autogenrated message parameters for ROS action files
1 parent 13f3a6f commit d91274e

File tree

5 files changed

+149
-6
lines changed

5 files changed

+149
-6
lines changed

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

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@
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.ActionGoalGenerationTemplate;
28+
import org.ros.internal.message.action.ActionFeedbackGenerationTemplate;
29+
import org.ros.internal.message.action.ActionResultGenerationTemplate;
2730
import org.ros.internal.message.service.ServiceDefinitionFileProvider;
2831
import org.ros.internal.message.topic.TopicDefinitionFileProvider;
2932
import org.ros.message.MessageDeclaration;
@@ -46,6 +49,10 @@ public class GenerateInterfaces {
4649
private final ActionDefinitionFileProvider actionDefinitionFileProvider;
4750
private final MessageDefinitionProviderChain messageDefinitionProviderChain;
4851
private final MessageFactory messageFactory;
52+
private final ActionGoalGenerationTemplate actionGoalGenerationTemplate = new ActionGoalGenerationTemplate();
53+
private final ActionFeedbackGenerationTemplate actionFeedbackGenerationTemplate = new ActionFeedbackGenerationTemplate();
54+
private final ActionResultGenerationTemplate actionResultGenerationTemplate = new ActionResultGenerationTemplate();
55+
4956
static private final String ROS_PACKAGE_PATH = "ROS_PACKAGE_PATH";
5057

5158
public GenerateInterfaces() {
@@ -153,12 +160,18 @@ private void writeActionInterfaces(File outputDirectory, Collection<String> pack
153160
writeInterface(actionDeclaration, outputDirectory, false);
154161
List<String> goalResultAndFeedback = MessageDefinitionTupleParser.parse(definition, 3);
155162

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));
163+
MessageDeclaration goalDeclaration = MessageDeclaration.of(
164+
actionType.getType() + "Goal",
165+
actionGoalGenerationTemplate.applyTemplate(goalResultAndFeedback.get(0))
166+
);
167+
MessageDeclaration resultDeclaration = MessageDeclaration.of(
168+
actionType.getType() + "Result",
169+
actionResultGenerationTemplate.applyTemplate(goalResultAndFeedback.get(1))
170+
);
171+
MessageDeclaration feedbackDeclaration = MessageDeclaration.of(
172+
actionType.getType() + "Feedback",
173+
actionFeedbackGenerationTemplate.applyTemplate(goalResultAndFeedback.get(2))
174+
);
162175

163176
writeInterface(goalDeclaration, outputDirectory, true);
164177
writeInterface(resultDeclaration, outputDirectory, true);
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+
}
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+
/**
20+
* @author arne.peters@tum.de (Arne Peters)
21+
*/
22+
public class ActionFeedbackGenerationTemplate {
23+
24+
/**
25+
* @return returns this {@link Message} as a {@link RawMessage}
26+
*/
27+
public String applyTemplate(String messageSource) {
28+
return "# ====== DO NOT MODIFY! AUTOGENERATED FROM AN ACTION DEFINITION ======\n" +
29+
"\n" +
30+
"Header header\n" +
31+
"actionlib_msgs/GoalStatus status\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+
/**
20+
* @author arne.peters@tum.de (Arne Peters)
21+
*/
22+
public class ActionGoalGenerationTemplate {
23+
24+
/**
25+
* @return returns this {@link Message} as a {@link RawMessage}
26+
*/
27+
public String applyTemplate(String messageSource) {
28+
return "# ====== DO NOT MODIFY! AUTOGENERATED FROM AN ACTION DEFINITION ======\n" +
29+
"\n" +
30+
"Header header\n" +
31+
"actionlib_msgs/GoalID goal_id\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+
/**
20+
* @author arne.peters@tum.de (Arne Peters)
21+
*/
22+
public class ActionResultGenerationTemplate {
23+
24+
/**
25+
* @return returns this {@link Message} as a {@link RawMessage}
26+
*/
27+
public String applyTemplate(String messageSource) {
28+
return "# ====== DO NOT MODIFY! AUTOGENERATED FROM AN ACTION DEFINITION ======\n" +
29+
"\n" +
30+
"Header header\n" +
31+
"actionlib_msgs/GoalStatus status\n" +
32+
messageSource;
33+
}
34+
}

0 commit comments

Comments
 (0)