diff --git a/packages/blocks/package.json b/packages/blocks/package.json index f337efeb..42a33fb4 100644 --- a/packages/blocks/package.json +++ b/packages/blocks/package.json @@ -1,6 +1,6 @@ { "name": "@viamrobotics/prime-blocks", - "version": "0.0.23", + "version": "0.0.24", "publishConfig": { "access": "public" }, diff --git a/packages/blocks/src/lib/slam-map-2d/color-map.ts b/packages/blocks/src/lib/slam-map-2d/color-map.ts index 76ece406..991dc532 100644 --- a/packages/blocks/src/lib/slam-map-2d/color-map.ts +++ b/packages/blocks/src/lib/slam-map-2d/color-map.ts @@ -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 @@ -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 @@ -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); }