我在使用 ros3djs 和 rosbridge 时遇到了激光扫描显示问题。当我记录扫描的 bagfile 并在我的笔记本电脑上运行它时,我的浏览器完美地显示它,但是当我在我的 jetson (nvidia nx) 上尝试相同的代码时,浏览器上没有任何显示。我尝试通过创建一个简单的三个 JS 立方体来测试 ros3djs 中的 Three.js 和查看器并显示它。我在这里错过了什么?。
答案 0 :(得分:0)
我知道这可能有点晚了,但这里是让 LaserScan 在 ros3djs 中正常工作所需的步骤。
确保 rosbridge 服务器正在运行 (roslaunch rosbridge_server rosbridge_websocket.launch
)
确保 tf2_web_republisher 节点正在运行 (rosrun tf2_web_republisher tf2_web_republisher
)
当然还要确保您的 LaserScan 发布者正在运行,这取决于您的具体配置
您现在可以像这样在 roslibjs 和 ros3djs 中连接您的 TFClient 和 LaserScan 订阅者:
const ros = new ROSLIB.Ros({
url : 'ws://<your_address>:9090'
})
ros.on('connection', function() {
console.log('Connected to websocket server.');
})
ros.on('error', function(error) {
console.log('Error connecting to websocket server: ', error);
})
ros.on('close', function() {
console.log('Connection to websocket server closed.');
})
const viewer = new ROS3D.Viewer({
divID : 'scan',
width : 800,
height : 600,
background: '#444444',
antialias : true
})
const tfClient = new ROSLIB.TFClient({
ros : ros,
angularThres : 0.01,
transThres : 0.01,
rate : 10.0
})
const scanclient = new ROS3D.LaserScan({
ros: ros,
topic: '/scan',
tfClient: tfClient,
rootObject: viewer.scene,
material: { size: 0.05, color: 0xff00ff }
})