-
Notifications
You must be signed in to change notification settings - Fork 1
added optimization for a sinusoidal wave #1
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
pascal-meyer01
wants to merge
7
commits into
JMUWRobotics:fourcams
Choose a base branch
from
pascal-meyer01:fourcams
base: fourcams
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
ea19145
added optimization for a sinusoidal wave
8eaf17c
ditch std::{format, println} in favour of fmt, update fmt to 11.1.4
5c069cc
implement experimental intersection with newto
46edecc
working sinusoidal wave fit for a flat surface -> not tested for waves
0dbcbf7
added data
174fbbd
added data
188c8ec
added arduino code
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| Daten/* | ||
| data/* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| # Run four cameras | ||
|
|
||
| to compile use: | ||
|
|
||
| ```sh | ||
| meson setup builddir | ||
| meson compile -C builddir | ||
| ``` | ||
|
|
||
| then run the program with: | ||
|
|
||
| ```sh | ||
| python3 viswrap.py | ||
| ``` | ||
|
|
||
| each argument needs to be passed with ```--sift``` as example | ||
|
|
||
| # example | ||
|
|
||
| Example for a flat water surface with 4 cameras: | ||
|
|
||
| ```sh | ||
| python3 viswrap.py --solve --sift --lone 0.4 | ||
| ``` | ||
|
|
||
| # arguments | ||
|
|
||
| | Argument | Description | Type | | ||
| |------------|---------------------------------|--------| | ||
| | `--sin` | Enables sine processing | Flag | | ||
| | `--lone` | Sets the lone threshold value | Float | | ||
| | `--solve` | Enable the ceres solver | Flag | |
183 changes: 183 additions & 0 deletions
183
WaveGen/Arduino/basicStepperDriver/basicStepperDriver.ino
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,183 @@ | ||
| #include <Arduino.h> | ||
| #include "BasicStepperDriver.h" | ||
|
|
||
| // motor : https://www.omc-stepperonline.com/de/p-series-ip67-wasserdicht-nema-23-schrittmotor-5-0a-1-8nm-254-95oz-in-23ip67-20 | ||
| // stepper controller: https://www.omc-stepperonline.com/de/digitaler-schrittmotortreiber-1-0-4-2a-20-50vdc-fuer-nema-17-23-24-schrittmotor-dm542t | ||
|
|
||
| // the motor has a 1.8 deg step so 200 steps | ||
| #define MOTOR_STEPS 200 | ||
|
|
||
| // set a safty RPM | ||
| #define SAFTY_RPM 600 | ||
|
|
||
| // step resolution on stepper controller set to 800 step/rev | ||
| #define MICROSTEPS 4 | ||
|
|
||
| // All the wires needed for full functionality | ||
| #define DIR 4 | ||
| #define STEP 3 | ||
| #define ENABLE 2 | ||
|
|
||
| //Uncomment line to use enable/disable functionality | ||
| //#define SLEEP 13 | ||
|
|
||
| // set all value to default | ||
| float rpmVal = 60.0; | ||
| float timeVal = 0.0; | ||
| int angleVal = 0; | ||
| int start_delay = 0; | ||
|
|
||
| unsigned long start_time = 0; | ||
|
|
||
| // start bsic driver | ||
| BasicStepperDriver stepper(MOTOR_STEPS, DIR, STEP, ENABLE); | ||
|
|
||
| void setup() { | ||
|
|
||
| // enable serial | ||
| Serial.begin(9600); | ||
| while (!Serial) {;} // Wait for serial port to connect | ||
| Serial.println("Found serial connection of wavegen"); | ||
|
|
||
| stepper.begin(rpmVal, MICROSTEPS); | ||
| stepper.setEnableActiveState(LOW); | ||
|
|
||
| stepper.disable(); | ||
|
|
||
| } | ||
|
|
||
| void loop(){ | ||
|
|
||
| // parse the message from python | ||
| if (Serial.available() > 0) { | ||
|
|
||
| // read in line | ||
| String input = Serial.readStringUntil('\n'); | ||
| input.trim(); | ||
|
|
||
| // Split command and value | ||
| int spaceIndex = input.indexOf(' '); | ||
| String command = input; | ||
| int value = 0; | ||
|
|
||
| // Split string into tokens | ||
| const int maxTokens = 10; | ||
| String tokens[maxTokens]; | ||
| int tokenCount = 0; | ||
|
|
||
| // sort the messages | ||
| while (input.length() > 0 && tokenCount < maxTokens) { | ||
| int spaceIndex = input.indexOf(' '); | ||
| if (spaceIndex == -1) { | ||
|
|
||
| tokens[tokenCount++] = input; | ||
| break; | ||
|
|
||
| } else { | ||
|
|
||
| tokens[tokenCount++] = input.substring(0, spaceIndex); | ||
| input = input.substring(spaceIndex + 1); | ||
| input.trim(); | ||
|
|
||
| } | ||
| } | ||
|
|
||
| // Parse name/value pairs | ||
| for (int i = 0; i < tokenCount - 1; i += 2) { | ||
| String name = tokens[i]; | ||
| float value = tokens[i + 1].toFloat(); | ||
|
|
||
| if (name == "a") { | ||
| angleVal = tokens[i + 1].toInt(); | ||
| Serial.print("Set angle to "); | ||
| Serial.println(angleVal); | ||
|
|
||
| } else if (name == "t") { | ||
|
|
||
| // time in ms | ||
| timeVal = value; | ||
| Serial.print("Set time to "); | ||
| Serial.println(timeVal); | ||
|
|
||
| } else if (name == "rpm") { | ||
|
|
||
| if(value > SAFTY_RPM){ | ||
| rpmVal = SAFTY_RPM; | ||
| } | ||
| else if(value != 0.0){ | ||
| rpmVal = value; | ||
| } | ||
|
|
||
| // set the new rpm value | ||
| stepper.begin(rpmVal, MICROSTEPS); | ||
|
|
||
| Serial.print("Set rpm to "); | ||
| Serial.println(rpmVal); | ||
|
|
||
| } else if(name == "delay"){ | ||
|
|
||
| start_delay = value; | ||
| Serial.print("Delay before start: "); | ||
| Serial.println(start_delay); | ||
|
|
||
| } else { | ||
|
|
||
| Serial.print("Unknown parameter: "); | ||
| Serial.println(name); | ||
| } | ||
| } | ||
|
|
||
| delay(start_delay * 1000); // in sec | ||
| Serial.println("Starting"); | ||
|
|
||
| } | ||
|
|
||
|
|
||
| if(angleVal != 0){ | ||
| Serial.print("start rotation with angle and rpm: "); | ||
| Serial.print(angleVal); | ||
| Serial.print(" "); | ||
| Serial.println(rpmVal); | ||
|
|
||
| stepper.enable(); | ||
| // if no rpm given the rotation speed is set to default | ||
| stepper.rotate(angleVal); | ||
|
|
||
| stepper.disable(); | ||
| angleVal = 0; | ||
| rpmVal = 60.0; | ||
|
|
||
| Serial.println("Finished"); | ||
|
|
||
| } | ||
|
|
||
| // only set in rpm if the angle is 0 -> else do angular rotation | ||
| if(rpmVal != 60.0 && angleVal == 0){ | ||
|
|
||
| Serial.print("rotating at rpm "); | ||
| Serial.println(rpmVal); | ||
|
|
||
| // set the new rpm value | ||
| stepper.setRPM(rpmVal); | ||
|
|
||
| if(start_time = 0){ | ||
| start_time = millis(); | ||
| } | ||
|
|
||
| stepper.rotate(360); | ||
| } | ||
|
|
||
| if(timeVal != 0.0){ | ||
| //Serial.println(millis() - start_time); | ||
| if(millis() - start_time > timeVal){ | ||
| // set RPM and set time to 0 | ||
| timeVal = 0.0; | ||
| rpmVal = 60.0; | ||
| stepper.disable(); | ||
|
|
||
| Serial.println("Stopped motor due to time"); | ||
| Serial.println("Finished"); | ||
| } | ||
| } | ||
|
|
||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| The MIT License (MIT) | ||
|
|
||
| Copyright (c) 2015 Laurentiu Badea | ||
|
|
||
| Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| of this software and associated documentation files (the "Software"), to deal | ||
| in the Software without restriction, including without limitation the rights | ||
| to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| copies of the Software, and to permit persons to whom the Software is | ||
| furnished to do so, subject to the following conditions: | ||
|
|
||
| The above copyright notice and this permission notice shall be included in all | ||
| copies or substantial portions of the Software. | ||
|
|
||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| SOFTWARE. | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| # Default build architecture and board | ||
| TARGET ?= arduino:avr:uno | ||
| CORE = $(shell echo $(TARGET) | cut -d: -f1,2) | ||
|
|
||
| # Where to save the Arduino support files, this should match what is in arduino-cli.yaml | ||
| ARDUINO_DIR ?= .arduino | ||
|
|
||
| default: | ||
| ################################################################################################# | ||
| # Initial setup: make .arduino/arduino-cli setup | ||
| # | ||
| # Build all the examples: make all TARGET=adafruit:samd:adafruit_feather_m0 | ||
| # | ||
| # Install more cores: make core TARGET=adafruit:samd:adafruit_feather_m0 | ||
| # (edit arduino-cli.yaml and add repository if needed) | ||
| ################################################################################################# | ||
|
|
||
| # See https://arduino.github.io/arduino-cli/installation/ | ||
| ARDUINO_CLI_URL = https://downloads.arduino.cc/arduino-cli/arduino-cli_latest_Linux_64bit.tar.gz | ||
| ARDUINO_CLI ?= $(ARDUINO_DIR)/arduino-cli --config-file arduino-cli.yaml | ||
| EXAMPLES := $(shell ls examples) | ||
|
|
||
| COMPILE = $(ARDUINO_CLI) compile --warnings all --fqbn $(TARGET) | ||
|
|
||
| all: # Build all example sketches | ||
| all: $(EXAMPLES:%=%.hex) | ||
| ls -l build | ||
|
|
||
| %.hex: # Generic rule for compiling sketch to uploadable hex file | ||
| %.hex: examples/% core | ||
| $(ARDUINO_CLI) compile --warnings all --fqbn $(TARGET) --output-dir build $< | ||
|
|
||
| # Remove built objects | ||
| clean: | ||
| rm -rfv build | ||
|
|
||
| core: $(ARDUINO_DIR)/arduino-cli | ||
| $(ARDUINO_CLI) core install $(CORE) | ||
|
|
||
| $(ARDUINO_DIR)/arduino-cli: # Download and install arduino-cli | ||
| $(ARDUINO_DIR)/arduino-cli: | ||
| mkdir -p $(ARDUINO_DIR) | ||
| cd $(ARDUINO_DIR) | ||
| curl -L -s $(ARDUINO_CLI_URL) \ | ||
| | tar xfz - -C $(ARDUINO_DIR) arduino-cli | ||
| chmod 755 $@ | ||
| $(ARDUINO_CLI) version | ||
|
|
||
| setup: # Configure cores and libraries for arduino-cli (which it will download if missing) | ||
| setup: $(ARDUINO_DIR)/arduino-cli | ||
| mkdir -p $(ARDUINO_DIR)/libraries | ||
| ln -sf $(CURDIR) $(ARDUINO_DIR)/libraries/ | ||
| $(ARDUINO_CLI) config dump | ||
| $(ARDUINO_CLI) core update-index | ||
| $(ARDUINO_CLI) core list | ||
|
|
||
| .PHONY: clean %.hex all setup |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Kann das arduino-SDK strings mit
==vergleichen? In C geht das nicht, da braucht man typischerweisestrcmp(name, "a") == 0