72 Commits
Author SHA1 Message Date
mangavalkandClaude Opus 5.5 cb1e9234c6 2019: add the May 2019 printed robot parts (STL)
Fusion 360 STL exports of the body, legs, hinges, foot, servo horn and
test legs into robot-parts/, and an early remote part into remote-case/.
Found in an old Hexapod folder; the remote files that came with them were
already in the repo.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-26 14:00:54 +01:00
mangavalk df54f0866d FireFly: add wisFORlive.pdf
PDF version of the IK derivation. It was in the Hexapod-Archief repo from its first commit (2014) until the 2016 cleanup removed it, so it was only left in that repo's history.
2026-10-25 18:53:59 +01:00
mangavalk 557f633897 Owner's reorganisation: frame into 2009-fpga, media regrouped, old math versions removed
- original-frame/ moves into 2009-fpga/original-frame/ (the FPGA version introduced the frame).
- Media regrouped by the owner: the two 2011-07-01 PNGs and MOV02256-02259 to FireFly, SNC00198.jpg to the FPGA version.
- Removed from the current version (still in the history): docs/math wisFORlive.docx, wisFORlive3.docx, wisFORlive4.docx and 'z axis rotation.url'.
- READMEs, 2026-current/CLAUDE.md and the root timeline updated to match.
2026-10-25 18:50:08 +01:00
mangavalk 3d879ad803 robot/: point the old-sketch references to 2019-teensy-nrf24/Hexapod_Teensy
Comments in Config.h and the README referred to LEGACY/, which is folded into the generation folders. Also 'from the repo root' -> 'from the 2026-current folder'. Comment and documentation changes only; approved by the owner.
2026-10-25 17:47:05 +01:00
mangavalk 1b3102296b Add READMEs for the repo and every generation, root CLAUDE.md and .gitattributes
The root README has the timeline of all generations since 2009. Each generation folder explains its hardware and what is in it. .gitattributes turns off line-ending conversion so all files stay as they were.
2026-10-25 17:33:11 +01:00
mangavalk be287b066e Give the 2014, 2016 and 2019 robot sketches their own sketch folder
The Arduino IDE needs the folder name to match the .ino: HexapodRobot/, Hexapod_NEW/ and Hexapod_Teensy/. References in 2026-current/CLAUDE.md updated.
2026-10-25 17:31:44 +01:00
mangavalk b3dd2e5540 Remove build output and editor files from the current version
Visual Studio build output (.obj, .pdb, .tlog, .sdf, .suo, ipch) of the 2012 IK visualiser and Unity's .vs, Logs and UserSettings of the 2018 simulation. They stay in the history. The built 'Hexapod app.exe' (Debug) is kept. Also drops the per-folder .gitattributes of the Processing sketch (the repo root now defines how files are stored) and the 2016 README of the old Hexapod repo (its only content was a GitLab link).
2026-10-25 17:31:09 +01:00
mangavalk dfd4d34512 Fold LEGACY into the generation folders
The LEGACY copies of HexapodRobot, Hexapod_NEW, Hexapod_Teensy and the old remote sketch were identical to the imported repos and are removed. The old Nextion design moves to 2019-teensy-nrf24/remote-nextion/, the 2019 remote case files to 2019-teensy-nrf24/remote-case/. Paths in CLAUDE.md, READMEs, remote/ comments, sim/build.ps1, the Unity DLL message and .vscode/settings.json now point to the new places. robot/ is not touched (its CLAUDE.md asks to check with the owner first).
2026-10-25 17:30:35 +01:00
mangavalk c666bc6039 Current robot: Fusion 360 designs
Body bottom, bottom and mid leg, servo horn (v5 and v6), Hitec HS-485HB servo model and the remote case (v4 and v40), with their preview images and exports. From D:\Fusion 360 export.
2026-10-25 17:28:46 +01:00
mangavalk 0b2d361716 FireFly: other versions of documents found on the share
Files from Electronics\Hexapod whose content differs from the archive copies. They keep their original file name; a date is added where the name would clash.
2026-10-25 17:28:45 +01:00
mangavalk a5372b902d FireFly (2011-2012): photos and videos
Everything created after 2 Nov 2011 20:44:07, incl. the 'Hexapod 29-11-11' film and media.jpg. From Electronics\Hexapod\media, Verwerkte media and media.jpg.
2026-10-25 17:27:04 +01:00
mangavalk 6c54a0caf2 FPGA version (2009-2011): photos and videos
Everything created on or before 2 Nov 2011 20:44:07, incl. the 'hexapod film 18-11-09'. From Electronics\Hexapod\media and Verwerkte media.
2026-10-25 17:26:36 +01:00
mangavalk 62ddaafd80 FireFly: documents, hardware notes and tools
Math (IK, rotation), planning, research papers, concept images, the Arduino Mega + SSC-32 notes and the two 2011 Windows programs. From Hexapod-Archief documentation/ (files only; its history stays in the archived repo).
2026-10-25 17:26:28 +01:00
mangavalk 204fccba0c Original frame: DXF/DWG designs used by every version from 2009 to 2023
From Hexapod-Archief documentation/design.
2026-10-25 17:26:27 +01:00
mangavalk 883d44f807 Teensy 2019: nRF24L01 test sending a data struct
From the Arduino sketchbook (was GettingStarted_HandlingData).
2019-05-25 20:07:45 +02:00
mangavalk 6fda86ebf2 Teensy 2019: nRF24L01 ping test with the robot's radio pins (CE 39, CSN 15, SCK 14)
From the Arduino sketchbook (was nrf24-GettingStarted-test).
2019-05-25 16:17:27 +02:00
mangavalk d68fb0507e Teensy 2019: MPU6050 accelerometer test
From the Arduino sketchbook (was mpu6050-test).
2019-05-16 21:46:37 +02:00
mangavalk 2373167785 Teensy 2019: read SSC-32 style servo commands, first step to replacing the SSC-32
From the Arduino sketchbook.
2019-05-12 18:30:56 +02:00
mangavalk 413f52c008 FireFly library: variant kept in the 2014 GitLab archive
GPS include disabled, out-of-reach flag instead of the 7-segment error. Exact date unknown; dated at the archive's first commit (Feb 2014).
2014-02-17 11:44:17 +01:00
mangavalk 6e50819e01 FireFly 2012: behaviour rewrite now uses the hexapod library
From Electronics\Hexapod\Arduino sketches 2011-2012\FireFly. Data.h, Def.h and SerD.h moved into the library.
2012-07-23 17:56:33 +02:00
mangavalk 304367a769 FireFly 2012: the robot code as an Arduino library 'hexapod' (v3.1): IK, SSC-32, IR, ultrasonic, GPS, 7-segment
From Electronics\Hexapod\Arduino library 2012.
2012-07-23 17:52:23 +02:00
mangavalk f0b272a1d3 FireFly 2012: start of a behaviour-based rewrite (unfinished, does not compile)
From 'FireFly 19.rar'.
2012-07-19 20:51:25 +02:00
mangavalk 0911543c03 FireFly 2012 v3: later version of May 2012
From Electronics\Hexapod\Arduino sketches 2011-2012\hexapodV3 (backup 2012-07-09).
2012-05-29 18:10:16 +02:00
mangavalk f690f307c1 FireFly 2012 v3: restructured into Data/Converter/IK/Servos classes, IR remote, ultrasonic radar head
From 'hexapodV3 28-april-2012-Backup.rar'. Oud/ is the 2011 code it was based on.
2012-04-28 16:42:59 +02:00
mangavalk 2e063fc0d9 FireFly 2012: handheld remote with graphic LCD, IR receiver and Wii Nunchuk
From the Arduino sketchbook (Electronics\Arduino\Hexapod\hexapod_remote_glcd, was GLCD).
2012-03-31 15:38:55 +02:00
mangavalk 8e66e26bb9 FireFly 2011: tuned leg positions, walk sequence and IK
From 'hexapod V2 29-12-11.rar' (main file was hexapod.pde).
2011-12-02 22:03:05 +01:00
mangavalk fe472bfce9 FireFly 2011: Arduino Mega + SSC-32, Wii Nunchuk, preset walking sequences
From Electronics\Hexapod\Arduino sketches 2011-2012\hexapod_oud (banner 'Version 3.0').
2011-10-09 15:56:03 +02:00
mangavalk 160b6ec36a Import Hexapod (2014-2022) with full history 2026-10-25 17:24:12 +01:00
mangavalk 29573971bb Import remote (2019) with full history 2026-10-25 17:23:49 +01:00
mangavalk 7638d594df Import Hexapod-processing (2014) with full history 2026-10-25 17:23:49 +01:00
mangavalk a22ce93ab2 Import Hexapod-App (2012) with full history 2026-10-25 17:23:48 +01:00
mangavalk aa35df1575 Import Hexapod_Simulation_Unity (2018-2023) with full history 2026-10-25 17:23:48 +01:00
mangavalkandClaude Opus 5.5 09f7424714 LEGACY: older hexapod sketches (Hexapod_NEW, HexapodRobot)
From https://mangavalk.com/Hexapod/Hexapod @ 7945005 (its Hexapod_Teensy
is identical to the copy already in LEGACY). Earlier electronics
generation: on-board IK driving an external SSC-32-style servo
controller. Notes on what still applies are in CLAUDE.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-25 01:17:46 +02:00
mangavalk 3e28a0aec6 update 2026-10-25 00:43:37 +02:00
mangavalk f67a12ce88 Cast abs() arguments to long long in InverseKinemetics
Recovered from the uncommitted working copy in the 'Projecten nov 2016' backup.
2026-10-25 00:31:21 +02:00
mangavalk 902b4501aa Add README and .gitattributes 2026-10-24 23:50:19 +02:00
mangavalkandClaude Opus 5.5 5ff85c4eb8 Robot: Teensy 3.6 with the old robot's servo wiring and calibration
- LEGACY/Hexapod_Teensy/: old robot sketch (reference only).
- platformio.ini: robot env targets teensy36 (owner-confirmed board).
- Config.h: per-servo SERVOS table (pin, pulse at 0 deg, signed
  us/deg, pulse limits) built from the old sketch's pins, ranges, trims
  and the old Unity servo directions. Rear-left/front-left coxa offsets
  set to 0: the owner re-horns those two servos (the old +-90 left them
  at the end of travel; the sim showed them clamping).
