Skip to content

Commit 55f1011

Browse files
authored
Merge pull request #82 from makerforgetech/develop
Updates to V4
2 parents 8efbc37 + dd9a1d1 commit 55f1011

33 files changed

+864
-127
lines changed

.gitignore

Lines changed: 129 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,132 @@ app.log*
1313
battery*.csv
1414
timelapse/*
1515
.coverage
16-
modular-biped-venv
16+
modular-biped-venv
17+
data
18+
19+
# Viam demanded the modules get installed directly in the directory
20+
Adafruit_Blinka-8.28.0.dist-info/
21+
Adafruit_PlatformDetect-3.57.0.dist-info/
22+
Adafruit_PureIO-1.1.11.dist-info/
23+
Adafruit_PureIO/
24+
PIL/
25+
Pillow-10.1.0.dist-info/
26+
Pillow.libs/
27+
PyYAML-6.0.1.dist-info/
28+
Pypubsub-4.0.3.dist-info/
29+
RPi.GPIO-0.7.1.dist-info/
30+
RPi/
31+
_distutils_hack/
32+
_rpi_ws281x.cpython-311-aarch64-linux-gnu.so
33+
_yaml/
34+
adafruit_blinka/
35+
adafruit_bus_device/
36+
adafruit_circuitpython_busdevice-5.2.6.dist-info/
37+
adafruit_circuitpython_pixelbuf-2.0.4.dist-info/
38+
adafruit_circuitpython_requests-2.0.3.dist-info/
39+
adafruit_circuitpython_seesaw-1.16.1.dist-info/
40+
adafruit_circuitpython_typing-1.9.6.dist-info/
41+
adafruit_pixelbuf.py
42+
adafruit_platformdetect/
43+
adafruit_requests.py
44+
adafruit_seesaw/
45+
analogio.py
46+
bin/
47+
bitbangio.py
48+
board.py
49+
busio.py
50+
certifi-2023.11.17.dist-info/
51+
certifi/
52+
chardet-3.0.4.dist-info/
53+
chardet/
54+
circuitpython_typing/
55+
click-8.1.7.dist-info/
56+
click/
57+
colorzero-2.0.dist-info/
58+
colorzero/
59+
colour-0.1.5.dist-info/
60+
colour.py
61+
digitalio.py
62+
distutils-precedence.pth
63+
google/
64+
googleapis_common_protos-1.62.0.dist-info/
65+
googletrans-3.1.0a0.dist-info/
66+
googletrans/
67+
gpiozero-2.0.dist-info/
68+
gpiozero/
69+
gpiozerocli/
70+
grpclib-0.4.6.dist-info/
71+
grpclib/
72+
h11-0.9.0.dist-info/
73+
h11/
74+
h2-3.2.0.dist-info/
75+
h2/
76+
hpack-3.0.0.dist-info/
77+
hpack/
78+
hstspreload-2023.1.1.dist-info/
79+
hstspreload/
80+
httpcore-0.9.1.dist-info/
81+
httpcore/
82+
httpx-0.13.3.dist-info/
83+
httpx/
84+
hyperframe-5.2.0.dist-info/
85+
hyperframe/
86+
idna-2.10.dist-info/
87+
idna/
88+
include/
89+
joblib-1.3.2.dist-info/
90+
joblib/
91+
keypad.py
92+
microcontroller/
93+
micropython-stubs/
94+
micropython.py
95+
multidict-6.0.4.dist-info/
96+
multidict/
97+
neopixel_write.py
98+
nltk-3.8.1.dist-info/
99+
nltk/
100+
numpy-1.26.2.dist-info/
101+
numpy.libs/
102+
numpy/
103+
onewireio.py
104+
pkg_resources/
105+
protobuf-4.25.1.dist-info/
106+
pubsub/
107+
pulseio.py
108+
pwmio.py
109+
pyftdi-0.55.0.dist-info/
110+
pyftdi/
111+
pygame-2.5.2.dist-info/
112+
pygame.libs/
113+
pygame/
114+
pyserial-3.5.dist-info/
115+
pyusb-1.2.1.dist-info/
116+
rainbowio.py
117+
regex-2023.10.3.dist-info/
118+
regex/
119+
rfc3986-1.5.0.dist-info/
120+
rfc3986/
121+
rpi_ws281x-5.0.0.dist-info/
122+
rpi_ws281x/
123+
run_viam.sh
124+
schedule-1.2.1.dist-info/
125+
schedule/
126+
serial/
127+
setenv.py
128+
setuptools-69.0.2.dist-info/
129+
setuptools/
130+
sniffio-1.3.0.dist-info/
131+
sniffio/
132+
sysv_ipc-1.1.0.dist-info/
133+
sysv_ipc.cpython-311-aarch64-linux-gnu.so
134+
tqdm-4.66.1.dist-info/
135+
tqdm/
136+
typing_extensions-4.9.0.dist-info/
137+
typing_extensions.py
138+
usb/
139+
usb_hid.py
140+
venv/
141+
viam/
142+
viam_sdk-0.12.0.dist-info/
143+
yaml/
144+
!modules/viam/

.vscode/c_cpp_properties.json

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,6 @@
2020
"/home/dan/.arduino15/packages/arduino/hardware/avr/1.8.6/variants/eightanaloginputs",
2121
"/home/dan/Arduino/libraries/ServoEasing/src",
2222
"/home/dan/Arduino/libraries/Servo/src",
23-
"/home/dan/Arduino/libraries/Adafruit_MPU6050",
24-
"/home/dan/Arduino/libraries/Adafruit_BusIO",
25-
"/home/dan/.arduino15/packages/arduino/hardware/avr/1.8.6/libraries/Wire/src",
26-
"/home/dan/.arduino15/packages/arduino/hardware/avr/1.8.6/libraries/SPI/src",
27-
"/home/dan/Arduino/libraries/Adafruit_Unified_Sensor",
2823
"/home/dan/.arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/lib/gcc/avr/7.3.0/include",
2924
"/home/dan/.arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/lib/gcc/avr/7.3.0/include-fixed",
3025
"/home/dan/.arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/avr/include"

animations/raised.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
[
2-
{"sleep": 1}
2+
{"servo:leg_l_hip:mvabs": 20},
3+
{"servo:leg_l_knee:mvabs": 40},
4+
{"servo:leg_l_ankle:mvabs": 60},
5+
{"servo:leg_r_hip:mvabs": 80},
6+
{"servo:leg_r_knee:mvabs": 60},
7+
{"servo:leg_r_ankle:mvabs": 50}
38
]

animations/scan.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[
2+
{"servo:tilt:mv": 20},
3+
{"sleep": 0.5},
4+
{"pin:high": 22},
5+
{"servo:tilt:mv": -40},
6+
{"sleep": 0.5},
7+
{"servo:tilt:mv": 40},
8+
{"sleep": 0.5},
9+
{"servo:tilt:mv": -40},
10+
{"sleep": 0.5},
11+
{"servo:tilt:mv": 20},
12+
{"pin:low": 22},
13+
{"sleep": 2}
14+
]

animations/sit.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
[
2-
{"sleep": 1}
2+
{"servo:leg_l_hip:mvabs": 40},
3+
{"servo:leg_l_knee:mvabs": 10},
4+
{"servo:leg_l_ankle:mvabs": 100},
5+
{"servo:leg_r_hip:mvabs": 60},
6+
{"servo:leg_r_knee:mvabs": 90},
7+
{"servo:leg_r_ankle:mvabs": 0}
38
]

animations/sleep.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
[
2-
{"servo:tilt:mvabs": 0},
3-
{"servo:pan:mvabs": 90},
2+
{"servo:tilt:mvabs": 50},
3+
{"servo:pan:mvabs": 50},
4+
{"animate": "sit"},
45
{"sleep": 1}
56
]

animations/stand.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
[
2-
{"sleep": 1}
2+
{"servo:leg_l_hip:mvabs": 20},
3+
{"servo:leg_l_knee:mvabs": 40},
4+
{"servo:leg_l_ankle:mvabs": 60},
5+
{"servo:leg_r_hip:mvabs": 80},
6+
{"servo:leg_r_knee:mvabs": 60},
7+
{"servo:leg_r_ankle:mvabs": 50}
38
]

animations/tiptoes.json

Lines changed: 0 additions & 3 deletions
This file was deleted.

arduino_sketch/Config.h

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
* @brief Configuration file for the Arduino sketch.
66
* @details This file contains the configuration for the Arduino sketch.
77
*/
8+
//#define SERVO_CALIBRATION_ENABLED // Enable servo calibration (see ServoManager::calibrate())
9+
//#define SERVO_CALIBRATION_SYMMETRICAL // Calculate and apply equivelant changes on other leg.
810

