Helpful resources: https://github.com/mithi/robotics-coursework
##1.1 World Nodes
The WorldInfo node is the root configuration node for any Webots world. It defines fundamental simulation properties:
WorldInfo {
basicTimeStep 32 # Simulation step in milliseconds
FPS 60 # Frames per second for rendering
gravity 0 -9.81 0 # Gravity vector (x y z)
coordinateSystem "NUE" # North-Up-East coordinate system
physics "ODE" # Open Dynamics Engine physics
}
Physics Parameters
basicTimeStep
: Controls simulation speed (ms)gravity
: Vector defining gravity direction and magnitudecfm
: Constraint Force Mixing (default: 1e-5)erp
: Error Reduction Parameter (default: 0.2)Rendering Parameters
FPS
: Maximum frames per secondlineScale
: Line thickness for renderingcontactProperties
: Define material interactionsCoordinate System
coordinateSystem
: Defines axis orientationCtrl + 1-9 : Save viewpoint
1-9 : Restore saved viewpoint
Ctrl + Shift + F : Full screen
Ctrl + 0 : Reset viewpoint
Up Arrow : Tilt up
Down Arrow : Tilt down
Left Arrow : Rotate left
Right Arrow : Rotate right
Page Up : Zoom in
Page Down : Zoom out
Ctrl + P : Play/pause simulation
Ctrl + T : Run one step
Ctrl + R : Reset simulation
Ctrl + Shift + R : Reset simulation and reload world
Object Selection
View Modes
Ctrl + F1: Plain rendering
Ctrl + F2: Wireframe mode
Ctrl + F3: Normal vectors display
Ctrl + F4: Physics visualization
Quick Scene Tree Navigation
Camera Getting Lost
Zoom Sensitivity Issues
# Adjust in Preferences → General → Navigation
Translation multiply factor: 0.4 (default)
Rotation multiply factor: 0.5 (default)
Scene Tree Organization
# Recommended hierarchy
WorldInfo
├── Viewpoint
├── Background
├── DirectionalLight
├── Ground
└── Robots/Objects
Camera Setup
Scene Organization
Performance Tips
##1.2 Supervisor Nodes
What is a Supervisor Node? A Supervisor node is a special robot node in Webots with privileged access to the simulation. Think of it as a “god mode” controller that can:
Modify the simulation while it’s running Access and modify any object’s position/rotation Create/delete objects dynamically Record simulation data Reset simulation states
Creating a Supervisor Node Basic Setup pythonCopy# In your .wbt world file Robot { controller “my_supervisor” supervisor TRUE # This is the key line … } Python Controller Example pythonCopyfrom controller import Supervisor
supervisor = Supervisor() timestep = int(supervisor.getBasicTimeStep())
robot = supervisor.getFromDef(“ROBOT”) if robot is not None: # Get position of robot position = robot.getPosition() print(f"Robot position: {position}")
# Move robot to new position
translation_field = robot.getField("translation")
translation_field.setSFVec3f([0, 0.5, 0])
while supervisor.step(timestep) != -1: # Main control loop pass Key Supervisor Capabilities
trans_field = object.getField(“translation”) trans_field.setSFVec3f([x, y, z])
rot_field = object.getField(“rotation”) rot_field.setSFRotation([axis_x, axis_y, axis_z, angle]) 2. Simulation Control pythonCopy# Reset simulation supervisor.simulationReset()
supervisor.simulationResetPhysics()
mode = supervisor.simulationGetMode() supervisor.simulationSetMode(Supervisor.SIMULATION_MODE_PAUSE) 3. Dynamic Object Creation pythonCopy# Import node from file root = supervisor.getRoot() children = root.getField(“children”) children.importMFNode(-1, “path/to/object.wbo”)
box_string = """ Solid { translation 0 0.5 0 children [ Shape { appearance PBRAppearance { baseColor 1 0 0 } geometry Box { size 0.1 0.1 0.1 } } ] } """ children.importMFNodeFromString(-1, box_string) 4. Data Recording pythonCopy# Record to animation file supervisor.animationStartRecording(“recording.html”)
supervisor.animationStopRecording()
supervisor.worldSave(“saved_state.wbt”) Common Use Cases
Training Data Generation pythonCopydef collect_training_data(): robot = supervisor.getFromDef(“ROBOT”) object = supervisor.getFromDef(“TARGET”)
while supervisor.step(timestep) != -1: robot_pos = robot.getPosition() object_pos = object.getPosition()
# Save to dataset
with open('training_data.csv', 'a') as f:
f.write(f"{robot_pos},{object_pos}\n")
Reinforcement Learning Setup pythonCopydef reset_episode():
robot = supervisor.getFromDef(“ROBOT”) trans_field = robot.getField(“translation”) trans_field.setSFVec3f([0, 0, 0])
object = supervisor.getFromDef(“TARGET”) object_trans = object.getField(“translation”) random_pos = [random.uniform(-1, 1), 0.5, random.uniform(-1, 1)] object_trans.setSFVec3f(random_pos)
supervisor.simulationResetPhysics()
Automated Testing pythonCopydef run_test_scenario(): robot = supervisor.getFromDef(“ROBOT”) initial_pos = robot.getPosition()
for _ in range(1000): if supervisor.step(timestep) == -1: break
final_pos = robot.getPosition() distance = compute_distance(initial_pos, final_pos)
return distance < 0.1 # Test pass/fail criteria Best Practices
Error Handling
pythonCopydef safe_get_node(supervisor, def_name): node = supervisor.getFromDef(def_name) if node is None: raise ValueError(f"Node ‘{def_name}’ not found in simulation") return node
Resource Management
pythonCopydef cleanup_simulation(): # Stop any recordings supervisor.animationStopRecording()
# Save final state
supervisor.worldSave("final_state.wbt")
# Reset physics
supervisor.simulationResetPhysics()
Performance Considerations
Cache node references instead of getting them repeatedly Minimize physics resets Use batch operations when possible Consider timestep implications when moving objects
Common Pitfalls
Node Access
Always check if nodes exist before accessing Use DEF names consistently Handle None returns from getFromDef()
Physics Interactions
Reset physics after teleporting objects Consider stability when changing object positions Maintain realistic velocities and accelerations
Resource Usage
Close file handles properly Stop recordings when done Clean up created objects when no longer needed
Brief introduction to Webots Environment Setup and its importance in the context of robotic laundry folding.
Core concepts and theoretical foundations.
Step-by-step implementation guide with code examples.
Specific project tasks related to Webots Environment Setup.
Summary of main points and learning outcomes.