🚚 Renames controller data

This commit is contained in:
Rune Harlyk
2026-01-03 18:00:13 +01:00
committed by nikguin04
parent 3a393375fd
commit 7cb5c06524
9 changed files with 21 additions and 21 deletions
+8 -8
View File
@@ -1,7 +1,7 @@
import { get } from 'svelte/store'
import type { body_state_t } from './kinematic'
import { currentKinematic } from './stores/featureFlags'
import { HumanInputData, WalkGaits } from './platform_shared/message'
import { ControllerData, WalkGaits } from './platform_shared/message'
export interface gait_state_t {
step_height: number
@@ -53,7 +53,7 @@ export abstract class GaitState {
end() {
console.log('Ending', this.name)
}
step(body_state: body_state_t, command: HumanInputData, dt: number = 0.02) {
step(body_state: body_state_t, command: ControllerData, dt: number = 0.02) {
this.map_command(command)
this.body_state = body_state
this.dt = dt / 1000
@@ -70,7 +70,7 @@ export abstract class GaitState {
return body_state
}
map_command(command: HumanInputData) {
map_command(command: ControllerData) {
const kin = this.kinematic
this.gait_state = {
step_height: command.s1 * kin.max_step_height,
@@ -85,7 +85,7 @@ export abstract class GaitState {
export class IdleState extends GaitState {
protected name = 'Idle'
step(body_state: body_state_t, command: HumanInputData) {
step(body_state: body_state_t, command: ControllerData) {
super.step(body_state, command)
return body_state
}
@@ -94,7 +94,7 @@ export class IdleState extends GaitState {
export class CalibrationState extends GaitState {
protected name = 'Calibration'
step(body_state: body_state_t, _command: HumanInputData) {
step(body_state: body_state_t, _command: ControllerData) {
super.step(body_state, _command)
body_state.omega = 0
body_state.phi = 0
@@ -110,7 +110,7 @@ export class CalibrationState extends GaitState {
export class RestState extends GaitState {
protected name = 'Rest'
step(body_state: body_state_t, _command: HumanInputData) {
step(body_state: body_state_t, _command: ControllerData) {
super.step(body_state, _command)
body_state.omega = 0
body_state.phi = 0
@@ -126,7 +126,7 @@ export class RestState extends GaitState {
export class StandState extends GaitState {
protected name = 'Stand'
step(body_state: body_state_t, command: HumanInputData) {
step(body_state: body_state_t, command: ControllerData) {
super.step(body_state, command)
const kin = this.kinematic
body_state.omega = 0
@@ -189,7 +189,7 @@ export class BezierState extends GaitState {
super.end()
}
step(body_state: body_state_t, command: HumanInputData, dt: number = 0.02) {
step(body_state: body_state_t, command: ControllerData, dt: number = 0.02) {
super.step(body_state, command, dt)
const kin = this.kinematic
this.body_state.ym = kin.min_body_height + command.height * kin.body_height_range
+3 -3
View File
@@ -1,6 +1,6 @@
import Kinematic from '$lib/kinematic'
import {
HumanInputData,
ControllerData,
KinematicData,
ModeData,
ModesEnum,
@@ -24,8 +24,8 @@ export const walkGait: Writable<WalkGaitData> = writable(
export const kinematicData = writable(KinematicData.create())
export const input: Writable<HumanInputData> = writable(
HumanInputData.create({
export const input: Writable<ControllerData> = writable(
ControllerData.create({
left: { x: 0, y: 0 },
right: { x: 0, y: 0 },
height: 0.7,
+2 -2
View File
@@ -23,7 +23,7 @@
import {
AnglesData,
DownloadOTAData,
HumanInputData,
ControllerData,
KinematicData,
ModeData,
RSSIData,
@@ -48,7 +48,7 @@
addEventListeners()
input.subscribe(data =>
throttler.throttle(() => socket.sendEvent(HumanInputData, data), 100)
throttler.throttle(() => socket.sendEvent(ControllerData, data), 100)
)
mode.subscribe(data => socket.sendEvent(ModeData, data))
walkGait.subscribe(data => socket.sendEvent(WalkGaitData, data))
+1 -1
View File
@@ -32,7 +32,7 @@ DEFINE_MESSAGE_TRAITS(KinematicData, kinematic_data)
DEFINE_MESSAGE_TRAITS(IMUCalibrateData, imu_calibrate)
DEFINE_MESSAGE_TRAITS(I2CScanData, i2c_scan)
DEFINE_MESSAGE_TRAITS(PeripheralSettingsData, peripheral_settings)
DEFINE_MESSAGE_TRAITS(HumanInputData, human_input_data)
DEFINE_MESSAGE_TRAITS(ControllerData, controller_data)
DEFINE_MESSAGE_TRAITS(WalkGaitData, walk_gait)
DEFINE_MESSAGE_TRAITS(IMUCalibrateExecute, imu_calibrate_execute)
DEFINE_MESSAGE_TRAITS(I2CScanDataRequest, i2c_scan_data_request)
+1 -1
View File
@@ -5,7 +5,7 @@
struct CommandMsg {
float lx, ly, rx, ry, h, s, s1;
void fromProto(const socket_message_HumanInputData& data) {
void fromProto(const socket_message_ControllerData& data) {
lx = data.has_left ? data.left.x : 0;
ly = data.has_left ? data.left.y : 0;
rx = data.has_right ? data.right.x : 0;
+1 -1
View File
@@ -23,7 +23,7 @@ class MotionService {
void handleAngles(const socket_message_AnglesData& data);
void handleInput(const socket_message_HumanInputData& data);
void handleInput(const socket_message_ControllerData& data);
void handleWalkGait(const socket_message_WalkGaitData& data);
+2 -2
View File
@@ -136,8 +136,8 @@ void setupServer() {
}
void setupEventSocket() {
socket.on<socket_message_HumanInputData>(
[&](const socket_message_HumanInputData &data, int clientId) { motionService.handleInput(data); });
socket.on<socket_message_ControllerData>(
[&](const socket_message_ControllerData &data, int clientId) { motionService.handleInput(data); });
socket.on<socket_message_ModeData>([&](const socket_message_ModeData &data, int clientId) {
servoController.setMode(SERVO_CONTROL_STATE::ANGLE);
+1 -1
View File
@@ -18,7 +18,7 @@ void MotionService::setState(MotionState* newState) {
}
}
void MotionService::handleInput(const socket_message_HumanInputData& data) {
void MotionService::handleInput(const socket_message_ControllerData& data) {
command.fromProto(data);
if (state) state->handleCommand(command);
}
+2 -2
View File
@@ -139,7 +139,7 @@ message DownloadOTAData { string status = 1; int32 progress = 2; string error =
message SonarData { string dummy_field = 1; }
message HumanInputData {
message ControllerData {
Vector left = 10; Vector right = 11; float height = 20; float speed = 21; float s1 = 22;
}
@@ -198,7 +198,7 @@ message Message {
ServoPWMData servo_pwm = 210;
ServoStateData servo_state = 211;
WifiSettingsData wifi_settings = 240;
HumanInputData human_input_data = 250;
ControllerData controller_data = 250;
RSSIData rssi = 260;
}
}