911
#define SERVO_PIN_OFFSET 2 // Legacy, used to identify pin from pi communication
1012
// Left Leg
@@ -19,13 +21,17 @@
1921
#define PIN_SNT 2 // Servo neck tilt
2022
#define PIN_SNP 3 // Servo neck pan
2123
// Sway
22-
#define PIN_SLLHP 4 // Servo left leg hip piovot (unused)
24+
#define PIN_SLLHP 4 // Servo left leg hip pivot (unused)
2325
#define PIN_SRLHP 5 // Servo right leg hip pivot (unused)
2426

2527
#define LEG_LENGTH_SHIN 94.0 // Length of shin
2628
#define LEG_LENGTH_THIGH 94.0 // Length of thigh
2729
#define LEG_LENGTH_FOOT 28.0 // Length of foot
2830

31+
#define HIP_ADJUSTMENT 120 // Starting angle of hip relative to IK model
32+
#define KNEE_ADJUSTMENT 90
33+
#define ANKLE_ADJUSTMENT 85
34+
2935
#define EASING_TYPE EASE_QUADRATIC_IN_OUT
3036
#define ENABLE_EASE_QUADRATIC
3137
#define SERVO_SPEED_MIN 20
@@ -35,38 +41,40 @@
3541

3642
#define SERVO_COUNT 8 // Number of servos to be controlled by ServoEasing
3743

