Skip to content

Instantly share code, notes, and snippets.

@newcanopies
Last active May 27, 2021 19:43
Show Gist options
  • Save newcanopies/976387554fe2504e232b8e8efd18a42a to your computer and use it in GitHub Desktop.
Save newcanopies/976387554fe2504e232b8e8efd18a42a to your computer and use it in GitHub Desktop.
'use strict';
const express = require('express');
const app = express();
app.use(express.static('../examples/html'));
app.listen(3000);
console.log('The web server started on http://localhost:3000');
const rclnodejs = require('rclnodejs');
rclnodejs
.init()
.then(() => {
const node = rclnodejs.createNode('publisher_message_example_node');
const publisher = node.createPublisher(
'geometry_msgs/msg/PoseStamped',
// 'PoseStamped'
'/test_topic'
);
let count = 0;
setInterval(function () {
publisher.publish({
header: {
stamp: {
sec : 0,
nanosec : 100
},
frame_id : "map"
},
pose: {
position: {
x : 0.0,
y : 0.0,
z : 0.0
},
orientation: {
x : 0.0,
y : 0.0,
z : 0.0,
w : 1.0
}
}
});
console.log(`Publish ${++count} messages.`);
}, 1000);
rclnodejs.spin(node);
})
.catch((e) => {
console.log(e);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment