roslaunch rosbridge_server rosbridge_websocket.launch```
ros_graph 下面看活跃topic/nodes:
![rosbridge.png](https://img.haomeiwen.com/i3869738/697c2f95c774f5c7.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
终端执行
rosrun beginner_tutorials my.py```
活跃topic/nodes只显示 rosapi rosbridge_websocket /listener_5051_1491309295491三个节点:
在开启workstation的Jrosbridge client之后的活跃rat_graph中topic/nodes展示如下图:
rosconnect终止client之后节点展示图:
rosdisconnect.png
测试speechCallbback(String):
- ros端启动小乌龟节点:
rosrun turtlesim turtlesim_node```
![turtlesim_node](https://img.haomeiwen.com/i3869738/34e84a686000f8ac.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
2. 在*client端*增加代码并执行:
Topic cmdVel = new Topic(ros,"/turtle1/cmd_vel","std_msgs/String");
VoiceNav twistSpe = new VoiceNav();
Twist twist = twistSpe.speechCallback("向右转,");
new Thread(){
public void run(){
while(true){
cmdVel.publish(twist);
try{
Thread.sleep(1000);
}catch(){ e.printStackTrace(); }
}
}
}.start();```
rat_graph展示如下图:
客户端与ros连接client_cmd_turtle下图证明,rosbridge跑通了
小乌龟跑起来了!!!
有ros.disconnect();会接着跟ros断连,所以没办法跟websocket连接,发送消息。所以小乌龟不运动。
网友评论