38-
#define LEG_IK_MIN 140 // Min solvable height of leg between hip and ankle
44+
#define LEG_IK_MIN 75 // Min solvable height of leg between hip and ankle
3945
#define LEG_IK_MAX 170 // Max solvable height of leg between hip and ankle
4046

4147
#define NOVAL 1000
4248

43-
#define MPU6050_ENABLED // Enable MPU6050
49+
//#define MPU6050_ENABLED // Enable MPU6050
4450
//#define MPU6050_DEBUG // Debug in serial plotter
51+
//#define ANIMATE_ENABLED // Enable random animations
4552

4653

4754
// Arrays to store servo min / max positions to avoid mechanical issues due
4855
// NOTE: attach() disregards this, set PosRest to be within range of the servo's physical boundaries
49-
int PosMin[SERVO_COUNT] = {20, 5, 40, 20, 5, 15, 60, 20};
50-
int PosMax[SERVO_COUNT] = {160, 175, 180, 160, 175, 180, 120, 160};
51-
int PosSleep[SERVO_COUNT] = {70, PosMin[1], PosMax[2], 110, PosMax[4], PosMin[5], PosMax[7], 90};
56+
int PosMin[SERVO_COUNT] = {0, 0, 5, 0, 0, 10, 60, 30};
57+
int PosMax[SERVO_COUNT] = {180, 180, 165, 180, 180, 180, 120, 150};
58+
int PosSleep[SERVO_COUNT] = {40, 60, 95, 140, 120, 85, PosMax[7], 90};
5259
//int PrepRestFromSleep[SERVO_COUNT] = {80, PosMin[1], PosMax[2], 100, PosMax[4], PosMin[5], S7_REST, 80, S9_REST};
5360
//int PrepSleepFromRest[SERVO_COUNT] = {S1_REST, S2_REST, S3_REST, S4_REST, S5_REST, S6_REST, S7_REST, 80, S9_REST};
5461

