Forráskód Böngészése

added motor folder

Dennis Grotz 5 éve
szülő
commit
bc47f74801

+ 32 - 0
SketchAssistant/StaticLib1/Motorheader/Actuator.h

@@ -0,0 +1,32 @@
+/*
+ *  Actuator.h
+ *
+ *  Copyright (C)
+ *  Honda Research Institute Europe GmbH
+ *  Carl-Legien-Str. 30
+ *  63073 Offenbach/Main
+ *  Germany
+ *
+ *  UNPUBLISHED PROPRIETARY MATERIAL.
+ *  ALL RIGHTS RESERVED.
+ *
+ */
+#pragma once
+#include <stdbool.h>
+#include <stdint.h>
+#include <time.h>
+
+typedef struct Actuator
+{
+    bool active;
+    bool continuous;
+    clock_t endTime;
+    float intensity;
+    float minIntensity; // Cut off values under threshold (default: 0)
+    float maxIntensity; // Cut off values over threshold  (default: 1)
+    uint16_t frequency; // 250Hz, for Pacinian corpuscles use 200-300Hz
+} Actuator;
+
+void Actuator_setModeOnce(Actuator* actuator, float intensity, uint64_t duration);
+void Actuator_setModeContinuous(Actuator* actuator, float intensity);
+void Actuator_setModeStop(Actuator* actuator);

+ 81 - 0
SketchAssistant/StaticLib1/Motorheader/ArduinoHub.h

@@ -0,0 +1,81 @@
+/*
+ *  ArduinoHub.h
+ *
+ *  Copyright (C)
+ *  Honda Research Institute Europe GmbH
+ *  Carl-Legien-Str. 30
+ *  63073 Offenbach/Main
+ *  Germany
+ *
+ *  UNPUBLISHED PROPRIETARY MATERIAL.
+ *  ALL RIGHTS RESERVED.
+ *
+ */
+
+#pragma once
+#include <pthread.h>
+#include <stdbool.h>
+#include <stdint.h>
+#include <time.h>
+#include <windows.h>
+#include "Serial.h"
+#include "Actuator.h"
+
+typedef enum
+{
+    ARDUINOHUB_TYPE_PIEZO = 'P',
+    ARDUINOHUB_TYPE_ERM   = 'E',
+    ARDUINOHUB_TYPE_EMS   = 'M'
+} ArduinoHub_Type;
+
+typedef struct ArduinoHub
+{
+    bool valid;
+    pthread_mutex_t mutex;
+    pthread_t thread;
+    ArduinoHub_Type arduinoType;
+    Serial* serial;
+    Actuator* actuators;
+} ArduinoHub;
+
+ArduinoHub* ArduinoHub_new();
+void ArduinoHub_init(ArduinoHub* self, char* port, ArduinoHub_Type type);
+void ArduinoHub_clear(ArduinoHub* self);
+void ArduinoHub_delete(ArduinoHub* self);
+
+
+/**
+ * Starts vibration for a specified duration. The command is non-blocking.
+ * @intensity:
+ *      Intensity covering the whole spectrum of the actuator if no range is set.
+ *      An intensity range can be set with ArduinoHub_setIntensityRange().
+ * @duration:
+ *      Duration of the vibration in milliseconds.
+ */
+void ArduinoHub_vibrate(ArduinoHub* self, uint8_t tactor, float intensity, uint64_t duration);
+
+/**
+ * Starts continuous vibration. The command is non-blocking.
+ * @intensity:
+ *      Intensity covering the whole spectrum of the actuator if no range is set.
+ *      An intensity range can be set with ArduinoActuator_setIntensityRange().
+ */
+void ArduinoHub_startVibration(ArduinoHub* self, uint8_t tactor, float intensity);
+
+/**
+ * Stops continuous vibration.
+ */
+void ArduinoHub_stopVibration(ArduinoHub* self, uint8_t tactor);
+
+/**
+* Sets the frequency of the vibration of all piezo actuators.
+* No effect for ERM and EMS.
+*/
+void ArduinoHub_setFrequency(ArduinoHub* self, uint8_t tactor, uint16_t frequency);
+
+/**
+ * Set the intensity range. The default range is the actuators whole intensity [0, 1].
+ * Modifying this setting cuts-out intensity values under min and above max.
+ * E.g., for the range [0.2, 1.0] the intensity 0.5 maps to a device intensity of 0.6.
+ */
+void ArduinoHub_setIntensityRange(ArduinoHub* self, uint8_t tactor, float minIntensity, float maxIntensity);

+ 70 - 0
SketchAssistant/StaticLib1/Motorheader/EAIHub.h

@@ -0,0 +1,70 @@
+/*
+ *  EAIHub.h
+ *
+ *  Copyright (C)
+ *  Honda Research Institute Europe GmbH
+ *  Carl-Legien-Str. 30
+ *  63073 Offenbach/Main
+ *  Germany
+ *
+ *  UNPUBLISHED PROPRIETARY MATERIAL.
+ *  ALL RIGHTS RESERVED.
+ *
+ */
+
+#pragma once
+#include <stdbool.h>
+#include <stdint.h>
+#include <time.h>
+#include <pthread.h>
+#include "Actuator.h"
+
+typedef struct EAIHub
+{
+    bool valid;
+    pthread_mutex_t mutex;
+    pthread_t thread;
+    Actuator* actuators;
+    uint16_t tactorType;
+    uint16_t modulation; // Default: 250Hz
+    int deviceID;
+} EAIHub;
+
+EAIHub* EAIHub_new();
+void EAIHub_init(EAIHub* self, char* eaiPort);
+void EAIHub_clear(EAIHub* self);
+void EAIHub_delete(EAIHub* self);
+
+/**
+ * Starts vibration for a specified duration. The command is non-blocking.
+ * @intensity:
+ *      Intensity covering the whole spectrum of the actuator if no range is set.
+ *      An intensity range can be set with EAIHub_setIntensityRange().
+ * @duration:
+ *      Duration of the vibration in milliseconds.
+ */
+void EAIHub_vibrate(EAIHub* self, uint8_t tactor, float intensity, uint64_t duration);
+
+/**
+ * Starts continuous vibration. The command is non-blocking.
+ * @intensity:
+ *      Intensity covering the whole spectrum of the actuator if no range is set.
+ *      An intensity range can be set with ArduinoActuator_setIntensityRange().
+ */
+void EAIHub_startVibration(EAIHub* self, uint8_t tactor, float intensity);
+
+/**
+ * Stops continuous vibration.
+ */
+void EAIHub_stopVibration(EAIHub* self, uint8_t tactor);
+
+/**
+* Sets the frequency of the vibration of an actuator.
+*/
+void EAIHub_setFrequency(EAIHub* self, uint8_t tactor, uint16_t frequency);
+/**
+ * Set the intensity range. The default range is the actuators whole intensity [0, 1].
+ * Modifying this setting cuts-out intensity values under min and above max.
+ * E.g., for the range [0.2, 1.0] the intensity 0.5 maps to a device intensity of 0.6.
+ */
+void EAIHub_setIntensityRange(EAIHub* self, uint8_t tactor, float minIntensity, float maxIntensity);

+ 33 - 0
SketchAssistant/StaticLib1/Motorheader/Serial.h

@@ -0,0 +1,33 @@
+/*
+ *  Serial.h
+ *
+ *  Copyright (C)
+ *  Honda Research Institute Europe GmbH
+ *  Carl-Legien-Str. 30
+ *  63073 Offenbach/Main
+ *  Germany
+ *
+ *  UNPUBLISHED PROPRIETARY MATERIAL.
+ *  ALL RIGHTS RESERVED.
+ *
+ */
+
+#pragma once
+#include <stdbool.h>
+#include <stdint.h>
+#include <windows.h>
+
+typedef struct Serial
+{
+    bool valid;
+    char* port;
+    HANDLE hComm;
+    bool serialStatus;
+} Serial;
+
+Serial* Serial_new();
+void Serial_init(Serial* self, char* port);
+void Serial_clear(Serial* self);
+void Serial_delete(Serial* self);
+
+void Serial_sendMessage(Serial* self, unsigned char* message, int size);