I am trying to send a Teleport absolute message to a turtle with roslibjs. This is my code
function publish() {
connect()
const cmdVel = new ROSLIB.Topic({
ros: ros,
name: "turtle1/teleport_absolute",
messageType: "turtle1/teleport_absolute"
});
const data = new ROSLIB.Message({
x : linear.x,
y : linear.y,
theta : 8
});
// publishes to the queue
cmdVel.publish(data);
}
but whenever I run the Publish function I get this error
publish: Cannot infer topic type for topic /tf2_web_republisher/goal as it is not yet advertised
I tried sending basic twist messages before this and they worked, they looked like this.
var cmdVel = new ROSLIB.Topic({
ros : ros,
name : '/cmd_vel',
messageType : 'geometry_msgs/Twist'
});
var twist = new ROSLIB.Message({
linear : {
x : 0.1,
y : 0.2,
z : 0.3
},
angular : {
x : -0.1,
y : -0.2,
z : -0.3
}
});
have tried running
function publish() {
connect()
const cmdVel = new ROSLIB.Topic({
ros: ros,
name: "turtle1/teleport_absolute",
messageType: "turtle1/teleport_absolute"
});
const data = new ROSLIB.Message({
x : linear.x,
y : linear.y,
theta : 8
});
// publishes to the queue
cmdVel.publish(data);
}
doesn't work
There is also very little good documentation on this subject so finding answers for things such as this is a problem.
When using the roslibjs
you need to pass both the topic name and the message type. And you had a typo where you set both the topic name and message type as the same.
It should be
const cmdVel = new ROSLIB.Topic({
ros: ros,
name: "turtle1/teleport_absolute",
messageType: "geometry_msgs/Twist"
});