🥽 Makes use of Atan2 to calculate lateral fraction
This commit is contained in:
+5
-6
@@ -289,7 +289,6 @@ export class BezierState extends GaitState {
|
||||
this.step_length = Math.sqrt(this.gait_state.step_x ** 2 + this.gait_state.step_z ** 2);
|
||||
if (this.gait_state.step_x < 0) {
|
||||
this.step_length = -this.step_length;
|
||||
this.gait_state.step_z = -this.gait_state.step_z;
|
||||
}
|
||||
this.update_phase();
|
||||
this.update_feet_positions();
|
||||
@@ -335,7 +334,7 @@ export class BezierState extends GaitState {
|
||||
...args: number[]
|
||||
) {
|
||||
let length = this.step_length / 2;
|
||||
let angle = (this.gait_state.step_z * Math.PI) / 2;
|
||||
let angle = Math.atan2(this.gait_state.step_z, this.step_length) * 2;
|
||||
const delta_pos = controller(length, angle, ...args, this.phase);
|
||||
|
||||
length = this.gait_state.step_angle * 2;
|
||||
@@ -358,13 +357,13 @@ const stance_curve = (length: number, angle: number, depth: number, phase: numbe
|
||||
|
||||
const step = length * (1 - 2 * phase);
|
||||
const X = step * X_POLAR;
|
||||
const Y = step * Y_POLAR;
|
||||
let Z = 0;
|
||||
const Z = step * Y_POLAR;
|
||||
let Y = 0;
|
||||
|
||||
if (length !== 0) {
|
||||
Z = -depth * Math.cos((Math.PI * (X + Y)) / (2 * length));
|
||||
Y = -depth * Math.cos((Math.PI * (X + Y)) / (2 * length));
|
||||
}
|
||||
return [X, Z, Y];
|
||||
return [X, Y, Z];
|
||||
};
|
||||
|
||||
const yawArc = (default_foot_pos: number[], current_foot_pos: number[]): number => {
|
||||
|
||||
@@ -220,7 +220,6 @@ class BezierState : public GaitState {
|
||||
step_length = std::sqrt(gait_state.step_x * gait_state.step_x + gait_state.step_z * gait_state.step_z);
|
||||
if (gait_state.step_x < 0.0f) {
|
||||
step_length = -step_length;
|
||||
gait_state.step_z = -gait_state.step_z;
|
||||
}
|
||||
updatePhase(dt);
|
||||
updateFeetPositions(body_state);
|
||||
@@ -261,7 +260,7 @@ class BezierState : public GaitState {
|
||||
void controller(const int index, body_state_t &body_state,
|
||||
std::function<void(float, float, float *, float, float *)> curve, float *arg) {
|
||||
float length = step_length / 2.0f;
|
||||
float angle = gait_state.step_z * M_PI_2;
|
||||
float angle = std::atan2(gait_state.step_z, step_length) * 2;
|
||||
float point[3] = {0, 0, 0};
|
||||
curve(length, angle, arg, phase_time, point);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user