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

Web Proto Viewer: RangeFinder and Lidar #5628

Merged
merged 47 commits into from
Dec 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
f83d523
abstract camera
Nov 11, 2022
48ee281
buggy
Nov 11, 2022
cb7578c
advance but still buggy
Nov 11, 2022
d47f2c3
Merge branch 'feature-web-proto' into enhancement-display-camera
Nov 21, 2022
4204652
working frustum
Nov 29, 2022
ae74249
Merge branch 'feature-web-proto' into enhancement-display-camera
Nov 30, 2022
a26a10c
Merge branch 'feature-web-proto' into enhancement-display-camera
Nov 30, 2022
ad13b9c
always enable
Nov 30, 2022
d26b333
fix scrollbar and improve style
Nov 30, 2022
4315a6b
improvement (linescale + list of cameras)
Nov 30, 2022
9fd5707
enable and disable optional rendering
Nov 30, 2022
ca40d77
all parameters
Nov 30, 2022
1bd6c49
display correctly rows
Dec 1, 2022
8e07a39
Update toolbar.css
Dec 1, 2022
89ca908
style
Dec 1, 2022
68ebbfd
cleanup
Dec 1, 2022
1cfb7bc
Update ProtoCamera.proto
Dec 1, 2022
d685569
Update ProtoCamera.proto
Dec 1, 2022
d5bb2a5
Update resources/web/wwi/nodes/WbAbstractCamera.js
Dec 1, 2022
61a2aca
Update resources/web/wwi/nodes/WbCamera.js
Dec 1, 2022
abe8b24
change color
Dec 1, 2022
a165905
Merge branch 'feature-web-proto' into enhancement-display-camera
ad-daniel Dec 1, 2022
791b6b8
parent
Dec 1, 2022
07a9631
split in two methods
Dec 1, 2022
2afe108
Merge branch 'feature-web-proto' into enhancement-display-camera
Dec 1, 2022
b1185d1
click and co
Dec 1, 2022
8d43b63
rangefinder
Dec 1, 2022
b0efefd
sanitize abstract camera
Dec 1, 2022
83804e5
Revert "rangefinder"
Dec 2, 2022
f47631f
sanitize
Dec 2, 2022
f3b0c6c
renable hover correctly
Dec 2, 2022
4f50824
Revert "Revert "rangefinder""
Dec 2, 2022
a13a850
fix near sanitization
Dec 2, 2022
82fa96f
color
Dec 2, 2022
033e3f9
improve style
Dec 2, 2022
eebde50
correct color
Dec 2, 2022
a28172e
Merge branch 'enhancement-display-camera' into enhancement-display-ra…
Dec 2, 2022
a77f133
progress lidar
Dec 2, 2022
3ed76a2
fix conflicts
Dec 2, 2022
6edda44
progress
Dec 2, 2022
0d36573
progress
Dec 2, 2022
afe2934
Merge branch 'feature-web-proto' into enhancement-display-rangefinder
Dec 2, 2022
8abf7af
progress
Dec 2, 2022
73dba7f
progress
Dec 5, 2022
606e80a
Merge branch 'feature-web-proto' into enhancement-display-rangefinder
Dec 5, 2022
ad65155
finish lidar
Dec 5, 2022
2cd106b
const
Dec 5, 2022
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
4 changes: 3 additions & 1 deletion resources/web/wwi/FloatingProtoParameterWindow.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ import FloatingWindow from './FloatingWindow.js';
import {VRML} from './protoVisualizer/vrml_type.js';
import WbCamera from './nodes/WbCamera.js';
import WbHingeJoint from './nodes/WbHingeJoint.js';
import WbLidar from './nodes/WbLidar.js';
import WbWorld from './nodes/WbWorld.js';
import WbRangeFinder from './nodes/WbRangeFinder.js';

