rclnodejs
Version:
ROS2.0 JavaScript client with Node.js
69 lines (58 loc) • 1.94 kB
JavaScript
// Copyright (c) 2025, The Robot Web Tools Contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
function generateAction(data) {
const actionInfo = data.actionInfo;
const className = `${actionInfo.pkgName}__${actionInfo.subFolder}__${actionInfo.interfaceName}`;
return `// This file is automatically generated by rclnodejs
//
// *** DO NOT EDIT directly
//
'use strict';
class ${className} {
static get Goal() {
return require('./${className}_Goal.js');
}
static get Result() {
return require('./${className}_Result.js');
}
static get Feedback() {
return require('./${className}_Feedback.js');
}
static get impl() {
return {
get SendGoalService() {
return require('./${className}_SendGoal.js');
},
get GetResultService() {
return require('./${className}_GetResult.js');
},
get FeedbackMessage() {
return require('./${className}_FeedbackMessage.js');
},
get CancelGoal() {
return require('../action_msgs/action_msgs__srv__CancelGoal.js');
},
get GoalStatusArray() {
return require('../action_msgs/action_msgs__msg__GoalStatusArray.js');
}
};
}
static type() {
return {pkgName: '${actionInfo.pkgName}', subFolder: '${actionInfo.subFolder}', interfaceName: '${actionInfo.interfaceName}'};
}
}
module.exports = ${className};
`;
}
module.exports = generateAction;