diff --git a/docs/.obsidian/workspace.json b/docs/.obsidian/workspace.json index a62e138..89a1b1b 100644 --- a/docs/.obsidian/workspace.json +++ b/docs/.obsidian/workspace.json @@ -10,25 +10,16 @@ { "id": "e338073e64d4becc", "type": "leaf", - "state": { - "type": "empty", - "state": {} - } - }, - { - "id": "cdbb92cef28dd635", - "type": "leaf", "state": { "type": "markdown", "state": { - "file": "Getting started.md", + "file": "readme.md", "mode": "source", "source": false } } } - ], - "currentTab": 1 + ] } ], "direction": "vertical" @@ -94,7 +85,7 @@ "state": { "type": "backlink", "state": { - "file": "Getting started.md", + "file": "readme.md", "collapseAll": false, "extraContext": false, "sortOrder": "alphabetical", @@ -111,7 +102,7 @@ "state": { "type": "outgoing-link", "state": { - "file": "Getting started.md", + "file": "readme.md", "linksCollapsed": false, "unlinkedCollapsed": true } @@ -134,7 +125,7 @@ "state": { "type": "outline", "state": { - "file": "Getting started.md" + "file": "readme.md" } } } @@ -155,18 +146,23 @@ "command-palette:Open command palette": false } }, - "active": "cdbb92cef28dd635", + "active": "e338073e64d4becc", "lastOpenFiles": [ - "api.md", + "spot.md", + "Electronic connections.canvas", + "media/diagram.png", + "media/image.png", "Getting started.md", + "Getting_started.md", + "Getting.md", + "readme.md", "Spot.md", + "api.md", "Simulation/Simulation.md", "Simulation/Pasted image 20240319103157.png", "Simulation", - "Electronic connections.canvas", "media/PIO-upload.png", "media", - "readme.md", "Untitled.canvas", "Architecture & Design principles.md" ] diff --git a/docs/Electronic connections.canvas b/docs/Electronic connections.canvas deleted file mode 100644 index 24e3ea7..0000000 --- a/docs/Electronic connections.canvas +++ /dev/null @@ -1,48 +0,0 @@ -{ - "nodes":[ - {"id":"6cfc1d84e50573ff","type":"text","text":"Current sensor","x":-745,"y":-240,"width":250,"height":50}, - {"type":"text","text":"Power switch","id":"4d3eece6df4c067c","x":-745,"y":-330,"width":250,"height":60}, - {"type":"text","text":"Charger","id":"f90788dee6e7df0f","x":-1025,"y":-330,"width":250,"height":60}, - {"type":"text","text":"Battery 2S 2P","id":"f39d83b8fc4b2ce7","x":-870,"y":-460,"width":250,"height":60}, - {"type":"text","text":"3A Buck convert (5.1V)","id":"c0e4326352ef6acd","x":-745,"y":-160,"width":250,"height":60}, - {"type":"text","text":"20A Buck convert (6.8V)","id":"f0dee23dbf62a0ae","x":-1025,"y":-160,"width":250,"height":60}, - {"type":"text","text":"ESP32 Camera","id":"bf547d9155aabb39","x":-745,"y":-60,"width":250,"height":60}, - {"type":"text","text":"I2C","id":"fdd407781dd2424b","x":-745,"y":40,"width":250,"height":60}, - {"type":"text","text":"OLED","id":"c2841c1b6af26ea4","x":-845,"y":240,"width":125,"height":60}, - {"id":"fcfe052ee54dd2b8","type":"text","text":"GY271","x":-700,"y":240,"width":115,"height":60}, - {"type":"text","text":"MPU6050","id":"864e83f42107c496","x":-570,"y":240,"width":150,"height":60}, - {"type":"text","text":"Button","id":"eb35a70a906a91a4","x":-410,"y":243,"width":155,"height":55}, - {"id":"5f21765f42355f13","type":"text","text":"ADC","x":-410,"y":40,"width":155,"height":60}, - {"id":"2affa2d33afa20e9","type":"text","text":"Voltage sensor","x":-457,"y":-330,"width":250,"height":60}, - {"type":"text","text":"Ultra sonic sensor (Left)","id":"a65cfc4680ee5a5a","x":-255,"y":-30,"width":250,"height":50}, - {"type":"text","text":"PWM Servo Controller","id":"94661729af97f335","x":-1025,"y":40,"width":250,"height":60}, - {"id":"6552aaf56de0ad2d","x":-1025,"y":243,"width":155,"height":57,"type":"text","text":"12 Servos"}, - {"type":"text","text":"Button LED","id":"7f493c7f8d4efd1a","x":-254,"y":-210,"width":155,"height":50}, - {"type":"text","text":"Ultra sonic sensor (Right)","id":"1ffd9caa91466092","x":-254,"y":-85,"width":250,"height":50}, - {"id":"6707ec9494cea65f","x":-254,"y":-150,"width":194,"height":50,"type":"text","text":"OV2640 Camera"} - ], - "edges":[ - {"id":"a18757214fb3e094","fromNode":"fdd407781dd2424b","fromSide":"top","toNode":"bf547d9155aabb39","toSide":"bottom"}, - {"id":"0d603ea7ba19ec7e","fromNode":"864e83f42107c496","fromSide":"top","toNode":"fdd407781dd2424b","toSide":"bottom"}, - {"id":"e16c1e54b1aba5d4","fromNode":"f90788dee6e7df0f","fromSide":"top","toNode":"f39d83b8fc4b2ce7","toSide":"bottom"}, - {"id":"860ef66c0fd73c40","fromNode":"f39d83b8fc4b2ce7","fromSide":"bottom","toNode":"4d3eece6df4c067c","toSide":"top"}, - {"id":"593cf625cc68130c","fromNode":"fdd407781dd2424b","fromSide":"bottom","toNode":"c2841c1b6af26ea4","toSide":"top"}, - {"id":"49a4fa754fd182e4","fromNode":"fcfe052ee54dd2b8","fromSide":"top","toNode":"fdd407781dd2424b","toSide":"bottom"}, - {"id":"9306275aac5bf98f","fromNode":"4d3eece6df4c067c","fromSide":"bottom","toNode":"6cfc1d84e50573ff","toSide":"top"}, - {"id":"664d3ac89f1e85de","fromNode":"6cfc1d84e50573ff","fromSide":"left","toNode":"f0dee23dbf62a0ae","toSide":"top"}, - {"id":"1ad720ac767156c3","fromNode":"2affa2d33afa20e9","fromSide":"bottom","toNode":"5f21765f42355f13","toSide":"top"}, - {"id":"af1edce9d291e30a","fromNode":"6cfc1d84e50573ff","fromSide":"bottom","toNode":"c0e4326352ef6acd","toSide":"top"}, - {"id":"dd00e43ff971aec3","fromNode":"c0e4326352ef6acd","fromSide":"bottom","toNode":"bf547d9155aabb39","toSide":"top"}, - {"id":"5ea530abbcfce01a","fromNode":"6cfc1d84e50573ff","fromSide":"right","toNode":"5f21765f42355f13","toSide":"top"}, - {"id":"5e668628aacefbff","fromNode":"eb35a70a906a91a4","fromSide":"top","toNode":"5f21765f42355f13","toSide":"bottom"}, - {"id":"3f90a327094d24cd","fromNode":"5f21765f42355f13","fromSide":"left","toNode":"fdd407781dd2424b","toSide":"right"}, - {"id":"a0abde710ac5dda2","fromNode":"f0dee23dbf62a0ae","fromSide":"bottom","toNode":"94661729af97f335","toSide":"top"}, - {"id":"4368da5755684b47","fromNode":"4d3eece6df4c067c","fromSide":"right","toNode":"2affa2d33afa20e9","toSide":"left"}, - {"id":"3ad0ddba7ec01e15","fromNode":"bf547d9155aabb39","fromSide":"right","toNode":"7f493c7f8d4efd1a","toSide":"left"}, - {"id":"10931e2a93ab81a3","fromNode":"a65cfc4680ee5a5a","fromSide":"left","toNode":"bf547d9155aabb39","toSide":"right"}, - {"id":"e0ec6623bdee3f32","fromNode":"1ffd9caa91466092","fromSide":"left","toNode":"bf547d9155aabb39","toSide":"right"}, - {"id":"739ff15b59033da9","fromNode":"94661729af97f335","fromSide":"bottom","toNode":"6552aaf56de0ad2d","toSide":"top"}, - {"id":"db9df4a40b5eb56a","fromNode":"6707ec9494cea65f","fromSide":"left","toNode":"bf547d9155aabb39","toSide":"right"}, - {"id":"9773993ba8b1a858","fromNode":"fdd407781dd2424b","fromSide":"left","toNode":"94661729af97f335","toSide":"right"} - ] -} \ No newline at end of file diff --git a/docs/Simulation/Pasted image 20240319103157.png b/docs/Simulation/Pasted image 20240319103157.png deleted file mode 100644 index 14d209f..0000000 Binary files a/docs/Simulation/Pasted image 20240319103157.png and /dev/null differ diff --git a/docs/Simulation/Simulation.md b/docs/Simulation/Simulation.md deleted file mode 100644 index dbab71f..0000000 --- a/docs/Simulation/Simulation.md +++ /dev/null @@ -1,10 +0,0 @@ - - -## Ideas - -## ThreeJs -Use the GUI panel for setting monaco for code editing, make an robot SDK for easy scripting. - - -Webots ui -![[Pasted image 20240319103157.png]] diff --git a/docs/api.md b/docs/api.md index f89602d..4cff200 100644 --- a/docs/api.md +++ b/docs/api.md @@ -1,8 +1,39 @@ # API -https://dev.bostondynamics.com/docs/concepts/choreography/choreography_in_tablet.html + -| HTTP Method | Endpoint | Description | Parameters | +The back end exposes a number of API endpoints which are referenced in the table below. + +| Method | Endpoint | Authentication | POST JSON Body | Info | +| ------ | --------------------------------------- | ------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------- | +| GET | /rest/features | `NONE_REQUIRED` | none | Tells the client which features of the UI should be use | +| GET | /rest/mqttStatus | `IS_AUTHENTICATED` | none | Current MQTT connection status | +| GET | /rest/mqttSettings | `IS_ADMIN` | none | Currently used MQTT settings | +| POST | /rest/mqttSettings | `IS_ADMIN` | `{"enabled":false,"uri":"mqtt://192.168.1.12:1883","username":"","password":"","client_id":"esp32-f412fa4495f8","keep_alive":120,"clean_session":true}` | Update MQTT settings with new parameters | +| GET | /rest/ntpStatus | `IS_AUTHENTICATED` | none | Current NTP connection status | +| GET | /rest/ntpSettings | `IS_ADMIN` | none | Current NTP settings | +| POST | /rest/ntpSettings | `IS_ADMIN` | `{"enabled": true,"server": "time.google.com","tz_label": "Europe/London","tz_format": "GMT0BST,M3.5.0/1,M10.5.0"}` | Update the NTP settings | +| GET | /rest/apStatus | `IS_AUTHENTICATED` | none | Current AP status and client information | +| GET | /rest/apSettings | `IS_ADMIN` | none | Current AP settings | +| POST | /rest/apSettings | `IS_ADMIN` | `{"provision_mode": 1,"ssid": "ESP32-SvelteKit-e89f6d20372c","password": "esp-sveltekit","channel": 1,"ssid_hidden": false,"max_clients": 4,"local_ip": "192.168.4.1","gateway_ip": "192.168.4.1","subnet_mask": "255.255.255.0"}` | Update AP settings | +| GET | /rest/wifiStatus | `IS_AUTHENTICATED` | none | Current status of the wifi client connection | +| GET | /rest/scanNetworks | `IS_ADMIN` | none | Async Scan for Networks in Range | +| GET | /rest/listNetworks | `IS_ADMIN` | none | List networks in range after successful scanning. Otherwise triggers scanning. | +| GET | /rest/wifiSettings | `IS_ADMIN` | none | Current WiFi settings | +| POST | /rest/wifiSettings | `IS_ADMIN` | `{"hostname":"esp32-f412fa4495f8","priority_RSSI":true,"wifi_networks":[{"ssid":"YourSSID","password":"YourPassword","static_ip_config":false}]}` | Update WiFi settings and credentials | +| GET | /rest/systemStatus | `IS_AUTHENTICATED` | none | Get system information about the ESP. | +| POST | /rest/restart | `IS_ADMIN` | none | Restart the ESP32 | +| POST | /rest/factoryReset | `IS_ADMIN` | none | Reset the ESP32 and all settings to their default values | +| POST | /rest/uploadFirmware | `IS_ADMIN` | none | File upload of firmware.bin | +| POST | /rest/signIn | `NONE_REQUIRED` | `{"password": "admin","username": "admin"}` | Signs a user in and returns access token | +| GET | /rest/securitySettings | `IS_ADMIN` | none | retrieves all user information and roles | +| POST | /rest/securitySettings | `IS_ADMIN` | `{"jwt_secret": "734cb5bb-5597b722", "users": [{"username": "admin", "password": "admin", "admin": true}, {"username": "guest", "password": "guest", "admin": false, }]}` | retrieves all user information and roles | +| GET | /rest/verifyAuthorization | `NONE_REQUIRED` | none | Verifies the content of the auth bearer token | +| GET | /rest/generateToken?username={username} | `IS_ADMIN` | `{"token": "734cb5bb-5597b722"}` | Generates a new JWT token for the user from username | +| POST | /rest/sleep | `IS_AUTHENTICATED` | none | Puts the device in deep sleep mode | +| POST | /rest/downloadUpdate | `IS_ADMIN` | `{"download_url": "https://github.com/theelims/ESP32-sveltekit/releases/download/v0.1.0/firmware_esp32s3.bin"}` | Download link for OTA. This requires a valid SSL certificate and will follow redirects. | + + diff --git a/docs/Getting started.md b/docs/getting_started.md similarity index 86% rename from docs/Getting started.md rename to docs/getting_started.md index 3498d7b..e26201e 100644 --- a/docs/Getting started.md +++ b/docs/getting_started.md @@ -1,6 +1,11 @@ +# Getting started + ## Prerequisites + To prepare the frontend code for the ESP32, a specific build chain is required. Start by installing these essential tools: + ### Required Software + Install the following software to ensure all functionalities: - [VSCode](https://code.visualstudio.com/) - Preferred IDE for development @@ -9,12 +14,17 @@ Install the following software to ensure all functionalities: - [Python](https://www.python.org/downloads/) - Used for firmware build scripts ### Project Structure + Understand the project organization through these key directories: + - [docs/](https://github.com/runeharlyk/SpotMicroESP32-Leika/tree/master/docs) - Contains all documentation - [app/](https://github.com/runeharlyk/SpotMicroESP32-Leika/tree/master/app) - SvelteKit-based frontend - [esp32](https://github.com/runeharlyk/SpotMicroESP32-Leika/tree/master/esp32) - Firmware for the robot + ## Setting up PlatformIO + ### Configure Build Target + Modify the `platformio.ini` file at [platformio.ini](https://github.com/runeharlyk/SpotMicroESP32-Leika/tree/master/esp32/platformio.ini) to match your board specifications. Adapt or remove environment settings as necessary based on your board. ```ini @@ -31,37 +41,42 @@ board_build.mcu = esp32c3 For additional boards, refer to the [official board list](https://docs.platformio.org/en/latest/boards/index.html#espressif-32). ### Build & Upload Process + Update the `platformio.ini` file for your board, then navigate to the PlatformIO tab, select your environment, click `Upload Filesystem Image` and after uploading finish, click `Upload and Monitor`. The filesystem image only has to be uploaded the first time and will override config files on the microcontroller. When uploading new firmware the app is evaluated and if necessary will be rebuild. ## Setting up SvelteKit + ### Proxy Configuration for Development + Configure the proxy settings in the `vite.config.ts` file to direct API calls to your ESP32 device. By default it used the factory MDNS address, but can be changed to the ip if preferred. ```ts server: { - proxy: { - '/api': { - target: 'http://spot-micro.local', // Here - changeOrigin: true, - ws: true - }, - '/ws': { - target: 'ws://spot-micro.local', // Here - changeOrigin: true, - ws: true - } - } + proxy: { + '/api': { + target: 'http://spot-micro.local', // Here + changeOrigin: true, + ws: true + }, + '/ws': { + target: 'ws://spot-micro.local', // Here + changeOrigin: true, + ws: true + } + } }, ``` Changes require a restart of the development server. ### Start the Development Server + Use the following commands to launch the development server with Vite, enabling instant updates: ```sh cd app pnpm run dev ``` -Access the frontend via the provided browser link. \ No newline at end of file + +Access the frontend via the provided browser link. diff --git a/docs/media/diagram.png b/docs/media/diagram.png new file mode 100644 index 0000000..838d691 Binary files /dev/null and b/docs/media/diagram.png differ diff --git a/docs/readme.md b/docs/readme.md index 3454482..2835fd7 100644 --- a/docs/readme.md +++ b/docs/readme.md @@ -1,9 +1,10 @@ # Welcome to the docs + The docs a structured as obsidian notes to allow for better writing and more expressive content. -TODO: -READTHEDOCS site +## Table of content -Read about the robots capabilities: [[Spot]] -See the Electronic connection diagram: [[Electronic connections.canvas]] -Read about the [[api]] \ No newline at end of file +- [Robot build](robot_build.md) +- [Getting started](getting_started.md) +- [API](api.md) +- [Robots capabilities](spot.md) diff --git a/docs/robot_build.md b/docs/robot_build.md new file mode 100644 index 0000000..52a1c80 --- /dev/null +++ b/docs/robot_build.md @@ -0,0 +1,22 @@ +# Robot build + +## Electronics + +- ESP32 cam - Brain +- OV2640 160° - Camera +- PCA9685 - Servo board +- 12x 20kg(or higher) servo motors +- MPU6050 - Inertial measurement unit +- GY-271 - Magnetometer +- SZBK07 - 20A DC-DC Buck Converter +- LM2596 or XL4015 - DC-DC Stepdown Module +- 2x HC-SR04 - Ultrasonic Distance Sensor +- 0.96" SD1306 - OLED diplay +- ACS712 - Current sensor +- ADS1115 - 16 bit analog to digital converter +- Power button w/ led +- 4x 18650 Li-ion battery in 2P2S configuration +- Couple of resistors (10K, 47.7k, 33K) +- 4x Servo extension cables + +![Electronics diagram](media/diagram.png "Title")