export default class FloatingProtoParameterWindow extends FloatingWindow {
#protoManager;
Expand Down Expand Up @@ -502,7 +504,7 @@ export default class FloatingProtoParameterWindow extends FloatingWindow {

for (const key of keys) {
const device = nodes.get(key);
if (device instanceof WbCamera) {
if (device instanceof WbCamera || device instanceof WbRangeFinder || device instanceof WbLidar) {
numberOfDevices++;

let div = document.createElement('div');
Expand Down
26 changes: 21 additions & 5 deletions resources/web/wwi/Parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -627,16 +627,32 @@ export default class Parser {
newNode = new WbInertialUnit(id, translation, scale, rotation, name === '' ? 'inertial unit' : name);
else if (node.tagName === 'LED')
newNode = new WbLed(id, translation, scale, rotation, name === '' ? 'led' : name);
else if (node.tagName === 'Lidar')
newNode = new WbLidar(id, translation, scale, rotation, name === '' ? 'lidar' : name);
else if (node.tagName === 'LightSensor')
else if (node.tagName === 'Lidar') {
const fieldOfView = parseFloat(getNodeAttribute(node, 'fieldOfView', Math.PI / 2));
const horizontalResolution = parseInt(getNodeAttribute(node, 'horizontalResolution', '512'));
const maxRange = parseFloat(getNodeAttribute(node, 'maxRange', '1'));
const minRange = parseFloat(getNodeAttribute(node, 'minRange', '0.01'));
const numberOfLayers = parseInt(getNodeAttribute(node, 'numberOfLayers', '4'));
const tiltAngle = parseFloat(getNodeAttribute(node, 'tiltAngle', '0'));
const verticalFieldOfView = parseFloat(getNodeAttribute(node, 'verticalFieldOfView', '0.2'));

newNode = new WbLidar(id, translation, scale, rotation, name === '' ? 'lidar' : name, fieldOfView, maxRange, minRange,
numberOfLayers, tiltAngle, verticalFieldOfView, horizontalResolution);
} else if (node.tagName === 'LightSensor')
newNode = new WbLightSensor(id, translation, scale, rotation, name === '' ? 'light sensor' : name);
else if (node.tagName === 'Pen')
newNode = new WbPen(id, translation, scale, rotation, name === '' ? 'pen' : name);
else if (node.tagName === 'Radar')
newNode = new WbRadar(id, translation, scale, rotation, name === '' ? 'radar' : name);
else if (node.tagName === 'RangeFinder')
newNode = new WbRangeFinder(id, translation, scale, rotation, name === '' ? 'range finder' : name);
else if (node.tagName === 'RangeFinder') {
const height = parseInt(getNodeAttribute(node, 'height', '64'));
const width = parseInt(getNodeAttribute(node, 'width', '64'));
const fieldOfView = parseFloat(getNodeAttribute(node, 'fieldOfView', M_PI_4));
const maxRange = parseFloat(getNodeAttribute(node, 'maxRange', '1'));
const minRange = parseFloat(getNodeAttribute(node, 'minRange', '0.01'));
newNode = new WbRangeFinder(id, translation, scale, rotation, name === '' ? 'range finder' : name, height, width,
fieldOfView, maxRange, minRange);
}
else if (node.tagName === 'Receiver')
newNode = new WbReceiver(id, translation, scale, rotation, name === '' ? 'receiver' : name);
else if (node.tagName === 'Speaker')
Expand Down
20 changes: 20 additions & 0 deletions resources/web/wwi/X3dScene.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import WbGroup from './nodes/WbGroup.js';
import WbImageTexture from './nodes/WbImageTexture.js';
import WbIndexedFaceSet from './nodes/WbIndexedFaceSet.js';
import WbIndexedLineSet from './nodes/WbIndexedLineSet.js';
import WbLidar from './nodes/WbLidar.js';
import WbLight from './nodes/WbLight.js';
import WbMaterial from './nodes/WbMaterial.js';
import WbMesh from './nodes/WbMesh.js';
Expand All @@ -37,6 +38,7 @@ import WbVector3 from './nodes/utils/WbVector3.js';
import WbNormal from './nodes/WbNormal.js';
import WbSpotLight from './nodes/WbSpotLight.js';
import WbDirectionalLight from './nodes/WbDirectionalLight.js';
import WbRangeFinder from './nodes/WbRangeFinder.js';

export default class X3dScene {
#loader;
Expand Down Expand Up @@ -394,6 +396,24 @@ export default class X3dScene {
object.far = parseFloat(pose[key]);
else if (key === 'near')
object.near = parseFloat(pose[key]);
} else if (object instanceof WbRangeFinder) {
if (key === 'maxRange')
object.maxRange = parseFloat(pose[key]);
else if (key === 'minRange')
object.minRange = parseFloat(pose[key]);
} else if (object instanceof WbLidar) {
if (key === 'maxRange')
object.maxRange = parseFloat(pose[key]);
else if (key === 'minRange')
object.minRange = parseFloat(pose[key]);
else if (key === 'horizontalResolution')
object.horizontalResolution = parseInt(pose[key]);
else if (key === 'numberOfLayers')
object.numberOfLayers = parseInt(pose[key]);
else if (key === 'tiltAngle')
object.tiltAngle = parseFloat(pose[key]);
else if (key === 'verticalFieldOfView')
object.verticalFieldOfView = parseFloat(pose[key]);
}

if (object instanceof WbLight) {
Expand Down
33 changes: 18 additions & 15 deletions resources/web/wwi/nodes/WbAbstractCamera.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {arrayXPointerFloat} from './utils/utils.js';
export default class WbAbstractCamera extends WbSolid {
#fieldOfView;
#height;
#isFrustumEnabled;
#width;
constructor(id, translation, scale, rotation, name, height, width, fieldOfView) {
super(id, translation, scale, rotation, name);
Expand All @@ -17,7 +16,7 @@ export default class WbAbstractCamera extends WbSolid {
this.#width = width;

this._isRangeFinder = false;
this.#isFrustumEnabled = false;
this._isFrustumEnabled = false;
this._charType = '';
}

Expand Down Expand Up @@ -73,34 +72,38 @@ export default class WbAbstractCamera extends WbSolid {
this._transform = _wr_transform_new();
_wr_transform_attach_child(this._transform, this._renderable);
_wr_transform_attach_child(this.wrenNode, this._transform);

this.#applyFrustumToWren();
this._applyFrustumToWren();
}

#applyFrustumToWren() {
_applyFrustumToWren() {
_wr_node_set_visible(this._transform, false);

_wr_static_mesh_delete(this._mesh);
this._mesh = undefined;

if (!this.#isFrustumEnabled)
if (!this._isFrustumEnabled)
return;

const frustumColor = [1, 0, 1];
let frustumColor;
if (this._charType === 'c')
frustumColor = [1, 0, 1];
else if (this._charType === 'r')
frustumColor = [1, 1, 0];

const frustumColorRgb = _wrjs_array3(frustumColor[0], frustumColor[1], frustumColor[2]);

_wr_phong_material_set_color(this._material, frustumColorRgb);

let drawFarPlane;
let f;
const n = this.minRange();
const n = this._minRange();
// if the far is set to 0 it means the far clipping plane is set to infinity
// so, the far distance of the colored frustum should be set arbitrarily
if (this._charType === 'c' && this.maxRange() === 0) {
if (this._charType === 'c' && this._maxRange() === 0) {
f = n + 2 * _wr_config_get_line_scale();
drawFarPlane = false;
} else {
f = this.maxRange();
f = this._maxRange();
drawFarPlane = true;
}

Expand Down Expand Up @@ -153,21 +156,21 @@ export default class WbAbstractCamera extends WbSolid {
_wr_node_set_visible(this._transform, true);
}

minRange() {
_minRange() {
}

maxRange() {
_maxRange() {
return 1.0;
}

_update() {
if (this.wrenObjectsCreatedCalled)
this.#applyFrustumToWren();
this._applyFrustumToWren();
}

applyOptionalRendering(enable) {
this.#isFrustumEnabled = enable;
this.#applyFrustumToWren();
this._isFrustumEnabled = enable;
this._applyFrustumToWren();
}

#addVertex(vertices, colors, vertex, color) {
Expand Down
4 changes: 2 additions & 2 deletions resources/web/wwi/nodes/WbCamera.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ export default class WbCamera extends WbAbstractCamera {
this._update();
}

minRange() {
_minRange() {
return this.#near;
}

maxRange() {
_maxRange() {
return this.#far;
}
}
Loading