Phase 5.1: MechControlsMapper publishes its 20 control-input attributes
Reconstructed the MechControlsMapper attribute table (StickPosition..PilotArray, IDs 3-0x16 chained from Subsystem::NextAttributeID==2) + the real members (stickPosition ControlsJoystick, throttle/pedals/speed/turn Scalars, the look/ torso ControlsButtons, control/display/pilotArray ints) + AttributePointers[] + AttributeIndex (chains Subsystem::AttributeIndex). Fixed the mapper hierarchy statics in BTL4MPPR.CPP: L4/RIO/Thrustmaster ClassDerivations now chain correctly (L4 defined first for static-init order) and all use MechControlsMapper:: AttributeIndex so the mapper instance publishes the control attributes the streamed mappings bind to. Mech still constructs (33 subsystems). The post-construction crash is UNCHANGED (GetAttributePointer, attribute=0x13) -> so it's NOT the mapper; a streamed AttributeWatcher (numeric ID 19) resolves on another object via GetSimulation. Next diagnostic: which object/subsystemID the watcher targets. BT: 42 ok. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -21,11 +21,52 @@ Derivation
|
||||
"MechControlsMapper"
|
||||
);
|
||||
|
||||
//
|
||||
//#############################################################################
|
||||
// Published control-input attributes. The streamed control mappings bind (by
|
||||
// name) to these; the pad entry fills the chain-vs-id gap at id 2.
|
||||
//#############################################################################
|
||||
//
|
||||
const MechControlsMapper::IndexEntry
|
||||
MechControlsMapper::AttributePointers[]=
|
||||
{
|
||||
{ (int)MechControlsMapper::MechControlsMapperPadFirstAttributeID,
|
||||
"MechControlsMapperPad02",
|
||||
(Simulation::AttributePointer)&MechControlsMapper::throttlePosition },
|
||||
ATTRIBUTE_ENTRY(MechControlsMapper, StickPosition, stickPosition),
|
||||
ATTRIBUTE_ENTRY(MechControlsMapper, ThrottlePosition, throttlePosition),
|
||||
ATTRIBUTE_ENTRY(MechControlsMapper, PedalsPosition, pedalsPosition),
|
||||
ATTRIBUTE_ENTRY(MechControlsMapper, ReverseThrust, reverseThrust),
|
||||
ATTRIBUTE_ENTRY(MechControlsMapper, SpeedDemand, speedDemand),
|
||||
ATTRIBUTE_ENTRY(MechControlsMapper, TurnDemand, turnDemand),
|
||||
ATTRIBUTE_ENTRY(MechControlsMapper, LookForward, lookForward),
|
||||
ATTRIBUTE_ENTRY(MechControlsMapper, LookLeft, lookLeft),
|
||||
ATTRIBUTE_ENTRY(MechControlsMapper, LookRight, lookRight),
|
||||
ATTRIBUTE_ENTRY(MechControlsMapper, LookBehind, lookBehind),
|
||||
ATTRIBUTE_ENTRY(MechControlsMapper, LookDown, lookDown),
|
||||
ATTRIBUTE_ENTRY(MechControlsMapper, TorsoUp, torsoUp),
|
||||
ATTRIBUTE_ENTRY(MechControlsMapper, TorsoDown, torsoDown),
|
||||
ATTRIBUTE_ENTRY(MechControlsMapper, TorsoLeft, torsoLeft),
|
||||
ATTRIBUTE_ENTRY(MechControlsMapper, TorsoRight, torsoRight),
|
||||
ATTRIBUTE_ENTRY(MechControlsMapper, TorsoCenter, torsoCenter),
|
||||
ATTRIBUTE_ENTRY(MechControlsMapper, ControlMode, controlMode),
|
||||
ATTRIBUTE_ENTRY(MechControlsMapper, DisplayMode, displayMode),
|
||||
ATTRIBUTE_ENTRY(MechControlsMapper, PilotArrayPage, pilotArrayPage),
|
||||
ATTRIBUTE_ENTRY(MechControlsMapper, PilotArray, pilotArray)
|
||||
};
|
||||
|
||||
MechControlsMapper::AttributeIndexSet
|
||||
MechControlsMapper::AttributeIndex(
|
||||
ELEMENTS(MechControlsMapper::AttributePointers),
|
||||
MechControlsMapper::AttributePointers,
|
||||
Subsystem::AttributeIndex
|
||||
);
|
||||
|
||||
MechControlsMapper::SharedData
|
||||
MechControlsMapper::DefaultData(
|
||||
MechControlsMapper::ClassDerivations,
|
||||
Subsystem::MessageHandlers,
|
||||
Subsystem::AttributeIndex,
|
||||
MechControlsMapper::AttributeIndex,
|
||||
1
|
||||
);
|
||||
|
||||
@@ -46,12 +87,32 @@ MechControlsMapper::MechControlsMapper(
|
||||
{
|
||||
Check(owner);
|
||||
//
|
||||
// The mapper is the Mech's active control Performance; per-frame control
|
||||
// interpretation (InterpretControls) is reconstructed with the mech2/3/4
|
||||
// simulation (phase 5). Prime the published control state to neutral.
|
||||
// Prime the published control inputs to neutral. Per-frame interpretation
|
||||
// (InterpretControls) is reconstructed with the mech2/3/4 sim (phase 5.3).
|
||||
//
|
||||
stickPosition.x = 0.0f;
|
||||
stickPosition.y = 0.0f;
|
||||
throttlePosition = 0.0f;
|
||||
pedalsPosition = 0.0f;
|
||||
reverseThrust = 0;
|
||||
speedDemand = 0.0f;
|
||||
turnDemand = 0.0f;
|
||||
lookForward = 0;
|
||||
lookLeft = 0;
|
||||
lookRight = 0;
|
||||
lookBehind = 0;
|
||||
lookDown = 0;
|
||||
torsoUp = 0;
|
||||
torsoDown = 0;
|
||||
torsoLeft = 0;
|
||||
torsoRight = 0;
|
||||
torsoCenter = 0;
|
||||
controlMode = BasicMode;
|
||||
displayMode = 0;
|
||||
pilotArrayPage = 0;
|
||||
pilotArray = 0;
|
||||
{
|
||||
for (int i = 0; i < 64; ++i)
|
||||
for (int i = 0; i < 24; ++i)
|
||||
{
|
||||
reserved[i] = 0;
|
||||
}
|
||||
|
||||
@@ -23,6 +23,14 @@
|
||||
# include <cstr.hpp>
|
||||
# endif
|
||||
|
||||
# if !defined(CONTROLS_HPP)
|
||||
# include <controls.hpp>
|
||||
# endif
|
||||
|
||||
# if !defined(VECTOR2D_HPP)
|
||||
# include <vector2d.hpp>
|
||||
# endif
|
||||
|
||||
//##################### Forward Class Declarations #######################
|
||||
class Mech;
|
||||
|
||||
@@ -39,7 +47,39 @@
|
||||
public:
|
||||
static Derivation ClassDerivations;
|
||||
static SharedData DefaultData;
|
||||
static MessageHandlerSet MessageHandlers;
|
||||
|
||||
static const IndexEntry AttributePointers[];
|
||||
static AttributeIndexSet AttributeIndex;
|
||||
|
||||
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// Attribute IDs -- the control inputs the streamed mappings bind to.
|
||||
// The chain ends at Subsystem::NextAttributeID == 2.
|
||||
//
|
||||
public:
|
||||
enum {
|
||||
MechControlsMapperPadFirstAttributeID = 2,
|
||||
StickPositionAttributeID, // 3
|
||||
ThrottlePositionAttributeID, // 4
|
||||
PedalsPositionAttributeID, // 5
|
||||
ReverseThrustAttributeID, // 6
|
||||
SpeedDemandAttributeID, // 7
|
||||
TurnDemandAttributeID, // 8
|
||||
LookForwardAttributeID, // 9
|
||||
LookLeftAttributeID, // a
|
||||
LookRightAttributeID, // b
|
||||
LookBehindAttributeID, // c
|
||||
LookDownAttributeID, // d
|
||||
TorsoUpAttributeID, // e
|
||||
TorsoDownAttributeID, // f
|
||||
TorsoLeftAttributeID, // 10
|
||||
TorsoRightAttributeID, // 11
|
||||
TorsoCenterAttributeID, // 12
|
||||
ControlModeAttributeID, // 13
|
||||
DisplayModeAttributeID, // 14
|
||||
PilotArrayPageAttributeID, // 15
|
||||
PilotArrayAttributeID, // 16
|
||||
NextAttributeID
|
||||
};
|
||||
|
||||
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// Control modes
|
||||
@@ -69,10 +109,31 @@
|
||||
TestInstance() const;
|
||||
|
||||
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// Local Data
|
||||
// Local Data -- the published control inputs (the streamed mappings write
|
||||
// these; InterpretControls, phase 5.3, reads them to drive the mech).
|
||||
//
|
||||
protected:
|
||||
int reserved[64];
|
||||
ControlsJoystick stickPosition;
|
||||
Scalar throttlePosition;
|
||||
Scalar pedalsPosition;
|
||||
ControlsButton reverseThrust;
|
||||
Scalar speedDemand;
|
||||
Scalar turnDemand;
|
||||
ControlsButton lookForward;
|
||||
ControlsButton lookLeft;
|
||||
ControlsButton lookRight;
|
||||
ControlsButton lookBehind;
|
||||
ControlsButton lookDown;
|
||||
ControlsButton torsoUp;
|
||||
ControlsButton torsoDown;
|
||||
ControlsButton torsoLeft;
|
||||
ControlsButton torsoRight;
|
||||
ControlsButton torsoCenter;
|
||||
int controlMode;
|
||||
int displayMode;
|
||||
int pilotArrayPage;
|
||||
int pilotArray;
|
||||
int reserved[24];
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -13,34 +13,12 @@
|
||||
# include <btl4mppr.hpp>
|
||||
#endif
|
||||
|
||||
Derivation
|
||||
MechThrustmasterMapper::ClassDerivations(
|
||||
Subsystem::ClassDerivations,
|
||||
"MechThrustmasterMapper"
|
||||
);
|
||||
|
||||
MechThrustmasterMapper::SharedData
|
||||
MechThrustmasterMapper::DefaultData(
|
||||
MechThrustmasterMapper::ClassDerivations,
|
||||
Subsystem::MessageHandlers,
|
||||
Subsystem::AttributeIndex,
|
||||
1
|
||||
);
|
||||
|
||||
Derivation
|
||||
MechRIOMapper::ClassDerivations(
|
||||
Subsystem::ClassDerivations,
|
||||
"MechRIOMapper"
|
||||
);
|
||||
|
||||
MechRIOMapper::SharedData
|
||||
MechRIOMapper::DefaultData(
|
||||
MechRIOMapper::ClassDerivations,
|
||||
Subsystem::MessageHandlers,
|
||||
Subsystem::AttributeIndex,
|
||||
1
|
||||
);
|
||||
|
||||
//
|
||||
// NOTE: define L4MechControlsMapper's statics FIRST -- the RIO/Thrustmaster
|
||||
// derivations chain it, so it must construct before them. All three mappers'
|
||||
// DefaultData use MechControlsMapper::AttributeIndex so the mapper instance
|
||||
// publishes the control-input attributes the streamed mappings bind to.
|
||||
//
|
||||
Derivation
|
||||
L4MechControlsMapper::ClassDerivations(
|
||||
MechControlsMapper::ClassDerivations,
|
||||
@@ -51,7 +29,35 @@ L4MechControlsMapper::SharedData
|
||||
L4MechControlsMapper::DefaultData(
|
||||
L4MechControlsMapper::ClassDerivations,
|
||||
Subsystem::MessageHandlers,
|
||||
Subsystem::AttributeIndex,
|
||||
MechControlsMapper::AttributeIndex,
|
||||
1
|
||||
);
|
||||
|
||||
Derivation
|
||||
MechThrustmasterMapper::ClassDerivations(
|
||||
L4MechControlsMapper::ClassDerivations,
|
||||
"MechThrustmasterMapper"
|
||||
);
|
||||
|
||||
MechThrustmasterMapper::SharedData
|
||||
MechThrustmasterMapper::DefaultData(
|
||||
MechThrustmasterMapper::ClassDerivations,
|
||||
Subsystem::MessageHandlers,
|
||||
MechControlsMapper::AttributeIndex,
|
||||
1
|
||||
);
|
||||
|
||||
Derivation
|
||||
MechRIOMapper::ClassDerivations(
|
||||
L4MechControlsMapper::ClassDerivations,
|
||||
"MechRIOMapper"
|
||||
);
|
||||
|
||||
MechRIOMapper::SharedData
|
||||
MechRIOMapper::DefaultData(
|
||||
MechRIOMapper::ClassDerivations,
|
||||
Subsystem::MessageHandlers,
|
||||
MechControlsMapper::AttributeIndex,
|
||||
1
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user