Skip to content

Adding reset command, some define, changing version number #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: v2
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion firmware/src/Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Try "make help" first
#
MODEL="metabot2"
VERSION="1.0"
VERSION="2.0"

.DEFAULT_GOAL := sketch

Expand Down
34 changes: 24 additions & 10 deletions firmware/src/motion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,28 +54,28 @@ float motion_get_motor(int idx)
#define AMPLITUDE 30

// Speed factor
TERMINAL_PARAMETER_FLOAT(freq, "Time factor gain", 2.0);
TERMINAL_PARAMETER_FLOAT(freq, "Time factor gain", INIT_FREQ);

// Legs bacakward mode
TERMINAL_PARAMETER_BOOL(backLegs, "Legs backwards", false);
TERMINAL_PARAMETER_BOOL(backLegs, "Legs backwards", INIT_BACKLEGS);

// Amplitude & altitude of the robot
TERMINAL_PARAMETER_FLOAT(alt, "Height of the steps", 15.0);
TERMINAL_PARAMETER_FLOAT(alt, "Height of the steps", INIT_ALT);

// Static position
TERMINAL_PARAMETER_FLOAT(r, "Robot size", 153.0);
TERMINAL_PARAMETER_FLOAT(h, "Robot height", -55.0);
TERMINAL_PARAMETER_FLOAT(r, "Robot size", INIT_R);
TERMINAL_PARAMETER_FLOAT(h, "Robot height", INIT_H);

// Direction vector
TERMINAL_PARAMETER_FLOAT(dx, "Dx", 0.0);
TERMINAL_PARAMETER_FLOAT(dy, "Dy", 0.0);
TERMINAL_PARAMETER_FLOAT(crab, "Crab", 0.0);
TERMINAL_PARAMETER_FLOAT(dx, "Dx", INIT_DX);
TERMINAL_PARAMETER_FLOAT(dy, "Dy", INIT_DY);
TERMINAL_PARAMETER_FLOAT(crab, "Crab", INIT_CRAB);

// Turning, in ° per step
TERMINAL_PARAMETER_FLOAT(turn, "Turn", 0.0);
TERMINAL_PARAMETER_FLOAT(turn, "Turn", INIT_TURN);

// Front delta h
TERMINAL_PARAMETER_FLOAT(frontH, "Front delta H", 0.0);
TERMINAL_PARAMETER_FLOAT(frontH, "Front delta H", INIT_FRONTH);

#ifdef HAS_TERMINAL
TERMINAL_COMMAND(toggleBackLegs, "Toggle back legs")
Expand All @@ -89,6 +89,20 @@ TERMINAL_COMMAND(toggleCrab, "Toggle crab mode")
if (crab == 0) crab = 30;
else if (crab == 30) crab = 0;
}
TERMINAL_COMMAND(reset, "Reset robot's motion parameters"){
motion_init();
freq = INIT_FREQ;
backLegs = INIT_BACKLEGS;
alt = INIT_ALT;
r = INIT_R;
h = INIT_H;
dx = INIT_DX;
dy = INIT_DY;
crab = INIT_CRAB;
turn = INIT_TURN;
frontH = INIT_FRONTH;
terminal_io()->println("OK");
}
#endif

// Gait selector
Expand Down
11 changes: 11 additions & 0 deletions firmware/src/motion.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
#ifndef _METABOT_MOTION_H
#define _METABOT_MOTION_H

#define INIT_FREQ 2.0
#define INIT_BACKLEGS false
#define INIT_ALT 15.0
#define INIT_R 153.0
#define INIT_H -55.0
#define INIT_DX 0.0
#define INIT_DY 0.0
#define INIT_CRAB 0.0
#define INIT_TURN 0.0
#define INIT_FRONTH 0.0

// Output angles
extern float l1[4], l2[4], l3[4];

Expand Down