Skip to content

Instantly share code, notes, and snippets.

@PeterJCLaw
Created February 3, 2023 21:47
Show Gist options
  • Save PeterJCLaw/58ce5bb8616d7f384fc0d6f18a60836e to your computer and use it in GitHub Desktop.
Save PeterJCLaw/58ce5bb8616d7f384fc0d6f18a60836e to your computer and use it in GitHub Desktop.
Webots recognition object orientation quandary
from controller import Robot, Camera
robot = Robot()
camera: Camera = robot.getDevice('camera') # type: ignore
camera.enable(1000 // 30)
camera.recognitionEnable(1000 // 30)
while True:
for obj in camera.getRecognitionObjects():
print(tuple(obj.getOrientation()))
robot.step(int(robot.getBasicTimeStep()) * 50)
#VRML_SIM R2022b utf8
WorldInfo {
basicTimeStep 8
}
Viewpoint {
orientation -0.2727346664961006 0.30451750897145596 0.9126252727275745 1.5520085381979425
position -0.2750924212361294 -6.213234622254402 3.0430013497738613
near 0.1
ambientOcclusionRadius 0.3
bloomThreshold 100
}
DEF AMBIENT Background {
skyColor [
0.4 0.4 0.4
]
luminosity 2
}
DEF ROBOT-0 Robot {
translation 0.5 -2.375 0.0039779863600000005
rotation 4.501898917842903e-18 8.590193579573919e-18 -1 1.57079633
children [
DEF body_geo Group {
children [
Shape {
appearance DEF BODY_COLOUR PBRAppearance {
baseColor 0 1 0
roughness 0.3
metalness 0
}
geometry Box {
size 0.11 0.17 0.012
}
}
]
}
Camera {
translation -0.02 0 0.16
rotation -0.12467469646513704 0 0.9921976718685274 3.1415927
children [
Transform {
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
}
Transform {
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 4
frameThickness 2
}
}
]
name "Robot0"
model "Robot0"
boundingObject USE body_geo
physics Physics {
}
controller "demo_controller"
}
Solid {
translation 0.5 -1.2 0.1
rotation 1 0 0 0
children [
Shape {
appearance DEF TOKEN_APPEARANCE PBRAppearance {
baseColor 0.8 0.8 0
roughness 1
metalness 0
}
geometry DEF TOKEN_GEOMETRY Box {
size 0.27 0.27 0.27
}
}
Solid {
translation 0 -0.1351 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
}
}
]
boundingObject USE MARKER_GEOMETRY
physics Physics {
}
locked TRUE
recognitionColors [
1 1 1
]
}
]
name "Token"
model "Token"
boundingObject USE TOKEN_GEOMETRY
physics Physics {
density -1
mass 0.5
}
}
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
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment