RobotWebTools / ros3djs

3D Visualization Library for use with the ROS JavaScript Libraries
https://robotwebtools.github.io/ros3djs
Other
360 stars 215 forks source link

Cannot assign to read only property 'quaternion' of object '#<OccupancyGrid>' #230

Closed LukasGombar closed 5 years ago

LukasGombar commented 6 years ago

I need to run map from mapping in 3D OccupancyGrid. I am trying to make run new version of builded ros3djs with my existing html code, previous version of ros3djs works without problem. I have an issue when loading occupancy grid for map, with error:

Ros3D.js:52482 Uncaught TypeError: Cannot assign to read only property 'quaternion' of object '#' at new OccupancyGrid (Ros3D.js:52482) at OccupancyGridClient.processMessage (Ros3D.js:52571) at Topic.EventEmitter.emit (roslib.js:329) at Ros.Topic._messageCallback (roslib.js:2473) at Ros.EventEmitter.emit (roslib.js:329) at handleMessage (roslib.js:2306) at HTMLImageElement.image.onload (roslib.js:3679) OccupancyGrid @ Ros3D.js:52482
  processMessage @ Ros3D.js:52571
  EventEmitter.emit @ roslib.js:329
  Topic._messageCallback @ roslib.js:2473
  EventEmitter.emit @ roslib.js:329
  handleMessage @ roslib.js:2306
  image.onload @ roslib.js:3679

Tested already from example with the same error at: https://github.com/RobotWebTools/ros3djs/blob/develop/examples/map.html

derme302 commented 6 years ago

src/navigation/OccupancyGrid.js

  this.quaternion = new THREE.Quaternion(
      message.info.origin.orientation.x,
      message.info.origin.orientation.y,
      message.info.origin.orientation.z,
      message.info.origin.orientation.w
  );

In r68 of THREE.js position, rotation, quaternion and scale properties were made immutable so you can't do this assignment after that version. A better approach would be:

 var q = new THREE.Quaternion(
    message.info.origin.orientation.x,
    message.info.origin.orientation.y,
    message.info.origin.orientation.z,
    message.info.origin.orientation.w
  );

  this.quaternion.copy(q);

The grid is still not rendering correctly, but it solves this specific error message.

LukasGombar commented 6 years ago

Thank you very much. That solved an issue. Now everything is working. I just changed this in ROS3D.js file directly.

Now I have question who can edit this in file directly on github branch?