- ServoDriver: 18 servos on hardware PWM (50 Hz, 16-bit); the Teensy 3.6
  Servo library stops at 12.
- Radio on CE 39 / CSN 15 with SPI SCK on pin 14.
- sim: analogWrite/PWM shims, pulses decoded through SERVOS (API v6).
- Docs: CLAUDE.md, READMEs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-01 15:53:55 +02:00
mangavalkandClaude Opus 5.5 a961fa721b Remote: match the old remote's hardware; old remote code in LEGACY
- LEGACY/remote/teensy/: old remote sketch from
  https://mangavalk.com/Hexapod/remote.git @ 492dece (reference only).
- remote/Config.h: sticks on A0-A5, Nextion on Serial1 (0/1), as in the
  old sketch; MPU6050 moved to Wire2 (25/24) since A4/A5 are Wire's pins.
- NextionUI: controls on a vscope-global "control" page added to the
  old HMI; keeps the old t1 status texts; the old page-1 b2 button (and
  serial 'U') enter Nextion upload passthrough, following the PC's baud.
- Docs: NEXTION.md, remote README wiring, CLAUDE.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-01 15:29:21 +02:00
mangavalk 81fa7f1429 Update files 2026-10-01 15:09:00 +02:00
mangavalkandClaude Opus 5.5 935526eab5 Firmware simulation, Unity project, and sim-verified robot fixes
Simulation
- sim/: the unchanged robot firmware compiled into hexapod_sim.dll
  against PC stand-ins (Arduino, Servo, Wire + register-level MPU6050,
  RF24 with matching-config radio), a kinematic body model (support
  plane + planted-foot odometry) that also drives the simulated IMU,
  and a headless smoke test (sim_smoke). build.ps1 builds and tests.
- Hexapod_Simulation_Unity/ folded in (history kept in a bundle
  outside the repo). Assets/HexapodSim loads the DLL, drives the
  existing leg rig, and offers joystick / keyboard / robot-serial
  input plus a test panel.

Robot (all found or confirmed in the simulation)
- Config.h geometry taken from the Unity model.
- IK femur elevation sign, gait stance direction, body pose
  rotation direction, yaw lever arm.
- Stance feet integrated from the current command; gait restarts at
  mid-stance; heading integrates the applied turn rate, only while
  walking.
- Leg clearance and reach checks (Limits::feetFeasible); walk command
  and body pose scaled as a whole, pose scale rate-limited, planted
  feet guarded so the body never snaps or legs collide.
- Robot-gyro self-leveling as an integrator.
- Heading mode: steering relative to the body; S walks backward.
- Standing height from the remote (STANCE_HEIGHT_RANGE_MM).

Protocol v3 (reflash both boards)
- CmdPacket gains body_height (22 bytes).

Remote
- Height slider (Nextion hHeight/nHeight, serial [ ]).
- Fixed unspecified I2C read order in RemoteIMU.

LEGACY/: owner's old Nextion HMI and remote hardware assets.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-29 00:37:12 +02:00
mangavalkandClaude Opus 5.5 91dac16fca Draft: shared protocol, remote firmware, project docs
Not yet verified on hardware.

- shared/HexapodProtocol: CmdPacket (now 20 bytes, adds remote_roll /
  remote_pitch), FLAG_* bits and radio settings as the single protocol
  definition; static payload size = sizeof(CmdPacket) on both radios.
