- Move C++ sources to core/ subdirectory (T05) - Add pnpm workspaces + Turborepo pipeline (T06) - Add Emscripten CMake target and build-wasm.sh (T07) - Implement Embind bindings via YmirBindings.cpp (T08) - Add packages/types with TypeBox schemas for VesselDTO, ScenarioDTO, SimulationStateDTO (T09) - Create apps/api: Fastify v4 + Drizzle ORM + SQLite with vessels/scenarios CRUD (T10-T13) - Create apps/web: Vite + React 18 + COOP/COEP headers (T14) - Add simulation.worker.ts for WASM loop in Web Worker (T15) - Add Zustand simulationStore (T16) - Add TelemetryPanel component (T17) - Verified: pnpm build 3/3 tasks, 21ms cached; ctest 211/211 pass (T18-T19) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
59 lines
1.5 KiB
C++
59 lines
1.5 KiB
C++
#include <catch2/catch_test_macros.hpp>
|
|
#include <catch2/matchers/catch_matchers_floating_point.hpp>
|
|
|
|
#include <ymir/physics/RigidBody6DOF.h>
|
|
#include <ymir/simulation/Simulation.h>
|
|
|
|
#include <memory>
|
|
|
|
using Catch::Matchers::WithinAbs;
|
|
using namespace ymir;
|
|
|
|
static std::unique_ptr<RigidBody6DOF> makeRestingBody(int id, double mass = 1000.0)
|
|
{
|
|
Matrix6x6 M{};
|
|
for (int i = 0; i < 6; ++i) M[i][i] = mass;
|
|
Matrix6x6 A{};
|
|
Vector6 q{}, qdot{};
|
|
return std::make_unique<RigidBody6DOF>(id, M, A, q, qdot);
|
|
}
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
TEST_CASE("Simulation: single body at rest with no forces stays at rest", "[integration]")
|
|
{
|
|
Simulation sim;
|
|
sim.addBody(0, makeRestingBody(0));
|
|
|
|
for (int i = 0; i < 100; ++i)
|
|
sim.step(0.1);
|
|
|
|
BodyState s = sim.state(0);
|
|
for (int i = 0; i < 6; ++i)
|
|
{
|
|
REQUIRE_THAT(s.q()[i], WithinAbs(0.0, 1e-10));
|
|
REQUIRE_THAT(s.qdot()[i], WithinAbs(0.0, 1e-10));
|
|
}
|
|
}
|
|
|
|
TEST_CASE("Simulation: multiple bodies at rest with no forces all stay at rest", "[integration]")
|
|
{
|
|
Simulation sim;
|
|
sim.addBody(0, makeRestingBody(0));
|
|
sim.addBody(1, makeRestingBody(1));
|
|
sim.addBody(2, makeRestingBody(2));
|
|
|
|
for (int i = 0; i < 100; ++i)
|
|
sim.step(0.1);
|
|
|
|
for (int id = 0; id < 3; ++id)
|
|
{
|
|
BodyState s = sim.state(id);
|
|
for (int i = 0; i < 6; ++i)
|
|
{
|
|
REQUIRE_THAT(s.q()[i], WithinAbs(0.0, 1e-10));
|
|
REQUIRE_THAT(s.qdot()[i], WithinAbs(0.0, 1e-10));
|
|
}
|
|
}
|
|
}
|