PlayRho
1.1.0
An Interactive Real-Time-Oriented C++ Physics Engine & Library
|
|
This is the googletest
based unit testing file for the interfaces to playrho::d2::WheelJointConf
.
#include "UnitTests.hpp"
#include <PlayRho/Dynamics/Joints/Joint.hpp>
#include <PlayRho/Dynamics/Joints/WheelJointConf.hpp>
#include <PlayRho/Dynamics/World.hpp>
#include <PlayRho/Dynamics/BodyConf.hpp>
#include <PlayRho/Dynamics/WorldBody.hpp>
#include <PlayRho/Dynamics/WorldFixture.hpp>
#include <PlayRho/Dynamics/WorldJoint.hpp>
#include <PlayRho/Dynamics/WorldMisc.hpp>
#include <PlayRho/Dynamics/StepConf.hpp>
#include <PlayRho/Collision/Shapes/DiskShapeConf.hpp>
#include <cstring>
{
case 4:
break;
case 8:
break;
case 16:
break;
default:
FAIL();
break;
}
}
{
EXPECT_EQ(def.collideConnected, false);
EXPECT_EQ(def.localAnchorA, (
Length2{}));
EXPECT_EQ(def.localAnchorB, (
Length2{}));
EXPECT_FALSE(def.enableMotor);
EXPECT_EQ(def.maxMotorTorque,
Torque(0));
EXPECT_EQ(def.motorSpeed, 0_rpm);
EXPECT_EQ(def.frequency, 2_Hz);
EXPECT_EQ(def.dampingRatio,
Real(0.7f));
}
{
}
{
EXPECT_EQ(
GetType(joint), GetTypeID<WheelJointConf>());
}
{
jd.bodyB = b1;
jd.localAnchorA =
Length2(4_m, 5_m);
jd.localAnchorB =
Length2(6_m, 7_m);
}
{
jd.bodyB = b1;
jd.localAnchorA =
Length2(4_m, 5_m);
jd.localAnchorB =
Length2(6_m, 7_m);
const auto newValue = 5_rad / 1_s;
}
{
jd.bodyB = b1;
jd.localAnchorA =
Length2(4_m, 5_m);
jd.localAnchorB =
Length2(6_m, 7_m);
const auto newValue = 5_Nm;
}
{
const auto loc0 =
Length2{+1_m, -3_m};
jd.bodyB = b1;
jd.localAnchorA =
Length2(4_m, 5_m);
jd.localAnchorB =
Length2(6_m, 7_m);
EXPECT_EQ(
GetAnchorA(world, joint), loc0 + jd.localAnchorA);
EXPECT_EQ(
GetAnchorB(world, joint), loc1 + jd.localAnchorB);
}
{
const auto loc0 =
Length2{+1_m, -3_m};
const auto loc1 =
Length2{+1_m, +3_m};
jd.bodyB = b1;
jd.localAnchorA =
Length2(-1_m, 5_m);
jd.localAnchorB =
Length2(+1_m, 5_m);
}
{
ASSERT_EQ(
GetType(joint), GetTypeID<WheelJointConf>());
EXPECT_EQ(cdef.collideConnected, false);
EXPECT_EQ(cdef.localAnchorA, (
Length2{}));
EXPECT_EQ(cdef.localAnchorB, (
Length2{}));
EXPECT_FALSE(cdef.enableMotor);
EXPECT_EQ(cdef.maxMotorTorque,
Torque(0));
EXPECT_EQ(cdef.motorSpeed, 0_rpm);
EXPECT_EQ(cdef.frequency, 2_Hz);
EXPECT_EQ(cdef.dampingRatio,
Real(0.7f));
}
{
const auto p1 =
Length2{-1_m, 0_m};
const auto p2 =
Length2{+1_m, 0_m};
const auto anchor =
Length2(2_m, 1_m);
0.1);
stepConf.doWarmStart = false;
0.1);
}
{
EXPECT_EQ(angularVelocity, 0_rpm);
}
{
}
{
{
EXPECT_TRUE(conf == conf);
}
{
EXPECT_TRUE(conf == conf);
}
{
EXPECT_TRUE(conf == conf);
}
}
{
{
EXPECT_FALSE(conf != conf);
}
}
{
EXPECT_STREQ(
GetName(GetTypeID<WheelJointConf>()),
"d2::WheelJointConf");
}
UnitVec localYAxisA
The local Y translation axis in body-A.
Definition: WheelJointConf.hpp:112
@ Static
Static body type.
BodyID CreateBody(World &world, const BodyConf &def)
Creates a rigid body with the given configuration.
Definition: WorldBody.cpp:58
constexpr BodyConf & UseType(BodyType t) noexcept
Use the given type.
Definition: BodyConf.hpp:166
PLAYRHO_QUANTITY(boost::units::si::length) Length
Length quantity.
Definition: Units.hpp:158
BodyID CreateBody(const BodyConf &def=GetDefaultBodyConf())
Creates a rigid body with the given configuration.
Definition: World.cpp:161
PLAYRHO_QUANTITY(boost::units::si::torque) Torque
Torque quantity.
Definition: Units.hpp:255
WheelJointConf GetWheelJointConf(const Joint &joint)
Gets the definition data for the given joint.
Definition: WheelJointConf.cpp:73
Name space for 2-dimensionally related PlayRho names.
Definition: AABB.cpp:34
BodyID bodyA
1st attached body.
Definition: JointConf.hpp:36
UnitVec GetLocalYAxisA(const Joint &object)
Gets the given joint's local Y axis A if its type supports that.
Definition: Joint.cpp:242
static constexpr UnitVec GetRight() noexcept
Gets the right-ward oriented unit vector.
Definition: UnitVec.hpp:74
constexpr auto InvalidJointID
Invalid joint ID value.
Definition: JointID.hpp:33
constexpr void SetFrequency(DistanceJointConf &object, NonNegative< Frequency > value) noexcept
Free function for setting the frequency value of the given configuration.
Definition: DistanceJointConf.hpp:205
Real dampingRatio
Suspension damping ratio, one indicates critical damping.
Definition: WheelJointConf.hpp:127
const char * GetName(Manifold::Type type) noexcept
Gets a unique name for the given manifold type.
Definition: Manifold.cpp:788
constexpr ConcreteConf & UseDensity(NonNegative< AreaDensity > value) noexcept
Uses the given density.
Definition: ShapeConf.hpp:111
constexpr auto & GetX(T &value)
Gets the "X" element of the given value - i.e. the first element.
Definition: Math.hpp:66
Name space for all PlayRho related names.
Definition: AABB.cpp:33
void SetMaxMotorTorque(Joint &object, Torque value)
Sets the given joint's max motor torque if its type supports that.
Definition: Joint.cpp:363
AngularVelocity GetAngularVelocity(const Body &body) noexcept
Gets the angular velocity.
Definition: Body.hpp:1178
Length2 GetLocalAnchorA(const Joint &object)
Get the anchor point on body-A in local coordinates.
Definition: Joint.cpp:62
Length GetJointTranslation(const World &world, JointID id)
Gets the current joint translation.
Definition: WorldJoint.cpp:229
constexpr auto RadianPerSecond
Radian per second unit of angular velocity.
Definition: Units.hpp:384
Definition of an independent and simulatable "world".
Definition: World.hpp:129
Length2 GetAnchorB(const World &world, JointID id)
Get the anchor point on body-B in world coordinates.
Definition: WorldJoint.cpp:216
constexpr auto NewtonMeter
Newton meter unit of torque.
Definition: Units.hpp:408
void EnableMotor(Joint &object, bool value)
Enables the specified joint's motor property if it supports one.
Definition: Joint.cpp:575
constexpr bool ShiftOrigin(DistanceJointConf &, Length2) noexcept
Shifts the origin notion of the given configuration.
Definition: DistanceJointConf.hpp:177
Torque GetMotorTorque(const Joint &joint, Frequency inv_dt)
Gets the current motor torque for the given joint given the inverse time step.
Definition: Joint.hpp:791
BodyID GetBodyB(const Contact &contact) noexcept
Gets the body B ID of the given contact.
Definition: Contact.hpp:588
constexpr auto StripUnit(const T &v) -> decltype(StripUnit(v.get()))
Strips the unit from the given value.
Definition: Math.hpp:121
bool GetCollideConnected(const Joint &object) noexcept
Gets collide connected.
Definition: Joint.hpp:293
BodyID GetBodyA(const Contact &contact) noexcept
Gets the body A ID of the given contact.
Definition: Contact.hpp:581
constexpr BodyConf & UseLocation(Length2 l) noexcept
Use the given location.
Definition: BodyConf.hpp:172
bool IsMotorEnabled(const Joint &object)
Gets the specified joint's motor property value if it supports one.
Definition: Joint.cpp:560
constexpr auto Meter
Meter unit of Length.
Definition: Units.hpp:337
Length2 localAnchorB
The local anchor point relative to body B's origin.
Definition: WheelJointConf.hpp:106
UnitVec GetLocalXAxisA(const Joint &object)
Gets the given joint's local X axis A if its type supports that.
Definition: Joint.cpp:230
Torque GetMaxMotorTorque(const Joint &object)
Gets the given joint's max motor torque if its type supports that.
Definition: Joint.cpp:351
JointID CreateJoint(WorldImpl &world, const Joint &def)
Creates a new joint.
Definition: WorldImplJoint.cpp:47
Length2 GetLocalAnchorB(const Joint &object)
Get the anchor point on body-B in local coordinates.
Definition: Joint.cpp:96
Template for determining if the given types are addable.
Definition: Templates.hpp:189
Angle GetAngle(const UnitVec value)
Gets the angle of the given unit vector.
Definition: Math.hpp:718
bool doWarmStart
Do warm start.
Definition: StepConf.hpp:269
Wheel joint definition.
Definition: WheelJointConf.hpp:55
constexpr auto InvalidBodyID
Invalid body ID value.
Definition: BodyID.hpp:33
constexpr UnitVec GetRevPerpendicular(const UnitVec vector) noexcept
Gets a vector counter-clockwise (reverse-clockwise) perpendicular to the given vector.
Definition: UnitVec.hpp:330
PLAYRHO_QUANTITY(boost::units::si::angular_momentum) AngularMomentum
Angular momentum quantity.
Definition: Units.hpp:304
Step configuration.
Definition: StepConf.hpp:42
AngularVelocity GetMotorSpeed(const Joint &object)
Gets the given joint's motor speed if its type supports that.
Definition: Joint.cpp:254
Frequency GetFrequency(const Joint &object)
Gets the frequency of the joint if it has this property.
Definition: Joint.cpp:407
RotInertia GetAngularMass(const Joint &object)
Gets the given joint's angular mass.
Definition: Joint.cpp:287
constexpr AngularMomentum GetAngularReaction(const DistanceJointConf &) noexcept
Gets the current angular reaction for the given configuration.
Definition: DistanceJointConf.hpp:170
FixtureID CreateFixture(World &world, FixtureConf def, bool resetMassData)
Creates a fixture within the specified world.
Definition: WorldFixture.cpp:48
float Real
Real-number type.
Definition: Real.hpp:69
constexpr DiskShapeConf & UseRadius(NonNegative< Length > r) noexcept
Uses the given value as the radius.
Definition: DiskShapeConf.hpp:65
Configuration for a body.
Definition: BodyConf.hpp:50
constexpr Length2 GetLocation(const Transformation &value) noexcept
Gets the location information from the given transformation.
Definition: Transformation.hpp:69
Length2 localAnchorA
The local anchor point relative to body A's origin.
Definition: WheelJointConf.hpp:103
detail::IndexingNamedType< BodyCounter, struct BodyIdentifier > BodyID
Identifier for bodies.
Definition: BodyID.hpp:30
bool enableMotor
Enable/disable the joint motor.
Definition: WheelJointConf.hpp:115
Real GetDampingRatio(const Joint &object)
Gets the given joint's damping ratio property if it has one.
Definition: Joint.cpp:389
void SetMotorSpeed(Joint &object, AngularVelocity value)
Sets the given joint's motor speed if its type supports that.
Definition: Joint.cpp:269
Torque maxMotorTorque
The maximum motor torque.
Definition: WheelJointConf.hpp:118
Vector.
Definition: Vector.hpp:49
Length2 GetAnchorA(const World &world, JointID id)
Get the anchor point on body-A in world coordinates.
Definition: WorldJoint.cpp:208
TypeID GetType(const Shape &shape) noexcept
Gets the type info of the use of the given shape.
Definition: Shape.hpp:329
typename detail::IsIterableImpl< T > IsIterable
Determines whether the given type is an iterable type.
Definition: Templates.hpp:225
constexpr Momentum2 GetLinearReaction(const DistanceJointConf &object) noexcept
Gets the current linear reaction for the given configuration.
Definition: DistanceJointConf.hpp:163
AngularVelocity motorSpeed
The desired angular motor speed.
Definition: WheelJointConf.hpp:121
PLAYRHO_QUANTITY(boost::units::si::moment_of_inertia) RotInertia
Rotational inertia quantity.
Definition: Units.hpp:274
A joint-like constraint on one or more bodies.
Definition: Joint.hpp:144
BodyID bodyB
2nd attached body.
Definition: JointConf.hpp:39
Shape.
Definition: Shape.hpp:183
constexpr auto & GetY(T &value)
Gets the "Y" element of the given value - i.e. the second element.
Definition: Math.hpp:73
Vector2< Length > Length2
2-element vector of Length quantities.
Definition: Vector2.hpp:43
UnitVec localXAxisA
The local X translation axis in body-A.
Definition: WheelJointConf.hpp:109
NonNegative< Frequency > frequency
Suspension frequency, zero indicates no suspension.
Definition: WheelJointConf.hpp:124
StepStats Step(WorldImpl &world, const StepConf &conf)
Steps the given world the specified amount.
Definition: WorldImplMisc.cpp:85
bool collideConnected
Collide connected.
Definition: JointConf.hpp:43
PLAYRHO_QUANTITY(boost::units::si::angular_velocity) AngularVelocity
Angular velocity quantity.
Definition: Units.hpp:225
Disk shape configuration.
Definition: DiskShapeConf.hpp:42