EAIHub.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*
  2. * EAIHub.h
  3. *
  4. * Copyright (C)
  5. * Honda Research Institute Europe GmbH
  6. * Carl-Legien-Str. 30
  7. * 63073 Offenbach/Main
  8. * Germany
  9. *
  10. * UNPUBLISHED PROPRIETARY MATERIAL.
  11. * ALL RIGHTS RESERVED.
  12. *
  13. */
  14. #pragma once
  15. #include <stdbool.h>
  16. #include <stdint.h>
  17. #include <ctime>
  18. #include <pthread.h>
  19. #include "Actuator.h"
  20. typedef struct EAIHub
  21. {
  22. bool valid;
  23. pthread_mutex_t mutex;
  24. pthread_t thread;
  25. Actuator* actuators;
  26. uint16_t tactorType;
  27. uint16_t modulation; // Default: 250Hz
  28. int deviceID;
  29. } EAIHub;
  30. EAIHub* EAIHub_new();
  31. void EAIHub_init(EAIHub* self, char* eaiPort);
  32. void EAIHub_clear(EAIHub* self);
  33. void EAIHub_delete(EAIHub* self);
  34. /**
  35. * Starts vibration for a specified duration. The command is non-blocking.
  36. * @intensity:
  37. * Intensity covering the whole spectrum of the actuator if no range is set.
  38. * An intensity range can be set with EAIHub_setIntensityRange().
  39. * @duration:
  40. * Duration of the vibration in milliseconds.
  41. */
  42. void EAIHub_vibrate(EAIHub* self, uint8_t tactor, float intensity, uint64_t duration);
  43. /**
  44. * Starts continuous vibration. The command is non-blocking.
  45. * @intensity:
  46. * Intensity covering the whole spectrum of the actuator if no range is set.
  47. * An intensity range can be set with ArduinoActuator_setIntensityRange().
  48. */
  49. void EAIHub_startVibration(EAIHub* self, uint8_t tactor, float intensity);
  50. /**
  51. * Stops continuous vibration.
  52. */
  53. void EAIHub_stopVibration(EAIHub* self, uint8_t tactor);
  54. /**
  55. * Sets the frequency of the vibration of an actuator.
  56. */
  57. void EAIHub_setFrequency(EAIHub* self, uint8_t tactor, uint16_t frequency);
  58. /**
  59. * Set the intensity range. The default range is the actuators whole intensity [0, 1].
  60. * Modifying this setting cuts-out intensity values under min and above max.
  61. * E.g., for the range [0.2, 1.0] the intensity 0.5 maps to a device intensity of 0.6.
  62. */
  63. void EAIHub_setIntensityRange(EAIHub* self, uint8_t tactor, float minIntensity, float maxIntensity);