Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use CBOR compression for PointCloud2 #239

Merged
merged 3 commits into from
Dec 5, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/sensors/PointCloud2.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ for(var i=0;i<64;i++){decode64.e[decode64.S.charAt(i)]=i;}
* * ros - the ROSLIB.Ros connection handle
* * topic - the marker topic to listen to (default: '/points')
* * tfClient - the TF client handle to use
* * compression (optional) - message compression (default: 'cbor')
* * rootObject (optional) - the root object to add this marker to use for the points.
* * max_pts (optional) - number of points to draw (default: 10000)
* * pointRatio (optional) - point subsampling ratio (default: 1, no subsampling)
Expand All @@ -60,6 +61,7 @@ ROS3D.PointCloud2 = function(options) {
options = options || {};
this.ros = options.ros;
this.topicName = options.topic || '/points';
this.compression = options.compression || 'cbor';
this.points = new ROS3D.Points(options);
this.rosTopic = undefined;
this.subscribe();
Expand All @@ -80,7 +82,8 @@ ROS3D.PointCloud2.prototype.subscribe = function(){
this.rosTopic = new ROSLIB.Topic({
ros : this.ros,
name : this.topicName,
messageType : 'sensor_msgs/PointCloud2'
messageType : 'sensor_msgs/PointCloud2',
compression: this.compression
});
this.rosTopic.subscribe(this.processMessage.bind(this));
};
Expand All @@ -93,7 +96,7 @@ ROS3D.PointCloud2.prototype.processMessage = function(msg){
var n, pointRatio = this.points.pointRatio;

if (msg.data.buffer) {
this.points.buffer = msg.data.buffer;
this.points.buffer.set(msg.data);
n = msg.height*msg.width / pointRatio;
} else {
n = decode64(msg.data, this.points.buffer, msg.point_step, pointRatio);
Expand Down