Code reorganization and Drone Logic Update

This commit is contained in:
2026-01-05 02:38:46 +00:00
parent c5b208c91a
commit 27a70c4983
32 changed files with 1018 additions and 812 deletions

168
docs/blender_models.md Normal file
View File

@@ -0,0 +1,168 @@
# Blender Models in Gazebo
Import 3D models from Blender into the ARG simulation.
## Workflow
```
Blender (.blend) → Export COLLADA (.dae) → Gazebo Model → World
```
## Step 1: Create Model in Blender
1. Create your 3D model
2. Apply all transforms: `Ctrl+A` → All Transforms
3. Set origin to geometry center
## Step 2: Export from Blender
1. File → Export → COLLADA (.dae)
2. Settings:
- Selection Only (if needed)
- Include Armatures: OFF
- Include Animations: OFF
- Triangulate: ON
3. Save as `model.dae`
## Step 3: Create Gazebo Model
```
gazebo/models/my_model/
├── model.config
├── model.sdf
├── meshes/
│ └── model.dae
└── materials/
└── textures/
└── texture.png
```
### model.config
```xml
<?xml version="1.0"?>
<model>
<name>My Model</name>
<version>1.0</version>
<sdf version="1.9">model.sdf</sdf>
<description>Custom Blender model</description>
</model>
```
### model.sdf
```xml
<?xml version="1.0"?>
<sdf version="1.9">
<model name="my_model">
<static>true</static>
<link name="link">
<collision name="collision">
<geometry>
<mesh>
<uri>meshes/model.dae</uri>
<scale>1 1 1</scale>
</mesh>
</geometry>
</collision>
<visual name="visual">
<geometry>
<mesh>
<uri>meshes/model.dae</uri>
<scale>1 1 1</scale>
</mesh>
</geometry>
</visual>
</link>
</model>
</sdf>
```
## Step 4: Add to World
```xml
<include>
<uri>model://my_model</uri>
<name>my_model_instance</name>
<pose>5 3 0 0 0 0</pose>
</include>
```
## Step 5: Set Model Path
```bash
export GZ_SIM_RESOURCE_PATH=$PWD/gazebo/models:$GZ_SIM_RESOURCE_PATH
```
## Common Issues
### Model Not Found
```bash
export GZ_SIM_RESOURCE_PATH=/full/path/to/gazebo/models:$GZ_SIM_RESOURCE_PATH
```
### Scale Wrong
In Blender, check unit settings: Properties → Scene → Units
Adjust in SDF:
```xml
<scale>0.01 0.01 0.01</scale>
```
### Textures Not Showing
Put textures in `materials/textures/` and reference in DAE file.
Or add material in SDF:
```xml
<visual name="visual">
<geometry>
<mesh><uri>meshes/model.dae</uri></mesh>
</geometry>
<material>
<diffuse>0.8 0.2 0.2 1</diffuse>
</material>
</visual>
```
### Model Orientation Wrong
Blender uses Z-up, Gazebo uses Z-up. Should match.
If rotated, fix in Blender or use pose:
```xml
<pose>0 0 0 1.5708 0 0</pose>
```
## Simplified Collision
For complex meshes, use simple collision:
```xml
<collision name="collision">
<geometry>
<box><size>2 2 3</size></box>
</geometry>
</collision>
<visual name="visual">
<geometry>
<mesh><uri>meshes/complex_model.dae</uri></mesh>
</geometry>
</visual>
```
## Template
Copy the template:
```bash
cp -r gazebo/models/custom_object gazebo/models/my_model
```
Then:
1. Edit `model.config` with your name
2. Edit `model.sdf` with your model name
3. Put your `model.dae` in `meshes/`
## Test Model
```bash
gz sim -v4 gazebo/worlds/custom_landing.sdf
```