5562
// Starting positions
56-
int PosStart[SERVO_COUNT] = {30, 21, 94, 149, 158, 85, 90, 90};
63+
//0, 3 = HIP
64+
int PosStart[SERVO_COUNT] = {60, 0, 165, 120, 180, 10, 90, 90};
5765

5866

5967

6068
//int PosRest[SERVO_COUNT] = {S1_REST, S2_REST, S3_REST, S4_REST, S5_REST, S6_REST, S7_REST, S8_REST, S9_REST};
61-
int PosRest[SERVO_COUNT] = {30, 21, 94, 149, 158, 85, 90, 90};
69+
int PosRest[SERVO_COUNT] = {60, 0, 165, 120, 180, 10, 90, 90};
6270

6371
int PosConfig[SERVO_COUNT] = {90, 90, 90, 90, 90, 90, 90, 90};
6472

6573
// Poses
66-
int PosStand[SERVO_COUNT] = {110, 110, 110, 70, 70, 70, NOVAL, NOVAL};
74+
int PosStand[SERVO_COUNT] = {40, 60, 95, 140, 120, 85, NOVAL, NOVAL};
6775
int PosLookLeft[SERVO_COUNT] = {NOVAL, NOVAL, NOVAL, NOVAL, NOVAL, NOVAL, NOVAL, 180};
6876
int PosLookRight[SERVO_COUNT] = {NOVAL, NOVAL, NOVAL, NOVAL, NOVAL, NOVAL, NOVAL, 0};
69-
int PosLookRandom[SERVO_COUNT] = {NOVAL, NOVAL, NOVAL, NOVAL, NOVAL, NOVAL, -1, -1}; // Made random by calling the function moveRandom() if the value is -1
77+
int PosLookRandom[SERVO_COUNT] = {NOVAL, NOVAL, NOVAL, NOVAL, NOVAL, NOVAL, -1, NOVAL}; // Made random by calling the function moveRandom() if the value is -1
7078
int PosLookUp[SERVO_COUNT] = {NOVAL, NOVAL, NOVAL, NOVAL, NOVAL, NOVAL, 60, 90};
7179
int PosLookDown[SERVO_COUNT] = {NOVAL, NOVAL, NOVAL, NOVAL, NOVAL, NOVAL, 120, 90};
7280

arduino_sketch/InverseKinematics.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class InverseKinematics
1313
{
1414
// constructor
1515
public:
16-
double hipAdjustment = 105; // Angle to adjust hip, will be modified for balance
16+
double hipAdjustment = HIP_ADJUSTMENT; // Angle to adjust hip, will be modified for balance
1717
void doInit(float hipMinAngle, float hipMaxAngle, float kneeMinAngle, float kneeMaxAngle, float ankleMinAngle, float ankleMaxAngle, float thighLength, float shinLength, float footLength)
1818
{
1919
this->hipMinAngle = hipMinAngle;
@@ -81,9 +81,9 @@ class InverseKinematics
8181

8282
// Convert the angles from radians to degrees
8383
// Adjust to compensate for servo's actual position
84-
hipAngle = r2d(d2r(180) - (hip + d2r(hipAdjustment))); // Inverse and offset by 105 degrees
85-
kneeAngle = r2d(knee - d2r(90)); // Offset 90 to compensate
86-
ankleAngle = r2d(ankle + d2r(70)); // Offset 70 to compensate
84+
hipAngle = r2d(d2r(180) - (hip + d2r(hipAdjustment))); // Inverse and offset by 90 degrees
85+
kneeAngle = r2d(knee - d2r(KNEE_ADJUSTMENT)); // Offset 90 to compensate
86+
ankleAngle = r2d(ankle + d2r(ANKLE_ADJUSTMENT)); // Offset 70 to compensate
8787

8888
// if IK_DEBUG is defined, print debug info
8989
#ifdef IK_DEBUG

0 commit comments

Comments
 (0)