Skip to content

Commit

Permalink
RSDK-6218 - make postprocessed slam points the viam slam brand color …
Browse files Browse the repository at this point in the history
…"cyberpunk" (viamrobotics#461)
  • Loading branch information
kim-mishra authored Jan 11, 2024
1 parent 4ed3ebd commit 1537491
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/blocks/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@viamrobotics/prime-blocks",
"version": "0.0.23",
"version": "0.0.24",
"publishConfig": {
"access": "public"
},
Expand Down
23 changes: 21 additions & 2 deletions packages/blocks/src/lib/slam-map-2d/color-map.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as THREE from 'three';
import { theme } from '@viamrobotics/prime-core/theme';

/*
* this color map is greyscale. The color map is being used map probability values of a PCD
Expand All @@ -19,6 +20,9 @@ const colorMapGrey = [
].map(([red, green, blue]) =>
new THREE.Vector3(red, green, blue).multiplyScalar(1 / 255)
);
const USER_GENERATED_POINT_COLOR = new THREE.Color(
theme.extend.colors.cyberpunk
);

/*
* Find the desired color bucket for a given probability. This assumes the probability will be a value from 0 to 100
Expand All @@ -45,9 +49,24 @@ const colorBuckets = (probability: number): THREE.Vector3 => {
export const mapColorAttributeGrayscale = (colors: THREE.BufferAttribute) => {
for (let i = 0; i < colors.count; i += 1) {
/*
* Probability is currently assumed to be held in the rgb field of the PCD map, on a scale of 0 to 100.
* ticket to look into this further https://viam.atlassian.net/browse/RSDK-2605
* Probability is currently assumed to be held in the b part of the rgb field of the PCD map, on a scale of 0 to 100.
* ticket to look into this further https://viam.atlassian.net/browse/RSDK-2605.
*
* User generated points that have been added to the pcd are marked as such by putting 100% probability
* in the r part of the rgb field. If that has been set, we will draw the point in blue instead of mapping it to its
* corresponding shade of gray to signal it is a user generated point.
*/

if (colors.getX(i) === 1) {
colors.setXYZ(
i,
USER_GENERATED_POINT_COLOR.r,
USER_GENERATED_POINT_COLOR.g,
USER_GENERATED_POINT_COLOR.b
);
continue;
}

const colorMapPoint = colorBuckets(colors.getZ(i) * 10);
colors.setXYZ(i, colorMapPoint.x, colorMapPoint.y, colorMapPoint.z);
}
Expand Down

0 comments on commit 1537491

Please sign in to comment.