如何在Webots中编辑PUMA560 Proto文件及解决夹具更换问题
Hey there! Let's work through your PUMA560 fixture problems—these are super common when tweaking Webots PROTO files, so you're not alone here.
1. Fixing Disappearing Objects After Fixture Replacement
When your entire robot vanishes after swapping the fixture, it's almost always a coordinate/transform issue or invalid PROTO syntax. Here's how to edit the PUMA560 PROTO correctly:
- Locate the PROTO file: Navigate to your Webots installation's
projects/robots/unimation/puma560/protosfolder and openPUMA560.protoin a text editor (VS Code works great for this). - Find the end effector block: Scroll to the
childrensection of the final wrist link (usuallylink[6]). You'll see the original fixture—this might be aMeshor customShapenode. - Replace with your Box fixture: Swap the old geometry with a
Boxnode, but keep the original transform values (translation/rotation) to ensure it stays attached to the wrist. Example:# Original fixture (example) Shape { appearance PBRAppearance { baseColor 0.7 0.7 0.7 } geometry Mesh { url "webots://projects/robots/unimation/puma560/meshes/puma560_fixture.obj" } } # Replace with this Box fixture (adjust size to your needs) Shape { appearance PBRAppearance { baseColor 0.8 0.2 0.2 roughness 0.6 } geometry Box { size 0.06 0.06 0.12 } } - Verify transforms: Make sure the parent
Transformnode (if any) has the sametranslationandrotationas the original fixture. If you set these incorrectly, the Box might be placed inside the robot or far outside the camera view. - Save and reload: Save the PROTO file, then either restart Webots or right-click the PUMA560 node in your scene and select "Reload PROTO".
If it's still missing, check the size of your Box—if it's tiny (e.g., 0.001 0.001 0.001), it'll be practically invisible. Also, ensure you didn't accidentally delete any critical robot nodes while editing the PROTO.
2. Removing the Old Fixture and Binding the Controller
If the old fixture lingers even after adding a new one, you need to clean up both the PROTO and your scene, then link the controller properly:
Step 1: Delete the old fixture entirely
- From the PROTO: In
PUMA560.proto, find every trace of the original fixture (including anyCollisionnodes tied to it) and delete those lines. Don't leave partial nodes—this can cause unexpected behavior. - From the scene: If you manually added a new fixture to your scene (instead of editing the PROTO), open the Scene Tree, expand the PUMA560 node, find the old fixture child node, right-click it, and select "Delete".
Step 2: Bind the controller to the new fixture
- Fixed fixture: If your new fixture is just a static shape attached to the wrist, you don't need extra setup—since it's a child of the final wrist link, the controller's existing code for moving the PUMA560 will automatically move the fixture too.
- Motorized/gripping fixture: If your fixture needs movement (e.g., a gripper), add a
RotationalMotororLinearMotornode as a child of the wrist link, then assign it a uniqueDEFname (e.g.,DEF GripperMotor RotationalMotor { ... }). Update your controller code to reference this DEF name when controlling the motor:// Example C++ controller code WbDeviceTag gripper_motor = wb_robot_get_device("GripperMotor"); wb_motor_set_position(gripper_motor, 0.5); - Sensor integration: If you need touch/force feedback for gripping, add a
TouchSensorto the fixture and enable it in your controller withwb_touch_sensor_enable(sensor, TIME_STEP);.
Quick Tips
- Always back up the original
PUMA560.protofile before editing—this lets you revert if something breaks. - Use the Webots Scene Editor to test fixture positions first: drag a Box into the scene, adjust its translation/rotation until it's correctly attached to the wrist, then copy those values into the PROTO.
- Double-check controller code for any hardcoded references to the old fixture's DEF name—if you renamed things, those references need to match.
内容的提问来源于stack exchange,提问作者Shanaka Ramesh

