@ -269,14 +269,6 @@ public:
int gen_frame_ ;
bool motion_available_ = false ;
// Measured robot state for context grounding (breaks planner self-feedback loop).
// When enabled, planner context is filled from motor encoders + IMU instead of
// the planner's own previous output. Toggle at runtime with 'm' key.
bool use_measured_context_ = true ;
std : : array < double , 4 > measured_base_quat_ = { 1.0 , 0.0 , 0.0 , 0.0 } ;
std : : array < double , 29 > measured_joint_positions_ = { } ;
bool has_measured_state_ = false ;
protected :
// Common configuration
PlannerConfig config_ ;
@ -295,19 +287,6 @@ public:
return planner_state_ . initialized & & planner_state_ . enabled ;
}
/**
* @ brief Set measured robot state for context grounding .
* Called from the planner thread before UpdatePlanning ( ) .
*/
void SetMeasuredRobotState (
const std : : array < double , 4 > & base_quat ,
const std : : array < double , 29 > & joint_positions )
{
measured_base_quat_ = base_quat ;
measured_joint_positions_ = joint_positions ;
has_measured_state_ = true ;
}
int GetValidModeValueRange ( ) const {
if ( config_ . version = = 2 )
{
@ -576,11 +555,7 @@ public:
// Update context and get frame information
gen_frame_ = gen_frame + config_ . motion_look_ahead_steps ;
if ( use_measured_context_ & & has_measured_state_ ) {
UpdateContextFromMeasuredState ( motion_sequence ) ;
} else {
UpdateContextFromMotion ( motion_sequence ) ;
}
UpdateContextFromMotion ( motion_sequence ) ;
auto gather_input_end_time = std : : chrono : : steady_clock : : now ( ) ;
@ -702,41 +677,6 @@ public:
}
}
/**
* @ brief Blend planner context joint positions toward measured robot state .
*
* Fills all 4 context frames from the planner ' s trajectory first ( preserving
* position , quaternion , and inter - frame velocity ) , then blends ONLY the joint
* positions toward measured values uniformly across all 4 frames . Uniform
* blending preserves inter - frame velocity ( scaled by 1 - alpha ) while pulling
* joint angles toward reality . This prevents self - feedback convergence
* ( knee straightening ) without creating velocity discontinuities .
*
* alpha = 0 : pure self - feedback ( original behavior )
* alpha = 1 : fully measured joints ( may lose velocity info )
* alpha = 0.5 : balanced blend ( recommended starting point )
*/
void UpdateContextFromMeasuredState ( const std : : shared_ptr < const MotionSequence > & motion_sequence )
{
// Fill all 4 frames from planner trajectory (full state + velocity info)
UpdateContextFromMotion ( motion_sequence ) ;
// Blend joint positions toward measured values in all 4 frames uniformly.
// Position and quaternion stay from planner trajectory (no discontinuity).
constexpr float alpha = 0.5f ;
auto context_qpos_values = GetContextBuffer ( ) ;
for ( int n = 0 ; n < 4 ; + + n ) {
int base = n * ( G1_NUM_MOTOR + 7 ) ;
// Only blend joints [7..35], leave position [0..2] and quat [3..6] from planner
for ( int i = 0 ; i < G1_NUM_MOTOR ; i + + ) {
float planner_val = context_qpos_values [ base + 7 + i ] ;
float measured_val = static_cast < float > ( measured_joint_positions_ [ i ] ) ;
context_qpos_values [ base + 7 + i ] =
( 1.0f - alpha ) * planner_val + alpha * measured_val ;
}
}
}
/**
* @ brief Common method signatures that derived classes should implement
*/