Skip to content

Instantly share code, notes, and snippets.

@PeterJCLaw
Last active October 31, 2023 23:04
Show Gist options
  • Save PeterJCLaw/505d36575cddbd1cb1bc21adf489d3a1 to your computer and use it in GitHub Desktop.
Save PeterJCLaw/505d36575cddbd1cb1bc21adf489d3a1 to your computer and use it in GitHub Desktop.
Demo of Webots camera seeing through things it shouldn't
#VRML_SIM R2023b utf8
WorldInfo {
basicTimeStep 8
}
Viewpoint {
orientation -0.2641270273446244 0.34818045239496637 0.899448323138205 1.401293242155436
position 1.0361061693335043 -1.5840493074793125 1.7899999051922475
near 0.1
ambientOcclusionRadius 0.3
bloomThreshold 100
}
DEF SUN DirectionalLight {
castShadows TRUE
}
DEF AMBIENT Background {
skyColor [
0.4 0.4 0.4
]
luminosity 1.6
}
Robot {
translation 1.29725 0.34509 -0.0260195
rotation -1.7436613844064643e-05 -2.0996788542837743e-05 -0.9999999996275497 1.3860589059129724
children [
DEF SENSORS Pose {
children [
Camera {
translation -0.035 0 0.385
rotation -0.17338196964736508 0 0.9848546555716737 3.1415927
children [
Pose {
rotation 0.5773509358554485 0.5773509358554485 0.5773489358556708 2.0944
children [
Shape {
appearance PBRAppearance {
baseColor 0 0 0
}
geometry Cylinder {
height 0.01
radius 0.01
}
}
]
translationStep 0.001
}
Pose {
translation -0.02 0 0
children [
Shape {
appearance PBRAppearance {
baseColor 0.4 0.4 0.4
metalness 0
}
geometry Box {
size 0.03 0.03 0.03
}
}
]
}
]
fieldOfView 0.82
width 800
height 600
recognition Recognition {
maxRange 6
frameThickness 2
}
}
]
}
]
name "Robot0"
model "Robot0"
controller "camera_controller"
}
Solid {
translation 0 0 -0.002
children [
DEF FLOOR Shape {
appearance PBRAppearance {
roughness 1
metalness 0
}
geometry Plane {
size 5.75 5.75
}
}
]
name "Floor"
boundingObject USE FLOOR
locked TRUE
}
Group {
children [
Solid {
translation 1.2143198769251295 1.1778199976664312 0.0878352146946657
rotation 6.3022763113608605e-06 -1.2241137092569007e-05 0.999999999905218 1.5777120157401547
children [
Shape {
appearance DEF TOKEN_APPEARANCE PBRAppearance {
baseColor 0.7 0.55 0.35
roughness 1
metalness 0
}
geometry DEF TOKEN_GEOMETRY Box {
size 0.13 0.13 0.13
}
}
Solid {
translation 0.0651 0 0
rotation 0 0 1 3.1416
children [
Shape {
appearance PBRAppearance {
baseColorMap ImageTexture {
repeatS FALSE
repeatT FALSE
}
roughness 1
metalness 0
}
geometry DEF MARKER_GEOMETRY Box {
size 0.0001 0.08 0.08
}
}
]
name "front"
model "F196"
locked TRUE
recognitionColors [
1 1 1
]
}
Solid {
translation -0.0651 0 0
rotation 0 1 0 0
children [
Shape {
appearance PBRAppearance {
baseColorMap ImageTexture {
repeatS FALSE
repeatT FALSE
}
roughness 1
metalness 0
}
geometry DEF MARKER_GEOMETRY Box {
size 0.0001 0.08 0.08
}
}
]
name "back"
model "F196"
locked TRUE
recognitionColors [
1 1 1
]
}
Solid {
translation 0 0.0651 0
rotation 0 0 1 -1.5708
children [
Shape {
appearance PBRAppearance {
baseColorMap ImageTexture {
repeatS FALSE
repeatT FALSE
}
roughness 1
metalness 0
}
geometry DEF MARKER_GEOMETRY Box {
size 0.0001 0.08 0.08
}
}
]
name "side-1"
model "F196"
locked TRUE
recognitionColors [
1 1 1
]
}
Solid {
translation 0 -0.0651 0
rotation 0 0 1 1.5708
children [
Shape {
appearance PBRAppearance {
baseColorMap ImageTexture {
repeatS FALSE
repeatT FALSE
}
roughness 1
metalness 0
}
geometry DEF MARKER_GEOMETRY Box {
size 0.0001 0.08 0.08
}
}
]
name "side-2"
model "F196"
locked TRUE
recognitionColors [
1 1 1
]
}
Solid {
translation 0 0 0.0651
rotation 0 1 0 1.5708
children [
Shape {
appearance PBRAppearance {
baseColorMap ImageTexture {
repeatS FALSE
repeatT FALSE
}
roughness 1
metalness 0
}
geometry DEF MARKER_GEOMETRY Box {
size 0.0001 0.08 0.08
}
}
]
name "top"
model "F196"
locked TRUE
recognitionColors [
1 1 1
]
}
Solid {
translation 0 0 -0.0651
rotation 0 1 0 -1.5708
children [
Shape {
appearance PBRAppearance {
baseColorMap ImageTexture {
repeatS FALSE
repeatT FALSE
}
roughness 1
metalness 0
}
geometry DEF MARKER_GEOMETRY Box {
size 0.0001 0.08 0.08
}
}
]
name "bottom"
model "F196"
locked TRUE
recognitionColors [
1 1 1
]
}
]
name "B0"
model "B0"
boundingObject USE TOKEN_GEOMETRY
physics Physics {
density -1
mass 0.08
}
}
Solid {
translation 0.8445365383687449 1.1547679308931018 0.06298430394500423
rotation -3.0663789988474495e-06 2.1252301879482833e-05 0.9999999997694685 -2.559080000350197
children [
Shape {
appearance DEF TOKEN_APPEARANCE PBRAppearance {
baseColor 0.7 0.55 0.35
roughness 1
metalness 0
}
geometry DEF TOKEN_GEOMETRY Box {
size 0.13 0.13 0.13
}
}
Solid {
translation 0.0651 0 0
rotation 0 0 1 3.1416
children [
Shape {
appearance PBRAppearance {
baseColorMap ImageTexture {
repeatS FALSE
repeatT FALSE
}
roughness 1
metalness 0
}
geometry DEF MARKER_GEOMETRY Box {
size 0.0001 0.08 0.08
}
}
]
name "front"
model "F196"
locked TRUE
recognitionColors [
1 1 1
]
}
Solid {
translation -0.0651 0 0
rotation 0 1 0 0
children [
Shape {
appearance PBRAppearance {
baseColorMap ImageTexture {
repeatS FALSE
repeatT FALSE
}
roughness 1
metalness 0
}
geometry DEF MARKER_GEOMETRY Box {
size 0.0001 0.08 0.08
}
}
]
name "back"
model "F196"
locked TRUE
recognitionColors [
1 1 1
]
}
Solid {
translation 0 0.0651 0
rotation 0 0 1 -1.5708
children [
Shape {
appearance PBRAppearance {
baseColorMap ImageTexture {
repeatS FALSE
repeatT FALSE
}
roughness 1
metalness 0
}
geometry DEF MARKER_GEOMETRY Box {
size 0.0001 0.08 0.08
}
}
]
name "side-1"
model "F196"
locked TRUE
recognitionColors [
1 1 1
]
}
Solid {
translation 0 -0.0651 0
rotation 0 0 1 1.5708
children [
Shape {
appearance PBRAppearance {
baseColorMap ImageTexture {
repeatS FALSE
repeatT FALSE
}
roughness 1
metalness 0
}
geometry DEF MARKER_GEOMETRY Box {
size 0.0001 0.08 0.08
}
}
]
name "side-2"
model "F196"
locked TRUE
recognitionColors [
1 1 1
]
}
Solid {
translation 0 0 0.0651
rotation 0 1 0 1.5708
children [
Shape {
appearance PBRAppearance {
baseColorMap ImageTexture {
repeatS FALSE
repeatT FALSE
}
roughness 1
metalness 0
}
geometry DEF MARKER_GEOMETRY Box {
size 0.0001 0.08 0.08
}
}
]
name "top"
model "F196"
locked TRUE
recognitionColors [
1 1 1
]
}
Solid {
translation 0 0 -0.0651
rotation 0 1 0 -1.5708
children [
Shape {
appearance PBRAppearance {
baseColorMap ImageTexture {
repeatS FALSE
repeatT FALSE
}
roughness 1
metalness 0
}
geometry DEF MARKER_GEOMETRY Box {
size 0.0001 0.08 0.08
}
}
]
name "bottom"
model "F196"
locked TRUE
recognitionColors [
1 1 1
]
}
]
name "B1"
model "B1"
boundingObject USE TOKEN_GEOMETRY
physics Physics {
density -1
mass 0.08
}
}
Solid {
translation 0.8352153323009494 1.1748505916897845 0.1929752178201825
rotation -4.139954330355539e-05 -5.877156114115346e-05 -0.9999999974159908 1.0287399991566908
children [
Shape {
appearance DEF TOKEN_APPEARANCE PBRAppearance {
baseColor 0.7 0.55 0.35
roughness 1
metalness 0
}
geometry DEF TOKEN_GEOMETRY Box {
size 0.13 0.13 0.13
}
}
]
name "B2"
model "B2"
boundingObject USE TOKEN_GEOMETRY
physics Physics {
density -1
mass 0.08
}
linearVelocity -5.955147705654288e-11 1.2543638434767214e-10 -1.5587531265737154e-14
angularVelocity -4.648648330179805e-13 -2.330482946661408e-13 6.255417376475778e-12
}
]
}
Solid {
translation 1.2579000550020905 1.2681500004388273 -0.022154997996183437
rotation -2.979878875475737e-06 -9.302472618658597e-06 0.9999999999522922 -3.134560915625277
children [
DEF BODY Group {
children [
DEF base Pose {
translation 0 0 0.0325
children [
Shape {
appearance DEF SPACESHIP_APPEARANCE PBRAppearance {
baseColor 0.55 0.55 0.55
roughness 1
metalness 0
}
geometry Box {
size 0.48 0.39 0.025
}
}
]
}
DEF side_rear Pose {
translation -0.23 0.01 0.1225
children [
Shape {
appearance USE SPACESHIP_APPEARANCE
geometry Box {
size 0.02 0.37 0.155
}
}
]
}
DEF side_front Pose {
translation 0.23 -0.01 0.1225
children [
Shape {
appearance USE SPACESHIP_APPEARANCE
geometry Box {
size 0.02 0.37 0.155
}
}
]
}
DEF side_left Pose {
translation 0.01 0.185 0.1225
children [
Shape {
appearance USE SPACESHIP_APPEARANCE
geometry Box {
size 0.46 0.02 0.155
}
}
]
}
DEF side_right Pose {
translation -0.01 -0.185 0.1225
children [
Shape {
appearance USE SPACESHIP_APPEARANCE
geometry Box {
size 0.46 0.02 0.155
}
}
]
}
]
}
DEF MARKERS Group {
children [
Solid {
translation 0 0.1955 0.11
rotation 0 0 1 -1.570796327
children [
Shape {
appearance PBRAppearance {
baseColorMap ImageTexture {
repeatS FALSE
repeatT FALSE
}
roughness 1
metalness 0
}
geometry DEF MARKER_GEOMETRY Box {
size 0.0001 0.08 0.08
}
}
]
name "port"
model "F123"
locked TRUE
recognitionColors [
1 1 1
]
}
Solid {
translation 0 -0.1955 0.11
rotation 0 0 1 1.570796327
children [
Shape {
appearance PBRAppearance {
baseColorMap ImageTexture {
repeatS FALSE
repeatT FALSE
}
roughness 1
metalness 0
}
geometry DEF MARKER_GEOMETRY Box {
size 0.0001 0.08 0.08
}
}
]
name "starboard"
model "F128"
locked TRUE
recognitionColors [
1 1 1
]
}
]
}
]
name "S3"
model "S3"
boundingObject USE BODY
physics Physics {
density -1
mass 1.5
}
}
#VRML_SIM R2023b utf8
WorldInfo {
basicTimeStep 8
}
Viewpoint {
orientation 0.2296018325931172 0.7665480157769128 -0.599739224978957 0.9263850560771569
position -1.430622273864786 1.744048522600751 2.5635138672086555
near 0.1
ambientOcclusionRadius 0.3
bloomThreshold 100
}
DEF SUN DirectionalLight {
castShadows TRUE
}
DEF AMBIENT Background {
skyColor [
0.4 0.4 0.4
]
luminosity 1.6
}
Robot {
translation 1.2959335227632733 0.2918454214546005 -0.02601948245036377
rotation -1.7436613844064643e-05 -2.0996788542837743e-05 -0.9999999996275497 1.3860589059129724
children [
DEF SENSORS Pose {
children [
Camera {
translation -0.035 0 0.385
rotation -0.17338196964736508 0 0.9848546555716737 3.1415927
children [
Pose {
rotation 0.5773509358554485 0.5773509358554485 0.5773489358556708 2.0944
children [
Shape {
appearance PBRAppearance {
baseColor 0 0 0
}
geometry Cylinder {
height 0.01
radius 0.01
}
}
]
translationStep 0.001
}
Pose {
translation -0.02 0 0
children [
Shape {
appearance PBRAppearance {
baseColor 0.4 0.4 0.4
metalness 0
}
geometry Box {
size 0.03 0.03 0.03
}
}
]
}
]
fieldOfView 0.82
width 800
height 600
recognition Recognition {
maxRange 6
frameThickness 2
}
}
]
}
]
name "Robot0"
model "Robot0"
controller "camera_controller"
}
Solid {
translation 0 0 -0.002
children [
DEF FLOOR Shape {
appearance PBRAppearance {
roughness 1
metalness 0
}
geometry Plane {
size 5.75 5.75
}
}
]
name "Floor"
boundingObject USE FLOOR
locked TRUE
}
Group {
children [
Solid {
translation 1.0047898086439029 0.9965309543603724 0.08783223142663012
rotation 4.945043300548798e-07 -2.0115084726581782e-05 0.9999999997975694 1.5777672161105476
children [
Shape {
appearance DEF TOKEN_APPEARANCE PBRAppearance {
baseColor 0.7 0.55 0.35
roughness 1
metalness 0
}
geometry DEF TOKEN_GEOMETRY Box {
size 0.13 0.13 0.13
}
}
Solid {
translation 0.0651 0 0
rotation 0 0 1 3.1416
children [
Shape {
appearance PBRAppearance {
baseColorMap ImageTexture {
repeatS FALSE
repeatT FALSE
}
roughness 1
metalness 0
}
geometry DEF MARKER_GEOMETRY Box {
size 0.0001 0.08 0.08
}
}
]
name "front"
model "F196"
locked TRUE
recognitionColors [
1 1 1
]
}
Solid {
translation -0.0651 0 0
rotation 0 1 0 0
children [
Shape {
appearance PBRAppearance {
baseColorMap ImageTexture {
repeatS FALSE
repeatT FALSE
}
roughness 1
metalness 0
}
geometry DEF MARKER_GEOMETRY Box {
size 0.0001 0.08 0.08
}
}
]
name "back"
model "F196"
locked TRUE
recognitionColors [
1 1 1
]
}
Solid {
translation 0 0.0651 0
rotation 0 0 1 -1.5708
children [
Shape {
appearance PBRAppearance {
baseColorMap ImageTexture {
repeatS FALSE
repeatT FALSE
}
roughness 1
metalness 0
}
geometry DEF MARKER_GEOMETRY Box {
size 0.0001 0.08 0.08
}
}
]
name "side-1"
model "F196"
locked TRUE
recognitionColors [
1 1 1
]
}
Solid {
translation 0 -0.0651 0
rotation 0 0 1 1.5708
children [
Shape {
appearance PBRAppearance {
baseColorMap ImageTexture {
repeatS FALSE
repeatT FALSE
}
roughness 1
metalness 0
}
geometry DEF MARKER_GEOMETRY Box {
size 0.0001 0.08 0.08
}
}
]
name "side-2"
model "F196"
locked TRUE
recognitionColors [
1 1 1
]
}
Solid {
translation 0 0 0.0651
rotation 0 1 0 1.5708
children [
Shape {
appearance PBRAppearance {
baseColorMap ImageTexture {
repeatS FALSE
repeatT FALSE
}
roughness 1
metalness 0
}
geometry DEF MARKER_GEOMETRY Box {
size 0.0001 0.08 0.08
}
}
]
name "top"
model "F196"
locked TRUE
recognitionColors [
1 1 1
]
}
Solid {
translation 0 0 -0.0651
rotation 0 1 0 -1.5708
children [
Shape {
appearance PBRAppearance {
baseColorMap ImageTexture {
repeatS FALSE
repeatT FALSE
}
roughness 1
metalness 0
}
geometry DEF MARKER_GEOMETRY Box {
size 0.0001 0.08 0.08
}
}
]
name "bottom"
model "F196"
locked TRUE
recognitionColors [
1 1 1
]
}
]
name "B0"
model "B0"
boundingObject USE TOKEN_GEOMETRY
physics Physics {
density -1
mass 0.08
}
linearVelocity -3.848367800941309e-11 -4.070695911509531e-11 -2.6201263381176948e-15
angularVelocity 8.622294200124287e-15 -5.234964335790459e-15 -2.867193996382634e-17
}
]
}
Solid {
translation 1.1490877220519633 1.0973791701444027 -0.022154997991848294
rotation -9.843611262504345e-06 -1.0339163906948293e-05 0.9999999998981025 -3.134560781836678
children [
DEF BODY Group {
children [
DEF base Pose {
translation 0 0 0.0325
children [
Shape {
appearance DEF SPACESHIP_APPEARANCE PBRAppearance {
baseColor 0.55 0.55 0.55
roughness 1
metalness 0
}
geometry Box {
size 0.48 0.39 0.025
}
}
]
}
DEF side_rear Pose {
translation -0.23 0.01 0.1225
children [
Shape {
appearance USE SPACESHIP_APPEARANCE
geometry Box {
size 0.02 0.37 0.155
}
}
]
}
DEF side_front Pose {
translation 0.23 -0.01 0.1225
children [
Shape {
appearance USE SPACESHIP_APPEARANCE
geometry Box {
size 0.02 0.37 0.155
}
}
]
}
DEF side_left Pose {
translation 0.01 0.185 0.1225
children [
Shape {
appearance USE SPACESHIP_APPEARANCE
geometry Box {
size 0.46 0.02 0.155
}
}
]
}
DEF side_right Pose {
translation -0.01 -0.185 0.1225
children [
Shape {
appearance USE SPACESHIP_APPEARANCE
geometry Box {
size 0.46 0.02 0.155
}
}
]
}
]
}
DEF MARKERS Group {
children [
Solid {
translation 0 0.1955 0.11
rotation 0 0 1 -1.570796327
children [
Shape {
appearance PBRAppearance {
baseColorMap ImageTexture {
repeatS FALSE
repeatT FALSE
}
roughness 1
metalness 0
}
geometry DEF MARKER_GEOMETRY Box {
size 0.0001 0.08 0.08
}
}
]
name "port"
model "F123"
locked TRUE
recognitionColors [
1 1 1
]
}
Solid {
translation 0 -0.1955 0.11
rotation 0 0 1 1.570796327
children [
Shape {
appearance PBRAppearance {
baseColorMap ImageTexture {
repeatS FALSE
repeatT FALSE
}
roughness 1
metalness 0
}
geometry DEF MARKER_GEOMETRY Box {
size 0.0001 0.08 0.08
}
}
]
name "starboard"
model "F128"
locked TRUE
recognitionColors [
1 1 1
]
}
]
}
]
name "S3"
model "S3"
boundingObject USE BODY
physics Physics {
density -1
mass 1.5
}
linearVelocity -3.0406703474887586e-16 -5.015394181626264e-16 -2.0842586915629605e-16
angularVelocity 8.448941906826877e-15 -5.140163449137719e-15 -8.5417561310404005e-19
}
from controller import Robot, Camera
robot = Robot()
timestep = int(robot.getBasicTimeStep())
device = robot.getDevice('camera')
assert isinstance(device, Camera)
camera: Camera = device
camera.enable(timestep)
camera.recognitionEnable(timestep)
while True:
robot.step(timestep * 50)
print(f"I see {camera.getRecognitionNumberOfObjects()} objects")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment