Skip to content
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: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Daten/*
data/*
32 changes: 32 additions & 0 deletions README.md
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 WaveGen/Arduino/basicStepperDriver/basicStepperDriver.ino
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") {

Copy link
Copy Markdown
Collaborator

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 typischerweise strcmp(name, "a") == 0

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");
}
}

}
22 changes: 22 additions & 0 deletions WaveGen/Arduino/libraries/StepperDriver/LICENSE
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.

57 changes: 57 additions & 0 deletions WaveGen/Arduino/libraries/StepperDriver/Makefile
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
Loading