feat: 初始化提交
This commit is contained in:
59
参数获取测试.py
Normal file
59
参数获取测试.py
Normal file
@@ -0,0 +1,59 @@
|
||||
import time
|
||||
import krpc
|
||||
conn = krpc.connect(name='参数获取测试')
|
||||
if not conn.space_center:
|
||||
print("No active vessel found.")
|
||||
exit()
|
||||
|
||||
vessel = conn.space_center.active_vessel # 载具
|
||||
flight = vessel.flight(vessel.orbit.body.reference_frame)
|
||||
celestial = vessel.orbit.body # 当前天体
|
||||
|
||||
|
||||
pressure = flight.static_pressure # 静压
|
||||
|
||||
gav = celestial.surface_gravity # 重力加速度
|
||||
available_thrust = vessel.available_thrust # 可用推力
|
||||
|
||||
twr = available_thrust / (vessel.mass * gav) # 推重比
|
||||
|
||||
print(pressure)
|
||||
print(vessel.thrust)
|
||||
print(vessel.available_thrust)
|
||||
print(available_thrust)
|
||||
print(gav)
|
||||
print(twr)
|
||||
|
||||
# hybrid_ref = conn.space_center.ReferenceFrame.create_hybrid(
|
||||
# position=vessel.orbit.body.reference_frame,
|
||||
# rotation=vessel.surface_reference_frame
|
||||
# )
|
||||
# flight = vessel.flight(hybrid_ref)
|
||||
# print("速度向量:", flight.velocity)
|
||||
# print("航向(heading):", flight.heading, "°") # 你的仪表盘方向
|
||||
# print("俯仰(pitch):", flight.pitch, "°") # 正=抬头
|
||||
# print("垂直速:", flight.vertical_speed, "m/s") # 正=上
|
||||
|
||||
# while True:
|
||||
# print(flight.velocity," "*10, end='\r')
|
||||
# time.sleep(0.1)
|
||||
|
||||
|
||||
|
||||
# 1. 世界坐标速度 (North, East, Up) —— 标准悬停/着陆用这个!
|
||||
world_ref = vessel.orbit.body.reference_frame
|
||||
flight_world = vessel.flight(world_ref)
|
||||
|
||||
vel = flight_world.velocity
|
||||
vel_north = vel[0] # 北向 (正=北)
|
||||
vel_east = vel[1] # 东向 (正=东,负=西)
|
||||
vel_up = vel[2] # 向上 (正=爬升)
|
||||
|
||||
print(f"世界速度: 北={vel_north:.2f}, 东={vel_east:.2f}, 上={vel_up:.2f} m/s")
|
||||
print(f"垂直速确认: {flight_world.vertical_speed:.2f} m/s") # 应该 ≈ vel_up
|
||||
|
||||
# 2. 姿态 (heading, pitch) —— 用 surface 或 hybrid 都行,但这里用 surface 更直接
|
||||
surface_ref = vessel.surface_reference_frame
|
||||
flight_surface = vessel.flight(surface_ref)
|
||||
print(f"航向: {flight_surface.heading:.1f}°")
|
||||
print(f"俯仰: {flight_surface.pitch:.1f}°")
|
||||
Reference in New Issue
Block a user