|
44 | 44 | " Accelerometer,\n", |
45 | 45 | " Environment,\n", |
46 | 46 | " Flight,\n", |
47 | | - " Function,\n", |
48 | | - " GnssReceiver,\n", |
49 | 47 | " Gyroscope,\n", |
50 | 48 | " Rocket,\n", |
51 | 49 | ")\n", |
52 | 50 | "from rocketpy.motors import CylindricalTank, Fluid, HybridMotor\n", |
53 | 51 | "from rocketpy.motors.tank import MassFlowRateBasedTank\n", |
54 | | - "from rocketpy.tools import quaternions_to_spin\n", |
55 | 52 | "\n", |
56 | 53 | "plt.style.use(\"seaborn-v0_8-colorblind\")" |
57 | 54 | ] |
|
284 | 281 | "outputs": [], |
285 | 282 | "source": [ |
286 | 283 | "def tvc_controller_function(\n", |
287 | | - " time, sampling_rate, state, state_history, observed_variables, tvc, sensors\n", |
| 284 | + " time,\n", |
| 285 | + " sampling_rate,\n", |
| 286 | + " state,\n", |
| 287 | + " state_history,\n", |
| 288 | + " observed_variables,\n", |
| 289 | + " thrust_vector_control,\n", |
| 290 | + " sensors,\n", |
288 | 291 | "):\n", |
289 | 292 | " # state = [x, y, z, vx, vy, vz, e0, e1, e2, e3, wx, wy, wz]\n", |
290 | 293 | "\n", |
291 | 294 | " # print(time)\n", |
292 | 295 | "\n", |
293 | | - " tvc.gimbal_angle_x = 0\n", |
294 | | - " tvc.gimbal_angle_y = 0\n", |
| 296 | + " thrust_vector_control.gimbal_angle_x = 0\n", |
| 297 | + " thrust_vector_control.gimbal_angle_y = 0\n", |
295 | 298 | " # Return variables of interest to be saved in the observed_variables list\n", |
296 | 299 | " return (\n", |
297 | 300 | " time,\n", |
298 | | - " tvc.gimbal_angle_x,\n", |
299 | | - " tvc.gimbal_angle_y,\n", |
| 301 | + " thrust_vector_control.gimbal_angle_x,\n", |
| 302 | + " thrust_vector_control.gimbal_angle_y,\n", |
300 | 303 | " )\n", |
301 | 304 | "\n", |
302 | 305 | "\n", |
303 | | - "tvc, tvc_controller = HALCYON.add_tvc(\n", |
304 | | - " gimbal_range=10,\n", |
| 306 | + "thrust_vector_control, tvc_controller = HALCYON.add_thrust_vector_control(\n", |
| 307 | + " controller_function=tvc_controller_function,\n", |
305 | 308 | " sampling_rate=100,\n", |
| 309 | + " max_gimbal_angle=10,\n", |
306 | 310 | " gimbal_rate_limit=100,\n", |
307 | | - " controller_function=tvc_controller_function,\n", |
308 | 311 | " return_controller=True,\n", |
309 | 312 | ")\n", |
310 | | - "tvc.info()\n", |
| 313 | + "thrust_vector_control.x.info()\n", |
311 | 314 | "tvc_controller.info()" |
312 | 315 | ] |
313 | 316 | }, |
|
380 | 383 | "\n", |
381 | 384 | "\n", |
382 | 385 | "roll_control, roll_controller = HALCYON.add_roll_control(\n", |
383 | | - " max_roll_torque=10,\n", |
384 | | - " sampling_rate=100,\n", |
385 | | - " torque_rate_limit=100,\n", |
386 | 386 | " controller_function=roll_controller_function,\n", |
| 387 | + " sampling_rate=100,\n", |
| 388 | + " max_roll_torque=10,\n", |
| 389 | + " torque_rate_limit=1000,\n", |
387 | 390 | " return_controller=True,\n", |
388 | 391 | ")\n", |
389 | 392 | "roll_control.info()\n", |
|
417 | 420 | " time,\n", |
418 | 421 | " throttle_command,\n", |
419 | 422 | " throttle_actual,\n", |
420 | | - " )" |
421 | | - ] |
422 | | - }, |
423 | | - { |
424 | | - "cell_type": "code", |
425 | | - "execution_count": null, |
426 | | - "metadata": {}, |
427 | | - "outputs": [], |
428 | | - "source": [ |
| 423 | + " )\n", |
| 424 | + "\n", |
| 425 | + "\n", |
429 | 426 | "throttle_obj, throttle_controller = HALCYON.add_throttle_control(\n", |
430 | 427 | " controller_function=throttle_controller_function,\n", |
431 | 428 | " sampling_rate=100,\n", |
432 | 429 | " throttle_range=(0.0, 1.0),\n", |
433 | 430 | " throttle_rate_limit=100,\n", |
434 | | - " actuator_tau=0.2,\n", |
435 | | - " throttle=1.0,\n", |
| 431 | + " throttle_time_constant=0.5,\n", |
436 | 432 | " return_controller=True,\n", |
437 | | - " clamp=True,\n", |
438 | | - ")\n", |
439 | | - "print(\"has add_throttle_control:\", hasattr(HALCYON, \"add_throttle_control\"))\n", |
440 | | - "print(\"has throttle_control:\", hasattr(HALCYON, \"throttle_control\"))\n", |
441 | | - "print(\"throttle_control:\", getattr(HALCYON, \"throttle_control\", None))" |
| 433 | + ")" |
442 | 434 | ] |
443 | 435 | }, |
444 | 436 | { |
|
497 | 489 | "time1, ax, ay, az = zip(*accelerometer_clean.measured_data)\n", |
498 | 490 | "time2, gx, gy, gz = zip(*gyro_clean.measured_data)\n", |
499 | 491 | "\n", |
500 | | - "# plt.plot(time1, ax, label=\"Accelerometer X\")\n", |
501 | | - "# plt.plot(time1, ay, label=\"Accelerometer Y\")\n", |
502 | | - "# plt.plot(time1, az, label=\"Accelerometer Z\")\n", |
503 | | - "# plt.xlabel(\"Time (s)\")\n", |
504 | | - "# plt.ylabel(\"Acceleration (m/s^2)\")\n", |
505 | | - "# plt.legend()\n", |
506 | | - "# plt.grid()\n", |
507 | | - "# plt.show()\n", |
508 | | - "\n", |
509 | 492 | "plt.plot(time2, gx, label=\"Gyroscope X\")\n", |
510 | 493 | "plt.plot(time2, gy, label=\"Gyroscope Y\")\n", |
511 | 494 | "plt.plot(time2, gz, label=\"Gyroscope Z\")\n", |
|
538 | 521 | ], |
539 | 522 | "metadata": { |
540 | 523 | "kernelspec": { |
541 | | - "display_name": ".venv (3.12.10)", |
| 524 | + "display_name": ".venv (3.14.3)", |
542 | 525 | "language": "python", |
543 | 526 | "name": "python3" |
544 | 527 | }, |
|
552 | 535 | "name": "python", |
553 | 536 | "nbconvert_exporter": "python", |
554 | 537 | "pygments_lexer": "ipython3", |
555 | | - "version": "3.12.10" |
| 538 | + "version": "3.14.3" |
556 | 539 | } |
557 | 540 | }, |
558 | 541 | "nbformat": 4, |
|
0 commit comments