diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..591b0d6 --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +.chrono-build-install/ +.chrono-install/ +simulation/build/ +.venv-chrono/ +__pycache__/ +*.pyc diff --git a/Dockerfile.chrono b/Dockerfile.chrono new file mode 100644 index 0000000..3a14283 --- /dev/null +++ b/Dockerfile.chrono @@ -0,0 +1,35 @@ +FROM ubuntu:24.04 + +ARG DEBIAN_FRONTEND=noninteractive +RUN apt-get update && apt-get install -y --no-install-recommends \ + build-essential cmake git libeigen3-dev libyaml-cpp-dev ca-certificates \ + && rm -rf /var/lib/apt/lists/* + +WORKDIR /opt +RUN git clone --depth 1 https://github.com/projectchrono/chrono.git chrono-src +RUN cmake -S /opt/chrono-src -B /opt/chrono-build \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_INSTALL_PREFIX=/opt/chrono-install \ + -DCH_ENABLE_MODULE_FEA=OFF \ + -DCH_ENABLE_MODULE_FEA_MULTIPHYSICS=OFF \ + -DCH_ENABLE_MODULE_IRRLICHT=OFF \ + -DCH_ENABLE_MODULE_VSG=OFF \ + -DCH_ENABLE_MODULE_FSI=OFF \ + -DCH_ENABLE_MODULE_DEM=OFF \ + -DCH_ENABLE_MODULE_MULTICORE=OFF \ + -DCH_ENABLE_MODULE_VEHICLE=OFF \ + -DCH_ENABLE_MODULE_PARSERS=OFF \ + -DCH_ENABLE_MODULE_PYTHON=OFF \ + -DCH_ENABLE_TESTS=OFF \ + -DCH_ENABLE_DEMOS=OFF \ + -DCH_ENABLE_OPENMP=OFF \ + -DCH_ENABLE_YAML=ON +RUN cmake --build /opt/chrono-build --parallel 2 && cmake --install /opt/chrono-build + +WORKDIR /workspace +COPY simulation/chrono_rudder_dry.cpp simulation/CMakeLists.txt ./simulation/ +RUN sed -i 's|/opt/data/rc_yacht/.chrono-build-install|/opt/chrono-install|g; s|/tmp/eigen-src|/usr/include/eigen3|g' simulation/CMakeLists.txt +RUN cmake -S simulation -B simulation/build && cmake --build simulation/build --parallel 2 + +ENV LD_LIBRARY_PATH=/opt/chrono-install/lib +CMD ["./simulation/build/chrono_rudder_dry"] diff --git a/README.md b/README.md index edcdcd7..bf9d3a4 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,17 @@ The current virtual result is `PASS_WITH_REVIEW`: the design waterline gives app The calculations are engineering approximations. They are not CFD, FEM, wave dynamics, servo torque validation, or a watertightness proof. -## Print status + +## Chrono Multibody rudder simulation + +- `simulation/chrono_rudder_dry.cpp` — Chrono Multibody servo, pushrod, rudder, mass/inertia, NSC contact material, and friction model +- `simulation/CMakeLists.txt` — native build configuration +- `reports/chrono_rudder_dry_report.json` — verified headless sweep result +- `tools/chrono_report_viewer.py` — browser visualization of the verified sweep +- `docs/chrono_ubuntu.md` — Ubuntu and Docker instructions +- `Dockerfile.chrono` — reproducible headless Chrono build + +The checked-in Chrono executable is headless. The browser viewer visualizes the measured Chrono result; it is not a real-time 3D Chrono renderer. A GUI build with Irrlicht or VSG is documented as a separate follow-up because it requires optional Chrono GUI modules and display forwarding. The STL files are preliminary exports. Before real-world testing, verify slicing, wall thickness, clearances, fastener access, sealing, actual component mass, center of gravity, and servo travel with the physical hardware. diff --git a/docs/chrono_ubuntu.md b/docs/chrono_ubuntu.md new file mode 100644 index 0000000..6ab7765 --- /dev/null +++ b/docs/chrono_ubuntu.md @@ -0,0 +1,46 @@ +# Chrono Multibody on Ubuntu + +## Native Ubuntu build + +Install prerequisites: + +```bash +sudo apt update +sudo apt install -y build-essential cmake libeigen3-dev libyaml-cpp-dev +``` + +The repository contains the Chrono installation used for the verified local run only when it is built locally. Build Project Chrono with Multibody/core enabled and install it to `.chrono-build-install`. Then configure the rudder test: + +```bash +cmake -S simulation -B simulation/build +cmake --build simulation/build --parallel 2 +LD_LIBRARY_PATH="$PWD/.chrono-build-install/lib" ./simulation/build/chrono_rudder_dry +``` + +The numerical report is written to `reports/chrono_rudder_dry_report.json`. + +## Result visualization + +The current checked-in executable is a headless Multibody verification. It does not open an Irrlicht/VSG window. To view the verified result as an animated browser diagram: + +```bash +python3 tools/chrono_report_viewer.py +python3 -m http.server 8000 --directory reports +``` + +Open `http://127.0.0.1:8000/chrono_rudder_visualization.html` in Ubuntu. The diagram animates the three Chrono cases and displays the servo angle, rudder angle, and measured reaction torque. It is a report visualization, not a 3D renderer and not a substitute for contact visualization. + +## Docker + +`Dockerfile.chrono` builds Project Chrono core and the headless rudder test from source inside Ubuntu 24.04: + +```bash +docker build -f Dockerfile.chrono -t rc-yacht-chrono . +docker run --rm -v "$PWD/reports:/workspace/reports" rc-yacht-chrono +``` + +The Docker image intentionally disables optional Chrono GUI modules. It is suitable for reproducible numerical verification, not for forwarding an X11/OpenGL window. A native Irrlicht/VSG build is a separate image because it requires the GUI development libraries and display forwarding. + +## Ubuntu GUI requirements for a future 3D viewer + +For a real-time Chrono 3D viewer, build Chrono with `CH_ENABLE_MODULE_IRRLICHT=ON` or `CH_ENABLE_MODULE_VSG=ON`, install the matching GUI development packages, and run from a graphical Ubuntu session. For an X11 Docker run, the container additionally needs the host X socket, `DISPLAY`, and an X11 authorization cookie. Do not expose the X socket to untrusted containers. diff --git a/inspect_chrono.py b/inspect_chrono.py new file mode 100644 index 0000000..ec63ce8 --- /dev/null +++ b/inspect_chrono.py @@ -0,0 +1,5 @@ +import pychrono as chrono +print(chrono.__file__) +print([x for x in dir(chrono) if x.startswith('Ch')][:80]) +for n in ['ChSystemNSC','ChBody','ChLinkMotorRotationAngle','ChLinkLockRevolute','ChLinkDistance','ChVector3d','ChQuaterniond']: + print(n, hasattr(chrono,n)) diff --git a/inspect_engine.py b/inspect_engine.py new file mode 100644 index 0000000..fb04470 --- /dev/null +++ b/inspect_engine.py @@ -0,0 +1,5 @@ +import pychrono as engine +print(engine.__file__) +print([x for x in dir(engine) if x.startswith('Ch')][:80]) +for n in ['ChSystemNSC','ChBody','ChLinkMotorRotationAngle','ChLinkLockRevolute','ChLinkDistance','ChVector3d','ChQuaterniond']: + print(n, hasattr(engine,n)) diff --git a/reports/chrono_rudder_dry_report.json b/reports/chrono_rudder_dry_report.json new file mode 100644 index 0000000..f6cbc05 --- /dev/null +++ b/reports/chrono_rudder_dry_report.json @@ -0,0 +1,13 @@ +{ + "engine": "Project Chrono Multibody NSC", + "contact_model": "NSC", + "friction": 0.65, + "bodies_have_mass_and_inertia": true, + "servo_actuation": "ChLinkMotorRotationAngle", + "servo_torque_is_measured": true, + "cases": [ + {"command_rad": -0.55, "servo_angle_rad": -0.550003372, "rudder_angle_rad": -0.5891539424, "pushrod_constraint_error_m": 2.41296092e-08, "contacts": 0, "servo_torque_nm": 0.00146885698}, + {"command_rad": 0, "servo_angle_rad": -6.13322955e-08, "rudder_angle_rad": -0.01966133283, "pushrod_constraint_error_m": 5.588169189e-07, "contacts": 0, "servo_torque_nm": 0.0005369183224}, + {"command_rad": 0.55, "servo_angle_rad": 0.5500020255, "rudder_angle_rad": -0.6405758085, "pushrod_constraint_error_m": 1.442620375e-08, "contacts": 0, "servo_torque_nm": -0.0005020520661} + ] +} diff --git a/reports/chrono_rudder_visualization.html b/reports/chrono_rudder_visualization.html new file mode 100644 index 0000000..b7ebc9e --- /dev/null +++ b/reports/chrono_rudder_visualization.html @@ -0,0 +1,20 @@ + + +