- robot: use the shared protocol; vx = forward (harness w/x <-> q/e);
  InputMapper adds remote tilt on top of the right stick when
  FLAG_REMOTE_GYRO is set, and robot.ino no longer zeroes stick
  roll/pitch when it's off.
- remote (Teensy 4.1): Sticks (calibration, EEPROM), RemoteIMU,
  RemoteState (interlocks, link-loss disarm, smoothing), PacketBuilder,
  RadioLink, NextionUI, SerialConsole.
- CLAUDE.md, README.md, remote/README.md, remote/NEXTION.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-28 18:14:00 +02:00
mangavalkandClaude Opus 5.5 ad77b06c36 Initial import: robot firmware + PlatformIO two-env scaffold
Robot-side firmware (Teensy 4.0) imported unchanged as extracted.
platformio.ini defines [env:robot] (teensy40) and [env:remote]
(teensy41); scripts/select_src_dir.py points each env at its own
sketch folder so robot/ and remote/ stay Arduino-style sketches.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-28 15:36:37 +02:00
mangavalk 772e4c34ed upgrade to new unity version 2023-04-10 15:11:41 +02:00
mangavalk 43e60d535a updated walk and controller input to joystick 2022-12-04 23:11:05 +01:00
mangavalk 4be4615a10 Updated to new design 2019-06-10 15:20:47 +02:00
mangavalk 6706350811 wireless working 2019-05-26 22:58:04 +02:00
mangavalk 1217fcec34 wip wireless
payload max 32byte problem
2019-05-26 22:29:00 +02:00
mangavalk 4ec5020ef7 First version including eeprom 2019-05-25 23:36:25 +02:00
mangavalk 4bbd5c1828 Initial commit 2019-05-25 21:32:46 +00:00
mangavalk e1e06ee2cb better walk control 2019-05-19 15:54:46 +02:00
mangavalk b147e3376f joystick 2019-05-19 00:18:28 +02:00
mangavalk 9b40dccbf4 v9 walk3 wip 2018-11-19 22:21:47 +01:00
mangavalk 98b0fb4466 v8 added walking and rotation at the same time :D 2018-11-15 20:34:00 +01:00
mangavalk cc2f3cf8c6 fix problem in returning to home 2018-11-15 16:37:54 +01:00
mangavalk 04062fc3b8 v7 slow talking :D 2018-11-15 14:11:50 +01:00
mangavalk 8630ef0753 v6 rotational walking :D 2018-11-14 22:22:38 +01:00
mangavalk 054cfb6d72 v5 ITS ALIVE, IT WALKS! 2018-11-13 23:09:58 +01:00
mangavalk 9dcf9a6190 Added serial link to SSC32 2018-11-12 23:57:23 +01:00
mangavalk 235a81c280 v4 transformation after rotation added. 2018-11-11 22:26:43 +01:00
mangavalk 21da5d3a8b v3 working transformations and working knie offset :D 2018-11-11 18:11:13 +01:00
mangavalk e6697e9980 beautify 2018-11-10 23:54:58 +01:00
mangavalk 67eb222ced v2 WORKING ROTATIONS 2018-11-10 23:23:03 +01:00
mangavalk 5acd47f2ef v1 2018-11-10 20:44:41 +01:00
mangavalk ca0dfcf923 Initial commit 2018-11-10 20:44:12 +01:00
Patrick Valk 3991264790 added gitignore 2016-11-14 13:45:03 +01:00
mangavalk 972ba2cb73 Add CustomTimer and separate left/right leg handling
Imported from the unarchived 'hexapod' sketch folder. The real date of this
version is unknown; file dates were lost in a 2016-11-14 copy.
2016-11-14 13:07:00 +01:00
mangavalk 7aa1cc9d4e Add new file 2016-11-08 10:47:29 +00:00
mangavalk bc13cdbbbe Update README.md 2016-11-08 09:15:16 +00:00
mangavalk 8a770c9d36 Add new file 2016-11-08 09:14:36 +00:00
mangavalk 0447cb8c7a Rework HexapodClass
Imported from 'hexapod 4.rar'.
2014-10-13 00:49:00 +02:00
Administrator 1f1715c841 First commit 2014-02-17 11:50:52 +01:00
mangavalk 4d4b12e6b3 First commit 2014-02-16 00:13:50 +01:00
542 changed files with 467882 additions and 107 deletions

No files matched your search

