write tool
This commit is contained in:
74
A/2/position_watcher.py
Normal file
74
A/2/position_watcher.py
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
import mpmath as mp
|
||||||
|
import json
|
||||||
|
import sys
|
||||||
|
|
||||||
|
if __name__ != "__main__":
|
||||||
|
sys.exit()
|
||||||
|
|
||||||
|
mp.dps = 15 # 设置精度为15位小数
|
||||||
|
|
||||||
|
kSegLength1 = mp.mpf('2.86')
|
||||||
|
kSegLength2 = mp.mpf('1.65')
|
||||||
|
kAlpha = mp.mpf('0.55') / (2 * mp.pi)
|
||||||
|
|
||||||
|
def Theta2C(theta):
|
||||||
|
tmp = mp.sqrt(1 + theta**2)
|
||||||
|
return kAlpha * 0.5 * (theta * tmp - mp.log(-theta + tmp))
|
||||||
|
|
||||||
|
def Theta2Dot(theta):
|
||||||
|
return (kAlpha * theta * mp.cos(theta), kAlpha * theta * mp.sin(theta))
|
||||||
|
|
||||||
|
init_C=Theta2C(2*mp.pi*16)
|
||||||
|
def GenerateFirstNodeTheta(time_point):
|
||||||
|
cur_C = init_C - time_point
|
||||||
|
def f(theta):
|
||||||
|
return Theta2C(theta) - cur_C
|
||||||
|
return mp.findroot(f, 2*mp.pi*16, solver='secant')
|
||||||
|
|
||||||
|
def GenerateFollowNodeTheta(cur_node_theta, expected_distance):
|
||||||
|
cur_node_dot = Theta2Dot(cur_node_theta)
|
||||||
|
def f(theta):
|
||||||
|
test_node_dot = Theta2Dot(theta)
|
||||||
|
actual_distance = mp.sqrt((cur_node_dot[0]-test_node_dot[0])**2 + (cur_node_dot[1]-test_node_dot[1])**2)
|
||||||
|
return actual_distance - expected_distance
|
||||||
|
return mp.findroot(f, cur_node_theta + 0.1, solver='secant')
|
||||||
|
|
||||||
|
def CalcMoveList(time_point):
|
||||||
|
first_node_theta = GenerateFirstNodeTheta(time_point)
|
||||||
|
first_node_dot = Theta2Dot(first_node_theta)
|
||||||
|
first_node_C = Theta2C(first_node_theta)
|
||||||
|
|
||||||
|
node_list = [{"theta": first_node_theta, "node": first_node_dot, "C": first_node_C, "v": mp.mpf('1.0')}]
|
||||||
|
|
||||||
|
for i in range(1, 224):
|
||||||
|
expected_distance = kSegLength1 if i == 1 else kSegLength2
|
||||||
|
cur_node_theta = GenerateFollowNodeTheta(node_list[-1]["theta"], expected_distance)
|
||||||
|
cur_node_dot = Theta2Dot(cur_node_theta)
|
||||||
|
cur_node_C = Theta2C(cur_node_theta)
|
||||||
|
node_list.append({"theta": cur_node_theta, "node": cur_node_dot, "C": cur_node_C})
|
||||||
|
for i in range(223):
|
||||||
|
AA = kSegLength1 if i == 0 else kSegLength2
|
||||||
|
theta_i = node_list[i]["theta"]
|
||||||
|
theta_ip1 = node_list[i+1]["theta"]
|
||||||
|
alpha_i = mp.atan(theta_i)
|
||||||
|
alpha_ip1 = mp.atan(theta_ip1)
|
||||||
|
beta_i = mp.acos(((kAlpha*theta_i)**2 + AA**2 - (kAlpha*theta_ip1)**2) / (2*kAlpha*theta_i*AA))
|
||||||
|
gama_i = mp.acos(((kAlpha*theta_ip1)**2 + AA**2 - (kAlpha*theta_i)**2) / (2*kAlpha*theta_ip1*AA))
|
||||||
|
node_list[i+1]["v"] = node_list[i]["v"] * (-mp.cos(alpha_i + beta_i) / mp.cos(alpha_ip1 - gama_i))
|
||||||
|
|
||||||
|
return node_list
|
||||||
|
|
||||||
|
|
||||||
|
time_point= float(input())
|
||||||
|
print(f"calculating time_point={time_point}")
|
||||||
|
time_point_list = CalcMoveList(time_point)
|
||||||
|
|
||||||
|
# 将结果转换为float并保留6位小数
|
||||||
|
float_res_list = [
|
||||||
|
{k: round(float(v), 6) if isinstance(v, mp.mpf) else
|
||||||
|
[round(float(x), 6) for x in v] if isinstance(v, tuple) else v
|
||||||
|
for k, v in node.items()}
|
||||||
|
for node in time_point_list
|
||||||
|
]
|
||||||
|
# print(float_res_list)
|
||||||
|
json.dump(float_res_list, sys.stdout, indent=4)
|
105
environment.yml
Normal file
105
environment.yml
Normal file
@@ -0,0 +1,105 @@
|
|||||||
|
name: cumcm2024
|
||||||
|
channels:
|
||||||
|
- pytorch
|
||||||
|
- nvidia
|
||||||
|
- defaults
|
||||||
|
dependencies:
|
||||||
|
- _libgcc_mutex=0.1=main
|
||||||
|
- _openmp_mutex=5.1=1_gnu
|
||||||
|
- blas=1.0=mkl
|
||||||
|
- brotli-python=1.0.9=py312h6a678d5_8
|
||||||
|
- bzip2=1.0.8=h5eee18b_6
|
||||||
|
- ca-certificates=2024.7.2=h06a4308_0
|
||||||
|
- certifi=2024.7.4=py312h06a4308_0
|
||||||
|
- charset-normalizer=3.3.2=pyhd3eb1b0_0
|
||||||
|
- cuda-cudart=12.1.105=0
|
||||||
|
- cuda-cupti=12.1.105=0
|
||||||
|
- cuda-libraries=12.1.0=0
|
||||||
|
- cuda-nvrtc=12.1.105=0
|
||||||
|
- cuda-nvtx=12.1.105=0
|
||||||
|
- cuda-opencl=12.6.68=0
|
||||||
|
- cuda-runtime=12.1.0=0
|
||||||
|
- cuda-version=12.6=3
|
||||||
|
- expat=2.6.2=h6a678d5_0
|
||||||
|
- ffmpeg=4.3=hf484d3e_0
|
||||||
|
- filelock=3.13.1=py312h06a4308_0
|
||||||
|
- freetype=2.12.1=h4a9f257_0
|
||||||
|
- gmp=6.2.1=h295c915_3
|
||||||
|
- gnutls=3.6.15=he1e5248_0
|
||||||
|
- idna=3.7=py312h06a4308_0
|
||||||
|
- intel-openmp=2023.1.0=hdb19cb5_46306
|
||||||
|
- jinja2=3.1.4=py312h06a4308_0
|
||||||
|
- jpeg=9e=h5eee18b_3
|
||||||
|
- lame=3.100=h7b6447c_0
|
||||||
|
- lcms2=2.12=h3be6417_0
|
||||||
|
- ld_impl_linux-64=2.38=h1181459_1
|
||||||
|
- lerc=3.0=h295c915_0
|
||||||
|
- libcublas=12.1.0.26=0
|
||||||
|
- libcufft=11.0.2.4=0
|
||||||
|
- libcufile=1.11.1.6=0
|
||||||
|
- libcurand=10.3.7.68=0
|
||||||
|
- libcusolver=11.4.4.55=0
|
||||||
|
- libcusparse=12.0.2.55=0
|
||||||
|
- libdeflate=1.17=h5eee18b_1
|
||||||
|
- libffi=3.4.4=h6a678d5_1
|
||||||
|
- libgcc-ng=11.2.0=h1234567_1
|
||||||
|
- libgomp=11.2.0=h1234567_1
|
||||||
|
- libiconv=1.16=h5eee18b_3
|
||||||
|
- libidn2=2.3.4=h5eee18b_0
|
||||||
|
- libjpeg-turbo=2.0.0=h9bf148f_0
|
||||||
|
- libllvm14=14.0.6=hdb19cb5_3
|
||||||
|
- libnpp=12.0.2.50=0
|
||||||
|
- libnvjitlink=12.1.105=0
|
||||||
|
- libnvjpeg=12.1.1.14=0
|
||||||
|
- libpng=1.6.39=h5eee18b_0
|
||||||
|
- libstdcxx-ng=11.2.0=h1234567_1
|
||||||
|
- libtasn1=4.19.0=h5eee18b_0
|
||||||
|
- libtiff=4.5.1=h6a678d5_0
|
||||||
|
- libunistring=0.9.10=h27cfd23_0
|
||||||
|
- libuuid=1.41.5=h5eee18b_0
|
||||||
|
- libwebp-base=1.3.2=h5eee18b_0
|
||||||
|
- llvm-openmp=14.0.6=h9e868ea_0
|
||||||
|
- llvmlite=0.43.0=py312h6a678d5_0
|
||||||
|
- lz4-c=1.9.4=h6a678d5_1
|
||||||
|
- markupsafe=2.1.3=py312h5eee18b_0
|
||||||
|
- mkl=2023.1.0=h213fc3f_46344
|
||||||
|
- mkl-service=2.4.0=py312h5eee18b_1
|
||||||
|
- mkl_fft=1.3.10=py312h5eee18b_0
|
||||||
|
- mkl_random=1.2.7=py312h526ad5a_0
|
||||||
|
- mpmath=1.3.0=py312h06a4308_0
|
||||||
|
- ncurses=6.4=h6a678d5_0
|
||||||
|
- nettle=3.7.3=hbbd107a_1
|
||||||
|
- networkx=3.2.1=py312h06a4308_0
|
||||||
|
- numba=0.60.0=py312h526ad5a_0
|
||||||
|
- numpy=1.26.4=py312hc5e2394_0
|
||||||
|
- numpy-base=1.26.4=py312h0da6c21_0
|
||||||
|
- openh264=2.1.1=h4ff587b_0
|
||||||
|
- openjpeg=2.5.2=he7f1fd0_0
|
||||||
|
- openssl=3.0.14=h5eee18b_0
|
||||||
|
- pillow=10.4.0=py312h5eee18b_0
|
||||||
|
- pip=24.2=py312h06a4308_0
|
||||||
|
- pysocks=1.7.1=py312h06a4308_0
|
||||||
|
- python=3.12.4=h5148396_1
|
||||||
|
- pytorch=2.4.1=py3.12_cuda12.1_cudnn9.1.0_0
|
||||||
|
- pytorch-cuda=12.1=ha16c6d3_5
|
||||||
|
- pytorch-mutex=1.0=cuda
|
||||||
|
- pyyaml=6.0.1=py312h5eee18b_0
|
||||||
|
- readline=8.2=h5eee18b_0
|
||||||
|
- requests=2.32.3=py312h06a4308_0
|
||||||
|
- setuptools=72.1.0=py312h06a4308_0
|
||||||
|
- sqlite=3.45.3=h5eee18b_0
|
||||||
|
- sympy=1.13.2=py312h06a4308_0
|
||||||
|
- tbb=2021.8.0=hdb19cb5_0
|
||||||
|
- tk=8.6.14=h39e8969_0
|
||||||
|
- torchaudio=2.4.1=py312_cu121
|
||||||
|
- torchtriton=3.0.0=py312
|
||||||
|
- torchvision=0.19.1=py312_cu121
|
||||||
|
- typing_extensions=4.11.0=py312h06a4308_0
|
||||||
|
- tzdata=2024a=h04d1e81_0
|
||||||
|
- urllib3=2.2.2=py312h06a4308_0
|
||||||
|
- wheel=0.43.0=py312h06a4308_0
|
||||||
|
- xz=5.4.6=h5eee18b_1
|
||||||
|
- yaml=0.2.5=h7b6447c_0
|
||||||
|
- zlib=1.2.13=h5eee18b_1
|
||||||
|
- zstd=1.5.5=hc292b87_2
|
||||||
|
prefix: /home/bird/miniconda3/envs/cumcm2024
|
Reference in New Issue
Block a user