A module for simulating a point and controlling points.
Project description
pointsim
Проект создан для симуляции материальной точки для тестирования ПИД регуляторов и их коэффициентов.
Установка
pip install git+https://github.com/OnisOris/pointsim
Примеры
2D симуляция
import matplotlib
import numpy as np
from pointsim.cython_pid import PIDController
from pointsim import StabilizationSimulator2D, Point2D
matplotlib.use('Qt5Agg')
# Инициализируем PID-контроллер с коэффициентами
kp = [6.103582235784548, 6.103582235784548]
ki = [0, 0]
kd = [5.898832824054038, 5.898832824054038]
# pid_controller = PIDController(kp, ki, kd)
pid_controller = PIDController(np.array(kp, dtype=np.float64),
np.array(ki, dtype=np.float64),
np.array(kd, dtype=np.float64))
# Инициализируем точку
mass = 1.0
position = np.array([5.0, 5.0]) # Начальная позиция вдали от центра
speed = np.array([0.0, 0.0]) # Начальная скорость
point = Point2D(mass, position, speed)
# Создаем симулятор стабилизации с PID-регулятором
stabilization_simulator = StabilizationSimulator2D("PIDStabilizationSim", point, dt=0.1, pid_controller=pid_controller)
# Запускаем анимацию стабилизации с графиками
stabilization_simulator.animate()
3D симуляция
import matplotlib
from pointsim import StabilizationSimulator3D
matplotlib.use('Qt5Agg')
if __name__ == "__main__":
simulator = StabilizationSimulator3D(
name="PIDStabilizationSim",
mass=1.0,
position=[10.0, 10.0, 5.0], # Начальное смещение
speed=[0.0, 0.0, 0.0],
kp=[1, 1, 1], # Коэффициенты PID
ki=[0.0, 0.0, 0.0], # Интегральная часть отключена
kd=[1, 1, 1], # Дифференциальная часть
dt=0.05, # Шаг времени
show_trajectory=True, # Включаем отображение траектории
max_acceleration=5
)
simulator.run_simulation(steps=1000)
3D симуляция в реальном времени
import numpy as np
import matplotlib
from pointsim import StabilizationSimulator3DRealTime
matplotlib.use('Qt5Agg')
if __name__ == "__main__":
simulator = StabilizationSimulator3DRealTime(
name="PIDRealTimeSim",
mass=1.0,
position=[10.0, 10.0, 5.0],
speed=[0.0, 0.0, 0.0],
kp=[1, 1, 1],
ki=[0.0, 0.0, 0.0],
kd=[1, 1, 1],
dt=0.05,
show_trajectory=True,
max_acceleration=5
)
# Передаем внешний управляющий сигнал
simulator.receive_external_signal(np.array([0.1, -0.2, 0.3]))
# Запуск симуляции с анимацией
simulator.animate_real_time()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pointsim-0.0.1.tar.gz
(97.3 kB
view details)
Built Distribution
File details
Details for the file pointsim-0.0.1.tar.gz
.
File metadata
- Download URL: pointsim-0.0.1.tar.gz
- Upload date:
- Size: 97.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.13.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2266bbd7eb566a54d43e0d902cedebf9d31cda82d685597ef10702957c0cdc13 |
|
MD5 | ad7ca5007f3672d94be6530bdf6a3c4e |
|
BLAKE2b-256 | bc75c95f4eea755fd4cd46b53fbc401cbcb97dca0bf34b87ddb1dff5b27afc93 |
File details
Details for the file pointsim-0.0.1-cp313-cp313-win_amd64.whl
.
File metadata
- Download URL: pointsim-0.0.1-cp313-cp313-win_amd64.whl
- Upload date:
- Size: 53.5 kB
- Tags: CPython 3.13, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.13.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 149cda9fdcc2827398aeac75bbec781a34f547833d773723deb344daf4a61756 |
|
MD5 | b3c18905077bcad443c3143f6694592b |
|
BLAKE2b-256 | d0e5c2496b691daabd02edf84f4e430678f9528e122dcb245bb0a3d166fcf10d |