+2
View File
@@ -1,3 +1,5 @@
# Store every file exactly as it is: no line-ending conversion, so old code stays byte-for-byte original.
* -text
*.wmv filter=lfs diff=lfs merge=lfs -text
*.WMV filter=lfs diff=lfs merge=lfs -text
*.mp4 filter=lfs diff=lfs merge=lfs -text
+10
View File
@@ -0,0 +1,10 @@
# 2009–2011: the FPGA version
The first hexapod, driven by an FPGA. Its frame, `original-frame/`, was the mechanical base of every
version up to 2023. The FPGA code has not survived; what is left are the photos and videos in `media/`,
among them `hexapod film 18-11-09.wmv`.
- `original-frame/` – the leg, body and bracket designs (DXF/DWG, 2009–2011).
- `media/` – photos and videos of the FPGA version, sorted by the owner; those of the FireFly version are in
`../2011-firefly-mega-ssc32/media/`. (Most file dates are copy dates. `DSCF*` photos carry a camera date
of 2003.)
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+12
View File
@@ -0,0 +1,12 @@
# Original frame (2009–2023)
The mechanical design every version up to 2023 was built on. The 2026 robot has a new design, see
`../../2026-current/hardware/fusion360/`.
| File | Date | What |
|---|---|---|
| `poot.dxf` | 2009-10 | leg ("poot") |
| `hexapod been.dxf` | 2009-12 | leg ("been") |
| `poot2.dwg` | 2011-04 | leg, second version |
| `body.dxf`, `Body.jpg` | 2011-07 | body plate, for the Arduino Mega + SSC-32 rebuild |
| `bracket.dxf` | 2011-07 | servo bracket |
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
Binary file not shown.
+28
View File
@@ -0,0 +1,28 @@
# 2011–2012: FireFly (Arduino Mega + SSC-32)
In June 2011 the robot was rebuilt around an Arduino Mega 2560 and a Lynxmotion SSC-32 servo controller,
with a new body and bracket (`../2009-fpga/original-frame/`). The Mega does the inverse kinematics and sends
`#n Pxxxx Txxx` commands to the SSC-32 over `Serial1` at 38400 baud. The serial banner calls it "FireFly".
## firmware/
Each folder is an Arduino sketch (or library); successive versions are successive commits, so
`git log -p -- <folder>` shows what changed.
| Folder | Dates | What |
|---|---|---|
| `2011-nunchuk/hexapod_oud/` | 2011-10, 2011-12 | Wii Nunchuk input, fixed walking sequences, IK, SSC-32 output. Second commit = `hexapod V2 29-12-11.rar` |
| `2012-glcd-remote/hexapod_remote_glcd/` | 2012-03 | handheld remote: graphic LCD, IR receiver and Wii Nunchuk, using the hexapod library |
| `2012-ir-radar-gps/hexapodV3/` | 2012-04, 2012-05 | v3 restructure (Data, Converter, IK, Servos classes), RC6 IR remote, ultrasonic sensor on a swivelling head servo, watchdog. `Oud/` is the 2011 code it started from |
| `2012-library/hexapod/` | 2012-07, ≤2014-02 | the robot code as an Arduino library "hexapod" v3.1: IK, SSC-32, IR, ultrasonic, GPS (TinyGPS on `Serial2`), 7-segment display. Second commit = the variant kept in the 2014 GitLab archive |
| `2012-behaviours-wip/FireFly/` | 2012-07 | start of a behaviour-based rewrite on top of the library; unfinished, does not compile |
## Other folders
- `hardware/` – the Arduino Mega 2560 (SparkFun DEV-09949) and SSC-32 photos of June 2011, `Layout Hexapod.jpg`.
- `docs/math/` – the IK and body-rotation derivations (`[1]`–`[5]`, `Hexapod draaien Y as.png`, IK.pdf as `Movement Space Leg.pdf`). Older versions (`wisFORlive*.docx`) are in the history.
- `docs/planning/` – workflow and to-do documents (2012).
- `docs/research/` – papers on hexapod workspace and Q-learning, GPS module and TinyGPS manuals.
- `docs/concepts/` – inspiration images and early sketches (2008–2012).
- `tools/` – two small Windows programs from November 2011 (`hexapod 1.0.exe`, `hexapod Source 0.2.exe`); what they do is not known.
- `media/` – photos and videos of the FireFly version, sorted by the owner, incl. `Hexapod 29-11-11.wmv`.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large. Load diff
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,28 @@
#include "Data_Manager.h"
// Raw variable that must be send to the ssc32.
int RAW_2_SERVO[18];
// Angel to converter.
int DEG_2_CON[18];
// Coordinate to iverse kinematics.
int COR_2_IK[18];
// Orbit angles.
int ORBIT_X, ORBIT_Y, ORBIT_Z;
// Hight.
int HIGHT;
// Walk Direction relative from body.
int DIR_R_BODY;
// IK Legnth.
int l1, l2;
// Min and Max for SSC32.
int smin[3], smax[3];
// WalkTime
int walktime;
@@ -0,0 +1,20 @@
// Data_Manager.h
#ifndef DATA_MANAGER
#define DATA_MANAGER
extern int RAW_2_SERVO[18];
extern int DEG_2_CON[18];// int
extern int COR_2_IK[18];
extern int ORBIT_X, ORBIT_Y, ORBIT_Z;
extern int HIGHT;
extern int DIRECTION;
extern int l1, l2;
extern int smin[3], smax[3];
extern int walktime;
#endif
@@ -0,0 +1,50 @@
// Include.
#include <math.h>
#include "InverseKinemetics.h"
#include "SSC32.h"
#include "sequnces.h"
#include "Orbit.h"
#include "Data_Manager.h"
// Classes.
InverseKinemetics ik;
SSC32 body;
Orbit orbit;
// Nunchuck.
#include "WiiChuck.h"
#define MAXANGLE 90
#define MINANGLE -90
WiiChuck chuck = WiiChuck();
int angleStart, currentAngle;
int tillerStart = 100;
double angle;
// Functions.
void FireFly()
{
Serial.println("");
Serial.println(" ____ ____ ___ ");
Serial.println("/\\ _`\\ __ /\\ _`\\ /\\_ \\ ");
Serial.println("\\ \\ \\L\\_\\/\\_\\ _ __ __\\ \\ \\L\\_\\//\\ \\ __ __ ");
Serial.println(" \\ \\ _\\/\\/\\ \\/\\`'__\\/'__`\\ \\ _\\/ \\ \\ \\ /\\ \\/\\ \\ ");
Serial.println(" \\ \\ \\/ \\ \\ \\ \\ \\//\\ __/\\ \\ \\/ \\_\\ \\_\\ \\ \\_\\ \\ ");
Serial.println(" \\ \\_\\ \\ \\_\\ \\_\\\\ \\____\\\\ \\_\\ /\\____\\\\/`____ \\ ");
Serial.println(" \\/_/ \\/_/\\/_/ \\/____/ \\/_/ \\/____/ `/___/> \\");
Serial.println(" /\\___/");
Serial.println(" \\/__/ ");
Serial.println("");
Serial.println("Version 3.0");
delay(800);
}
void warning ()
{
digitalWrite(13, HIGH);
delay(100);
digitalWrite(13, LOW);
}
@@ -0,0 +1,157 @@
//#include "WProgram.h"
#include "InverseKinemetics.h"
void InverseKinemetics::RL3 (int i)
{
l3 = sqrt(pow(abs(COR_2_IK[0+(i*3)]), 2) + pow(abs(COR_2_IK[2+(i*3)]), 2));
}
float InverseKinemetics::ZX (int i)
{
RL3(i);
if (COR_2_IK[2+(i*3)] != 0)
float temp = degrees(acos((float)COR_2_IK[2+(i*3)] / l3));
else
float temp = 90; // Math Error Protection.
return temp;
}
float InverseKinemetics::TT (int i)
{
int x = pow(abs(COR_2_IK[0+(i*3)]), 2);
int y = pow(abs(COR_2_IK[1+(i*3)]), 2);
int z = pow(abs(COR_2_IK[2+(i*3)]), 2);
s = sqrt(x + y + z);
if (s > (l1 + l2) )
R[i] = 3;
float t1 = degrees(acos((pow(s, 2) + pow(COR_2_IK[1+(i*3)], 2) - pow(l3, 2))
/ (2 * s * COR_2_IK[1+(i*3)])));
float t2 = degrees(acos((pow(s, 2) + pow(l1, 2) - pow(l2, 2))
/ (2 * s * l1)));
float temp = (int)t1 + t2;
//Serial.print("DEBUG: "); Serial.print(t1); Serial.print(", "); Serial.print(t2); Serial.print(", "); Serial.println(temp);
return temp;
}
int InverseKinemetics::LL ()
{
int temp = degrees(acos((float)(pow(l1, 2) + pow(l2, 2) - pow(s, 2)) / (2 * l1 * l2)));
return temp;
}
void InverseKinemetics::setleg (int i)
{
Serial.print("Set Leg ");
Serial.println(i);
if (i >= 3)
{
//Error_Coordinate(i);
DEG_2_CON[0+(i*3)] = 180 - ZX(i);
DEG_2_CON[1+(i*3)] = 180 - TT(i);
DEG_2_CON[2+(i*3)] = LL();
Error_Angle(i);
}
else
{
//Error_Coordinate(i);
DEG_2_CON[0+(i*3)] = ZX(i);
DEG_2_CON[1+(i*3)] = TT(i);
DEG_2_CON[2+(i*3)] = 180 - LL();
Error_Angle(i);
}
}
void InverseKinemetics::setlegs ()
{
for (int i=0; i<6; i++)
{
setleg(i);
}
for (int i=0; i<6; i++)
{
if (i != 0)
Serial.print(", ");
else
Serial.print("Cor: ");
Serial.print(COR_2_IK[0+(i*3)]);
Serial.print(", ");
Serial.print(COR_2_IK[1+(i*3)]);
Serial.print(", ");
Serial.print(COR_2_IK[2+(i*3)]);
}
Serial.println(";");
}
void InverseKinemetics::Error_Angle (int i)
{
for (int i2=0; i2<3; i2++)
R[i2+(i*3)] = 0;
if (DEG_2_CON[0+(i*3)] < 0)
R[0+(i*3)] = 1;
if (DEG_2_CON[0+(i*3)] > 180)
R[0+(i*3)] = 2;
if (DEG_2_CON[1+(i*3)] < 0)
R[1+(i*3)] = 1;
if (DEG_2_CON[1+(i*3)] > 180)
R[1+(i*3)] = 2;
if (DEG_2_CON[2+(i*3)] < 0)
R[2+(i*3)] = 1;
if (DEG_2_CON[2+(i*3)] > 180)
R[2+(i*3)] = 2;
}
void InverseKinemetics::Error_Coordinate (int i)
{
Ra[i] = 0;
float temp = sqrt(pow(COR_2_IK[0+(i*3)], 2) + pow(COR_2_IK[1+(i*3)], 2) + pow(COR_2_IK[2+(i*3)], 2));
if (temp <= 5) {
Ra[i] = 1;
}
if (temp > l1 + l2) {
Ra[i] = 2;
}
}
int InverseKinemetics::CheckForErrorCor()
{
for (int i=1; i<19; i++)
if (R[i-1]!=0)
return i;
return 0;
}
String InverseKinemetics::CheckForErrorCor_print()
{
String temp = "Error Coordinate: ";
for (int i=0; i<18; i++)
{
temp = temp + (int)DEG_2_CON[i] + ", ";
}
temp = temp + "\nCheckForErrorCor returnd: " + CheckForErrorCor();
return temp;
}
int InverseKinemetics::CheckForErrorAng()
{
for (int i=0; i<6; i++)
if (Ra[i]!=0)
return i;
return 0;
}
@@ -0,0 +1,61 @@
#ifndef InverseKinemetics_H
#define InverseKinemetics_H
#include "WProgram.h"
#include <math.h>
#include "Data_Manager.h"
class InverseKinemetics
{
public:
//
void RL3(int i);
float ZX (int i);
float TT (int i);
int LL ();
void setlegs ();
void setleg (int i);
/* // Input
void setLeftFrontLeg (int ix, int iy, int iz); // clockwise, t3=clockwise, t3=counterclockwise
void setLeftMiddleLeg (int ix, int iy, int iz); // clockwise, t3=clockwise, t3=counterclockwise
void setLeftBackLeg (int ix, int iy, int iz); // clockwise, t3=clockwise, t3=counterclockwise
void setRightFrontLeg (int ix, int iy, int iz); // counterclockwise, t3=counterclockwise, t3=clockwise
void setRightMiddleLeg(int ix, int iy, int iz); // counterclockwise, t3=counterclockwise, t3=clockwise
void setRightBackLeg (int ix, int iy, int iz); // counterclockwise, t3=counterclockwise, t3=clockwise*/
// 0 | 3
// 1 | 4
// 2 | 5
//
void Error_Angle (int i);
void Error_Coordinate (int i);
int CheckForErrorCor();
String CheckForErrorCor_print();
int CheckForErrorAng();
// Variable's
int s;
float l3;
byte R[18];
byte Ra[6];
};
#endif
@@ -0,0 +1,91 @@
// Orbit.cpp
#include "Orbit.h"
void Orbit::getData(int iy[6], int ix[6], int iz[6])
{
for (int i=0; i<6; i++)
{
x[i] = ix[i];
y[i] = iy[i];
z[i] = iz[i];
}
lx[0] = 5;
lx[1] = 7;
lx[2] = 5;
lx[3] = 5;
lx[4] = 7;
lx[5] = 5;
ly[0] = 10;
ly[1] = 0;
ly[2] = 10;
ly[3] = 10;
ly[4] = 0;
ly[5] = 10;
}
void Orbit::getAngle (int ix, int iy)
{
oP = ix;
o2P = iy;
oN = 180 - ix;
o2N = 180 - iy;
}
void Orbit::calculate()
{
// X Size.
// Right side.
for (int i=3; i<6; i++)
{
float l1 = sqrt(pow(x[i], 2) + pow(y[i], 2));
float o1 = degrees(atan(y[i] / x[i]));
float o2 = oP - o1;
Ny[i] = sin(radians(o2)) * l1;
Nx[i] = (cos(radians(o2)) * l1) - lx[i];
Nz[i] = z[i];
}
// Left size;
for (int i=0; i<4; i++)
{
float l1 = sqrt(pow(x[i], 2) + pow(y[i], 2));
float o1 = degrees(atan(y[i] / x[i]));
float o2 = oN - o1;
Ny[i] = sin(radians(o2)) * l1;
Nx[i] = (cos(radians(o2)) * l1) - lx[i];
Nz[i] = z[i];
}
// Y Size.
// Right side.
/*for (int i=3; i<6; i++) WRong
{
float l1 = sqrt(pow(x[i], 2) + pow(y[i], 2));
float o1 = degrees(atan(y[i] / x[i]));
float o2 = o2P - o1;
Ny[i] = sin(radians(o2)) * l1;
Nx[i] = (cos(radians(o2)) * l1) - lx[i];
Nz[i] = z[i];
}
// Left size;
for (int i=0; i<4; i++) WRong
{
float l1 = sqrt(pow(x[i], 2) + pow(y[i], 2));
float o1 = degrees(atan(y[i] / x[i]));
float o2 = o2N - o1;
Ny[i] = sin(radians(o2)) * l1;
Nx[i] = (cos(radians(o2)) * l1) - lx[i];
Nz[i] = z[i];
}*/
}
@@ -0,0 +1,30 @@
// Orbit.h
#ifndef Orbit_H
#define Orbit_H
#include "WProgram.h"
class Orbit
{
public:
void getData(int ix[6], int iy[6], int iz[6]);
void getAngle (int ix, int iy);
void calculate();
int x[6], y[6], z[6];
int Nx[6], Ny[6], Nz[6];
int oP, o2P, oN, o2N;
int lx[6], ly[6];
};
#endif
@@ -0,0 +1,23 @@
// Rotation.cpp
#include "Rotation.h"
void Rotation::getData(int ix[6], int iy[6], int iz[6])
{
for (int i=0; i<6; i++)
{
x[i] = ix[i];
y[i] = iy[i];
z[i] = iz[i];
}
}
int NewX, NewY;
void rotate (int x, int y, int angel)
{
NewY = x * sin(radians(angel)) + y * cos(radians(angel));
NewX = x * cos(radians(angel)) - y * sin(radians(angel));
}
@@ -0,0 +1,24 @@
// Rotation.h
#ifndef Rotation_H
#define Rotation_H
#include "WProgram.h"
class Rotation
{
public:
void getData(int ix[6], int iy[6], int iz[6]);
int x[6], y[6], z[6];
};
#endif
@@ -0,0 +1,79 @@
#include "SSC32.h"
void SSC32::setup()
{
Serial1.begin(38400);
Serial.begin(38400);
time = 0;
walktime = 0;
}
void SSC32::MoveHead (int angel_from_mid)
{
Serial1.print(" #");
Serial1.print(9);
Serial1.print(" P");
Serial1.print(ConverttoMS((90 + angel_from_mid), smin[0], smax[0]));
Serial1.print(" T");
Serial1.println(100);
}
void SSC32::Render()
{
for (int i=0; i<6; i++)
{
RAW_2_SERVO[0+(i*3)] = ConverttoMS(DEG_2_CON[0+(i*3)], smin[0], smax[0]);
RAW_2_SERVO[1+(i*3)] = ConverttoMS(DEG_2_CON[1+(i*3)], smin[1], smax[1]);
RAW_2_SERVO[2+(i*3)] = ConverttoMS(DEG_2_CON[2+(i*3)], smin[2], smax[2]);
if (i != 0)
Serial.print(", ");
else
Serial.print("Ang: ");
Serial.print(DEG_2_CON[0+(i*3)]);
Serial.print(", ");
Serial.print(DEG_2_CON[1+(i*3)]);
Serial.print(", ");
Serial.print(DEG_2_CON[2+(i*3)]);
}
Serial.println(";");
}
int SSC32::ConverttoMS(int i, int low, int high)
{
int tmp = ( i * ( ( high - low ) / 180 ) );
return low + tmp;
}
void SSC32::toServos ()
{
// puss to servos
// var. SSC32.
// 0 | 3 // 16 | 0
// 1 | 4 // | | |
// 2 | 5 // 24 | 8
for (int i=0; i<9; i++)
{
Serial1.print(" #");
Serial1.print(16+i);// 18 22
Serial1.print(" P");
Serial1.print(RAW_2_SERVO[9+i]);
}
for (int i=0; i<9; i++)
{
Serial1.print(" #");
Serial1.print(i);
Serial1.print(" P");
Serial1.print(RAW_2_SERVO[i]);
}
Serial1.print(" T");
Serial1.println(walktime);
}
@@ -0,0 +1,34 @@
// SSC32.h
#ifndef SSC32_H
#define SSC32_H
#include "WProgram.h"
#include "Data_Manager.h"
class SSC32
{
public:
void setup();
void Render();
void toServos ();
void MoveHead (int angel_from_mid);
int ConverttoMS(int i, int low, int high);
// 0 | 3
// 1 | 4
// 2 | 5
int time;
};
#endif
@@ -0,0 +1,210 @@
/*
* Nunchuck -- Use a Wii Nunchuck
* Tim Hirzel http://www.growdown.com
*
notes on Wii Nunchuck Behavior.
This library provides an improved derivation of rotation angles from the nunchuck accelerometer data.
The biggest different over existing libraries (that I know of ) is the full 360 degrees of Roll data
from teh combination of the x and z axis accelerometer data using the math library atan2.
It is accurate with 360 degrees of roll (rotation around axis coming out of the c button, the front of the wii),
and about 180 degrees of pitch (rotation about the axis coming out of the side of the wii). (read more below)
In terms of mapping the wii position to angles, its important to note that while the Nunchuck
sense Pitch, and Roll, it does not sense Yaw, or the compass direction. This creates an important
disparity where the nunchuck only works within one hemisphere. At a result, when the pitch values are
less than about 10, and greater than about 170, the Roll data gets very unstable. essentially, the roll
data flips over 180 degrees very quickly. To understand this property better, rotate the wii around the
axis of the joystick. You see the sensor data stays constant (with noise). Because of this, it cant know
the difference between arriving upside via 180 degree Roll, or 180 degree pitch. It just assumes its always
180 roll.
*
* This file is an adaptation of the code by these authors:
* Tod E. Kurt, http://todbot.com/blog/
*
* The Wii Nunchuck reading code is taken from Windmeadow Labs
* http://www.windmeadow.com/node/42
*/
#ifndef WiiChuck_h
#define WiiChuck_h
#include "WProgram.h"
#include <Wire.h>
#include <math.h>
// these may need to be adjusted for each nunchuck for calibration
#define ZEROX 510
#define ZEROY 490
#define ZEROZ 460
#define RADIUS 180 // probably pretty universal
#define DEFAULT_ZERO_JOY_X 124
#define DEFAULT_ZERO_JOY_Y 132
class WiiChuck {
private:
byte cnt;
uint8_t status[6]; // array to store wiichuck output
byte averageCounter;
//int accelArray[3][AVERAGE_N]; // X,Y,Z
int i;
int total;
uint8_t zeroJoyX; // these are about where mine are
uint8_t zeroJoyY; // use calibrateJoy when the stick is at zero to correct
int lastJoyX;
int lastJoyY;
int angles[3];
boolean lastZ, lastC;
public:
byte joyX;
byte joyY;
boolean buttonZ;
boolean buttonC;
void begin()
{
Wire.begin();
cnt = 0;
averageCounter = 0;
Wire.beginTransmission (0x52); // transmit to device 0x52
Wire.send (0x40); // sends memory address
Wire.send (0x00); // sends memory address
Wire.endTransmission (); // stop transmitting
update();
for (i = 0; i<3;i++) {
angles[i] = 0;
}
zeroJoyX = DEFAULT_ZERO_JOY_X;
zeroJoyY = DEFAULT_ZERO_JOY_Y;
}
void calibrateJoy() {
zeroJoyX = joyX;
zeroJoyY = joyY;
}
void update() {
Wire.requestFrom (0x52, 6); // request data from nunchuck
while (Wire.available ()) {
// receive byte as an integer
status[cnt] = _nunchuk_decode_byte (Wire.receive()); //
cnt++;
}
if (cnt > 5) {
lastZ = buttonZ;
lastC = buttonC;
lastJoyX = readJoyX();
lastJoyY = readJoyY();
//averageCounter ++;
//if (averageCounter >= AVERAGE_N)
// averageCounter = 0;
cnt = 0;
joyX = (status[0]);
joyY = (status[1]);
for (i = 0; i < 3; i++)
//accelArray[i][averageCounter] = ((int)status[i+2] << 2) + ((status[5] & (B00000011 << ((i+1)*2) ) >> ((i+1)*2)));
angles[i] = (status[i+2] << 2) + ((status[5] & (B00000011 << ((i+1)*2) ) >> ((i+1)*2)));
//accelYArray[averageCounter] = ((int)status[3] << 2) + ((status[5] & B00110000) >> 4);
//accelZArray[averageCounter] = ((int)status[4] << 2) + ((status[5] & B11000000) >> 6);
buttonZ = !( status[5] & B00000001);
buttonC = !((status[5] & B00000010) >> 1);
_send_zero(); // send the request for next bytes
}
}
// UNCOMMENT FOR DEBUGGING
//byte * getStatus() {
// return status;
//}
float readAccelX() {
// total = 0; // accelArray[xyz][averageCounter] * FAST_WEIGHT;
return (float)angles[0] - ZEROX;
}
float readAccelY() {
// total = 0; // accelArray[xyz][averageCounter] * FAST_WEIGHT;
return (float)angles[1] - ZEROY;
}
float readAccelZ() {
// total = 0; // accelArray[xyz][averageCounter] * FAST_WEIGHT;
return (float)angles[2] - ZEROZ;
}
boolean zPressed() {
return (buttonZ && ! lastZ);
}
boolean cPressed() {
return (buttonC && ! lastC);
}
// for using the joystick like a directional button
boolean rightJoy(int thresh=60) {
return (readJoyX() > thresh and lastJoyX <= thresh);
}
// for using the joystick like a directional button
boolean leftJoy(int thresh=60) {
return (readJoyX() < -thresh and lastJoyX >= -thresh);
}
int readJoyX() {
return (int) joyX - zeroJoyX;
}
int readJoyY() {
return (int)joyY - zeroJoyY;
}
// R, the radius, generally hovers around 210 (at least it does with mine)
// int R() {
// return sqrt(readAccelX() * readAccelX() +readAccelY() * readAccelY() + readAccelZ() * readAccelZ());
// }
// returns roll degrees
int readRoll() {
return (int)(atan2(readAccelX(),readAccelZ())/ M_PI * 180.0);
}
// returns pitch in degrees
int readPitch() {
return (int) (acos(readAccelY()/RADIUS)/ M_PI * 180.0); // optionally swap 'RADIUS' for 'R()'
}
private:
byte _nunchuk_decode_byte (byte x)
{
x = (x ^ 0x17) + 0x17;
return x;
}
void _send_zero()
{
Wire.beginTransmission (0x52); // transmit to device 0x52
Wire.send (0x00); // sends one byte
Wire.endTransmission (); // stop transmitting
}
};
#endif
@@ -0,0 +1,15 @@
// atan2.cpp
#include "atan2.h"
void joy::JoyToDegAndDis (int x, int y)
{
deg = !(90 + degrees(atan2(y, x)));
distance = sqrt(y^2 + x^2);
}
int joy::JoyToDeg (int x, int y)
{ // watchout 90 + does not work good
return !(degrees(atan2(y, x)));
}
@@ -0,0 +1,26 @@
// atan2.h
#ifndef joy_H
#define joy_H
#include "WProgram.h"
class joy
{
public:
void JoyToDegAndDis (int x, int y);
int JoyToDeg (int x, int y);
int deg, distance;
};
#endif
@@ -0,0 +1,196 @@
// Hexapod FireFly
#include "Header.h"
#include "Wire.h" // Just dont work's, if you put it in the Header file.
// Setup.
void setup()
{
chuck.begin();
chuck.update();
smin[0] = 600;
smin[1] = 960;
smin[2] = 600;
smax[0] = 2400;
smax[1] = 2100;
smax[2] = 2400;
l1 = 10;
l2 = 15;
pinMode(13, OUTPUT); // Led L
Serial.begin(38400);
body.setup();
FireFly();
}
// Position.
int Position=1;
int PosMax=15;
int BeginPos=0;
int Directory=0;
void UpdatePosition(int i=0)
{
if (i == 0)
{
if ((Position < PosMax) && (Directory == 0))
Position++;
else if (Directory == 0)
Directory=1;
else if ((Position > 1) && (Directory == 1))
Position--;
else
Directory=0;
}
else
{
if (Position < PosMax)
Position++;
else
Position = BeginPos;
if (Directory == 1)
{
Directory = 2;
Position = BeginPos;
}
}
}
/*==============================================/
Go Use Class::operator=, To give Data From IK Class To Rotation or SSC32 Class.
/==============================================*/
// Variables.
double past = millis();
int Watchdog=0;
// Main loop.
void loop()
{
if (millis() < past) // to handle te exception of 50 day overflow of millis()
past = millis();
while ( ((millis() - past) < walktime) || (Watchdog == 0))
{
/* chuck.update();
ojx = chuck.readJoyX();
ojy = chuck.readJoyY();
oax = chuck.readAccelX();
oay = chuck.readAccelY();
// Mode Head Servo.
body.MoveHead(chuck.readRoll());*/
if (Watchdog == 0)
{
walktime = 300;
if (Directory==0)
{
UpdatePosition();
for (int i=0; i<6; i++)
{
COR_2_IK[0+(i*3)] = 10; //x
COR_2_IK[1+(i*3)] = Position; //y
COR_2_IK[2+(i*3)] = 0; //z
}
COR_2_IK[2+(0*3)] = -10;// x side body
COR_2_IK[2+(2*3)] = 10;///
COR_2_IK[2+(3*3)] = -10;//
COR_2_IK[2+(5*3)] = 10;///
COR_2_IK[0+(1*3)] = 10;// z side body
COR_2_IK[0+(4*3)] = 10;
}
else
{
PosMax = 7;
UpdatePosition(1);
for (int i2=0; i2<18; i2++)
{
COR_2_IK[i2] = TriPoD[Position][i2];
COR_2_IK[i2] = TriPoD[Position][i2];
}
for(int i=0; i<6; i++)
{
// zij, laag, achter
// 10, 15, -10, 15, 15, 0, 10, 15, 10, 10, 15, -10, 15, 15, 0, 10, 15, 10;
int cor[6] = { -5, 0, 5, -5, 0, 5 };
COR_2_IK[2+(i*3)] += cor[i];
}
}
/* orbit.getAngle(90 + (chuck.readRoll()/3), 90);// 90 + (chuck.readPitch()/3));
orbit.getData(x, y, z);
orbit.calculate();*/
// x, y, z
// x, z is above the leg, z is depth
// y, l3 is side leg, y is height
ik.setlegs();
body.Render();
Serial.println("Done Rendering");
/*if (ik.CheckForErrorCor() != 0)
{
warning();
Serial.println("Coordinate Error. ");
Serial.println(ik.CheckForErrorCor_print());
}
else*/
Watchdog = 1;
}
}
past = millis(); // gifs an overflow after 50 day run.
Serial.println("Out of loop");
if (Watchdog == 1)
{
if (ik.CheckForErrorAng() == 0) // check if there is no error.
{
Serial.println("Sending");
body.toServos();
}
else
{
warning();
Serial.println("Axis Error.");
}
Watchdog = 0;
}
}
@@ -0,0 +1,19 @@
// sequnces
// Hexapod seqencer.
int TriPoD_Size = 8;
int TriPoD[8][18] = {
{10,10, 0,10,15, 0,10,10, 0,10,15, 0,10,10, 0,10,15, 0},
{10,10,-2,10,15, 2,10,10,-2,10,15, 3,10,10,-2,10,15, 2},
{10,15,-2,10,15, 2,10,15,-2,10,15, 3,10,15,-2,10,15, 2},
{10,15,-2,10,10, 2,10,15,-2,10,10, 3,10,15,-2,10,10, 2},
{10,15, 0,10,10, 0,10,15, 0,10,10, 0,10,15, 0,10,10, 0},
{10,15, 2,10,10,-2,10,15, 2,10,10,-2,10,15, 2,10,10,-2},
{10,15, 2,10,15,-2,10,15, 2,10,15,-2,10,15, 2,10,15,-2},
{10,10, 2,10,15,-2,10,10, 2,10,15,-2,10,10, 2,10,15,-2}
};
@@ -0,0 +1,31 @@
// Hexapod FireFly
#include "hexapod.h"
#include "Gedrags_Classen.cpp"
//Watchdog WD;
//Ultrasone US;
hexapod *FireFly = new hexapod;
void setup()
{
Serial.begin(38400);
Serial1.begin(38400);
pinMode(13, OUTPUT);
FireFly->FireFly();
}
// Main loop.
void loop()
{
DataObject *cache = new DataObject;
cache->input(5, 3, 8, 8, 3, 0, 5, 3, -8, 5, 3, 8, 8, 3, 0, 5, 3, -8, 500);
//WD.CheckTime(DataLine);
FireFly->CoreSend(cache);
}
@@ -0,0 +1,55 @@
//Gedrags classen,
#ifndef GCC
#define GCC
#include "hexapod.h"
// LAYOUT
// _U_
// 0==/ \==3
// >***<
// 1===|---|===4
// >***<
// 2==\___/==5
class WalkForward //Direction
{
private:
DataObject LoopPatroon[8];
DataObject HuidigePositie;
hexapod *FireFly;
//Startup VARIABLES
void init(hexapod *pntr)
{
LoopPatroon[0](0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 800);
LoopPatroon[1](0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 800);
LoopPatroon[2](0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 800);
LoopPatroon[3](0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 800);
LoopPatroon[4](0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 800);
LoopPatroon[5](0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 800);
LoopPatroon[6](0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 800);
LoopPatroon[7](0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 800);
FireFly = pntr;
}
void send(DataObject pntr)
{
FireFly->CoreSend(&pntr);
}
public:
void Run()
{
//Start runnning code until exit or expection raises.
send(LoopPatroon[0]);//Test
}
};
#endif
@@ -0,0 +1,60 @@
//Ultrasone.cpp
// V3.0
#include "Ultrasone.h"
void Ultrasone::GetRadar(Data *DataLine)
{
DataLine->HeadTime = 0;
#ifdef DEBUGUS
Serial.print("### Ultrasone Direction/Position: ");
Serial.print(CurrentDirection);
Serial.print(", ");
Serial.println(CurrentPosition);
#endif
if (CurrentDirection == 0) // Left
{
if (CurrentPosition > MaxLeft)
{
CurrentPosition--;
DataLine->HeadAngle = CurrentPosition;
Con.ConvertHead(DataLine);
SSC32.MoveHead(DataLine);
Serial.print("### Ultrasone Distance: ");
Serial.println(DataLine->FireFly.GetUltraSoneDistance());
}
else
CurrentDirection = 1;
}
else if(CurrentDirection == 1) // Right
{
if (CurrentPosition < MaxRight)
{
CurrentPosition++;
DataLine->HeadAngle = CurrentPosition;
Con.ConvertHead(DataLine);
SSC32.MoveHead(DataLine);
Serial.print("### Ultrasone Distance: ");
Serial.println(DataLine->FireFly.GetUltraSoneDistance());
}
else
CurrentDirection = 0;
}
}
/*
[Vector]
X = Distance / Cos( CurrentPosition * pi2rad );
Y = Distance / sin( CurrentPosition / pi2rad );
*/
@@ -0,0 +1,39 @@
//Ultrasone.h
// V3.0
#ifndef ULTRASONE_H
#define ULTRASONE_H
#include "Arduino.h"
#include "Data.h"
#include "Servos.h"
#include "Converter.h"
#define MaxLeft -45
#define MaxRight 45
class Ultrasone
{
private:
Servos SSC32;
Converter Con;
public:
void GetRadar(Data *DataLine);
int CurrentPosition;
byte CurrentDirection;
Ultrasone()
{
CurrentPosition = 0;
CurrentDirection = 0; // Left
}
};
#endif
@@ -0,0 +1,37 @@
// Watchdog.cpp
#include "Watchdog.h"
void Watchdog::CheckTime(Data *DataLine)
{
if ((millis() >= (DataLine->LastSendTime + DataLine->WalkTime)) & (DataLine->ReadyToSend = true ))
{
DataLine->Send = 1;
DataLine->LastSendTime = millis();
#ifdef DEBUGW
Serial.println("### WatchDog->Watchdog ###");
Serial.print("### ");
Serial.print( millis());
Serial.println(" WatchDog->DataLine.Send = True");
Serial.print("### WatchDog->Watchdog Walktime: ");
Serial.println(DataLine->WalkTime);
#endif
}
else if ((DataLine->LastSendTime == 0 ) & (DataLine->ReadyToSend = true))
{
DataLine->Send = 1;
DataLine->LastSendTime = millis();
#ifdef DEBUGW
Serial.println("### WatchDog->Watchdog Startup ###");
Serial.print("### ");
Serial.print( millis());
Serial.println(" WatchDog->DataLine.Send = True");
Serial.print("### WatchDog->Watchdog Walktime: ");
Serial.println(DataLine->WalkTime);
#endif
}
}
@@ -0,0 +1,20 @@
// Watchdog.h
// V3.0
#ifndef WATCHDOG_H
#define WATCHDOG_H
#include "Arduino.h"
#include "Data.h"
class Watchdog
{
public:
void CheckTime(Data *DataLine);
};
#endif
Loaded 100 of 542 files, more files were not shown because too many files have changed in this diff. Show more