锥桶自定义更新
This commit is contained in:
22
main.py
22
main.py
@@ -3,6 +3,7 @@ import json
|
||||
import math
|
||||
import os
|
||||
import random
|
||||
import tempfile
|
||||
import threading
|
||||
from collections import deque
|
||||
from http.server import BaseHTTPRequestHandler, HTTPServer
|
||||
@@ -151,7 +152,26 @@ def main():
|
||||
with RenderApp() as render:
|
||||
render.opt.set_left_panel_vis(True)
|
||||
|
||||
model = load_model("scene.xml")
|
||||
# Load cone positions and inject into scene
|
||||
with open("cones.json") as f:
|
||||
cones = json.load(f)
|
||||
cone_xml = ""
|
||||
for i, c in enumerate(cones):
|
||||
cone_xml += (
|
||||
f'\n <body name="cone_{i}" pos="{c["x"]} {c["y"]} 0.0">\n'
|
||||
f' <geom type="box" size="0.10 0.10 0.015" pos="0 0 0.015" class="cone_blue"/>\n'
|
||||
f' <geom type="mesh" mesh="cone_mesh" pos="0 0 0.03" class="cone_blue"/>\n'
|
||||
f' <geom type="mesh" mesh="cone_white_mesh" pos="0 0 0.15" rgba="1 1 1 1"/>\n'
|
||||
f' </body>'
|
||||
)
|
||||
with open("scene.xml") as f:
|
||||
xml = f.read()
|
||||
xml = xml.replace("<!-- CONES -->", cone_xml)
|
||||
tmp = tempfile.NamedTemporaryFile(suffix=".xml", delete=False, dir=".", mode="w")
|
||||
tmp.write(xml)
|
||||
tmp.close()
|
||||
model = load_model(tmp.name)
|
||||
os.unlink(tmp.name)
|
||||
|
||||
cameras = model.cameras
|
||||
front_cam = cameras[0]
|
||||
|
||||
Reference in New Issue
Block a user