📏 Adds step length slider
This commit is contained in:
@@ -5,6 +5,7 @@ export interface ControllerInput {
|
|||||||
right: vector;
|
right: vector;
|
||||||
height: number;
|
height: number;
|
||||||
speed: number;
|
speed: number;
|
||||||
|
s1: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type GithubRelease = {
|
export type GithubRelease = {
|
||||||
|
|||||||
@@ -32,5 +32,6 @@ export const input: Writable<ControllerInput> = writable({
|
|||||||
left: { x: 0, y: 0 },
|
left: { x: 0, y: 0 },
|
||||||
right: { x: 0, y: 0 },
|
right: { x: 0, y: 0 },
|
||||||
height: 50,
|
height: 50,
|
||||||
speed: 50
|
speed: 50,
|
||||||
|
s1: 50
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
let right: nipplejs.JoystickManager;
|
let right: nipplejs.JoystickManager;
|
||||||
|
|
||||||
let throttle_timing = 40;
|
let throttle_timing = 40;
|
||||||
let data = new Array(7);
|
let data = new Array(8);
|
||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
left = nipplejs.create({
|
left = nipplejs.create({
|
||||||
@@ -51,6 +51,7 @@
|
|||||||
data[4] = toInt8($input.right.y, -1, 1);
|
data[4] = toInt8($input.right.y, -1, 1);
|
||||||
data[5] = toInt8($input.height, 0, 100);
|
data[5] = toInt8($input.height, 0, 100);
|
||||||
data[6] = toInt8($input.speed, 0, 100);
|
data[6] = toInt8($input.speed, 0, 100);
|
||||||
|
data[7] = toInt8($input.s1, 0, 100);
|
||||||
|
|
||||||
outControllerData.set(data);
|
outControllerData.set(data);
|
||||||
};
|
};
|
||||||
@@ -67,7 +68,7 @@
|
|||||||
throttle.throttle(updateData, throttle_timing);
|
throttle.throttle(updateData, throttle_timing);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleRange = (event:Event, key: 'speed' | 'height') => {
|
const handleRange = (event:Event, key: 'speed' | 'height' | 's1') => {
|
||||||
const value:number = event.target?.value
|
const value:number = event.target?.value
|
||||||
|
|
||||||
input.update((inputData) => {
|
input.update((inputData) => {
|
||||||
@@ -107,7 +108,9 @@
|
|||||||
</button>
|
</button>
|
||||||
{/each}
|
{/each}
|
||||||
<div>
|
<div>
|
||||||
{#if $mode === ModesEnum.Walk}
|
{#if $mode === ModesEnum.Walk || $mode === ModesEnum.Crawl}
|
||||||
|
<label for="s1">S1</label>
|
||||||
|
<input type="range" name="s1" min="0" max="100" on:input={(e) => handleRange(e, 's1')} class="range range-sm" />
|
||||||
<label for="speed">Speed</label>
|
<label for="speed">Speed</label>
|
||||||
<input type="range" name="speed" min="0" max="100" on:input={(e) => handleRange(e, 'speed')} class="range range-sm" />
|
<input type="range" name="speed" min="0" max="100" on:input={(e) => handleRange(e, 'speed')} class="range range-sm" />
|
||||||
{/if}
|
{/if}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ struct gait_state_t {
|
|||||||
|
|
||||||
struct ControllerCommand {
|
struct ControllerCommand {
|
||||||
int stop;
|
int stop;
|
||||||
float lx, ly, rx, ry, h, s;
|
float lx, ly, rx, ry, h, s, s1;
|
||||||
};
|
};
|
||||||
|
|
||||||
class GaitState {
|
class GaitState {
|
||||||
@@ -140,9 +140,9 @@ class PhaseGaitState : public GaitState {
|
|||||||
|
|
||||||
gait_state_t mapCommand(ControllerCommand command) {
|
gait_state_t mapCommand(ControllerCommand command) {
|
||||||
gait_state_t state;
|
gait_state_t state;
|
||||||
state.step_height = 0.4f + std::fabs(command.ry / 128);
|
state.step_height = (command.s1 / 128 + 1) / 2;
|
||||||
state.step_x = command.ly / 128;
|
state.step_x = command.ly / 128 * 2;
|
||||||
state.step_z = -command.lx / 128;
|
state.step_z = -command.lx / 128 * 2;
|
||||||
state.step_velocity = command.s / 128 + 1;
|
state.step_velocity = command.s / 128 + 1;
|
||||||
state.step_angle = 0;
|
state.step_angle = 0;
|
||||||
return state;
|
return state;
|
||||||
|
|||||||
@@ -72,8 +72,9 @@ class MotionService {
|
|||||||
command.ry = array[4];
|
command.ry = array[4];
|
||||||
command.h = array[5];
|
command.h = array[5];
|
||||||
command.s = array[6];
|
command.s = array[6];
|
||||||
|
command.s1 = array[7];
|
||||||
|
|
||||||
body_state.ym = (command.h + 127.f) * 0.75f / 100;
|
body_state.ym = (command.h + 127.f) * 0.35f / 100;
|
||||||
|
|
||||||
switch (motionState) {
|
switch (motionState) {
|
||||||
case MOTION_STATE::STAND: {
|
case MOTION_STATE::STAND: {
|
||||||
@@ -154,7 +155,7 @@ class MotionService {
|
|||||||
TaskManager *_taskManager;
|
TaskManager *_taskManager;
|
||||||
ServoController *_servoController;
|
ServoController *_servoController;
|
||||||
Kinematics kinematics;
|
Kinematics kinematics;
|
||||||
ControllerCommand command = {0, 0, 0, 0, 0, 0, 0};
|
ControllerCommand command = {0, 0, 0, 0, 0, 0, 0, 0};
|
||||||
|
|
||||||
friend class GaitState;
|
friend class GaitState;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user