Publish a cmd_vel geometry msgs/twist from webserver over rosbridge to RVIZ
I am new to ROS and I am trying to publish a cmdvel geometrymsgs/twist from my Webserver and visualize it in RVIZ, so that I can see the robot moving.
I am running the ROS distro kinetic on a virtual machine with Ubuntu 16.04.6 LTS. And I built my webserver using nodejs.
I also already installed rosbridge on the VM and successfully launched it using:
$ roslaunch rosbridge_server rosbridge_websocket.launch
And with this cmd I successfully launch RVIZ version 1.12.17 (kinetic):
$ roslaunch franka_own_simulator demo.launch rviz_tutorial:=true
This is the code I implemented on my webserver:
var ros = new ROSLIB.Ros({
url: 'ws://192.168.59.130:9090'
})
ros.on('connection', () => {
console.log('connected to webserver')
})
ros.on('error', function(error) {
console.log('Error connecting to websocket server: ', error)
})
var cmdVel = new ROSLIB.Topic({
ros: ros,
name: '/cmd_vel',
messageType: 'geometry_msgs/Twist'
})
var twist = new ROSLIB.Message({
linear : {
x : 0.1,
y : 4.2,
z : 0.3
},
angular : {
x : -0.1,
y : -0.2,
z : -4.3
}
})
cmdVel.publish(twist)
console.log('message sent')
With this code I am able to connect to the rosbridge I launched on the VM and I am also able to echo the cmdVel message, on the VM, that was sent, using:
$ rostopic echo /cmd_vel
linear:
x: 0.1
y: 4.2
z: 0.3
angular:
x: -0.1
y: -0.2
z: -4.3
But the simulated robot in RVIZ doesn't move.
My Question now is: How am I able to subscribe RVIZ to this topic, so that I am able to steer the robot by sending messages from my webserver? Or am I just using the wrong topic?
I don't know if this is of relevance in order to help with my problem, but these are the active nodes on my VM:
$ rosnode list
/joint_state_publisher
/move_group
/robot_state_publisher
/rosapi
/rosbridge_websocket
/rosout
/rviz_ubuntu_6623_2637754878704116255
Asked by Qualityland on 2019-06-26 02:21:29 UTC
Comments