🎨 Adds speed factor to frontend
This commit is contained in:
+4
-1
@@ -127,6 +127,7 @@ export class BezierState extends GaitState {
|
|||||||
protected step_length = 0
|
protected step_length = 0
|
||||||
protected stand_offset = 0.85
|
protected stand_offset = 0.85
|
||||||
protected mode: 'crawl' | 'trot' = 'trot'
|
protected mode: 'crawl' | 'trot' = 'trot'
|
||||||
|
protected speed_factor = 1
|
||||||
offset = [0, 0.5, 0.75, 0.25]
|
offset = [0, 0.5, 0.75, 0.25]
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
@@ -143,6 +144,7 @@ export class BezierState extends GaitState {
|
|||||||
|
|
||||||
this.mode = mode
|
this.mode = mode
|
||||||
if (mode === 'crawl') {
|
if (mode === 'crawl') {
|
||||||
|
this.speed_factor = 0.1
|
||||||
this.stand_offset = duty ?? 0.85
|
this.stand_offset = duty ?? 0.85
|
||||||
const o = order ?? [0, 3, 1, 2]
|
const o = order ?? [0, 3, 1, 2]
|
||||||
const base = [0, 0.25, 0.5, 0.75]
|
const base = [0, 0.25, 0.5, 0.75]
|
||||||
@@ -150,6 +152,7 @@ export class BezierState extends GaitState {
|
|||||||
for (let i = 0; i < 4; i++) offsets[o[i]] = base[i]
|
for (let i = 0; i < 4; i++) offsets[o[i]] = base[i]
|
||||||
this.offset = offsets
|
this.offset = offsets
|
||||||
} else {
|
} else {
|
||||||
|
this.speed_factor = 1
|
||||||
this.stand_offset = duty ?? 0.6
|
this.stand_offset = duty ?? 0.6
|
||||||
this.offset = order ? (order.map(v => v % 1) as number[]) : [0, 0.5, 0.5, 0]
|
this.offset = order ? (order.map(v => v % 1) as number[]) : [0, 0.5, 0.5, 0]
|
||||||
}
|
}
|
||||||
@@ -172,7 +175,7 @@ export class BezierState extends GaitState {
|
|||||||
update_phase() {
|
update_phase() {
|
||||||
const m = this.gait_state
|
const m = this.gait_state
|
||||||
if (m.step_x === 0 && m.step_z === 0 && m.step_angle === 0) return
|
if (m.step_x === 0 && m.step_z === 0 && m.step_angle === 0) return
|
||||||
this.phase += this.dt * m.step_velocity * 2
|
this.phase += this.dt * m.step_velocity * this.speed_factor
|
||||||
if (this.phase >= 1) {
|
if (this.phase >= 1) {
|
||||||
this.phase_num = (this.phase_num + 1) % 2
|
this.phase_num = (this.phase_num + 1) % 2
|
||||||
this.phase = 0
|
this.phase = 0
|
||||||
|
|||||||
Reference in New Issue
Block a user