Skip to content

Commit c1e4776

Browse files
Merge pull request #49 from mjyc/fix-nogoalidorheaderbug
Fix no goal_id bug and no header bug
2 parents 5a09fe4 + ae56e62 commit c1e4776

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

src/lib/ActionClient.js

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ const timeUtils = require('../utils/time_utils.js');
2121
const msgUtils = require('../utils/message_utils.js');
2222
const EventEmitter = require('events');
2323
let GoalID = null;
24+
let Header = null;
2425

2526
class ActionClient extends EventEmitter {
2627
constructor(options) {
@@ -30,6 +31,10 @@ class ActionClient extends EventEmitter {
3031
GoalID = msgUtils.requireMsgPackage('actionlib_msgs').msg.GoalID;
3132
}
3233

34+
if (Header === null) {
35+
Header = msgUtils.requireMsgPackage('std_msgs').msg.Header;
36+
}
37+
3338
this._actionType = options.type;
3439

3540
this._actionServer = options.actionServer;
@@ -103,17 +108,17 @@ class ActionClient extends EventEmitter {
103108

104109
sendGoal(goal) {
105110
if (!goal.goal_id) {
106-
goal.goal_id = {
107-
stamp: timeUtils.now(),
108-
id: this.generateGoalId()
109-
};
111+
goal.goal_id = new GoalID({
112+
stamp: timeUtils.now(),
113+
id: this.generateGoalId()
114+
});
110115
}
111116
if (!goal.header) {
112-
goal.header = {
113-
seq: this._goalSeqNum++,
114-
stamp: goal.goal_id.stamp,
115-
frame_id: 'auto-generated'
116-
};
117+
goal.header = new Header({
118+
seq: this._goalSeqNum++,
119+
stamp: goal.goal_id.stamp,
120+
frame_id: 'auto-generated'
121+
});
117122
}
118123
const goalId = goal.goal_id.id;
119124
this._goals[goalId] = goal;

0 commit comments

Comments
 (0)