<commit_before>/* Provides an easy interface for determining the basic orientation of the
 * user's arm and wrist.
 */

#ifndef MYO_INTELLIGESTURE_ORIENTATION_H_
#define MYO_INTELLIGESTURE_ORIENTATION_H_

#include <myo/myo.hpp>

#include "DeviceListenerWrapper.h"
#include "OrientationUtility.h"

class Orientation : public DeviceListenerWrapper {
 public:
  enum class Arm { unknown, forearmLevel, forearmDown, forearmUp };
  enum class Wrist { unknown, palmSideways, palmDown, palmUp };

  Orientation(DeviceListenerWrapper& parent_feature);

  virtual void onOrientationData(myo::Myo* myo, uint64_t timestamp,
                                 const myo::Quaternion<float>& rotation) {
    rotation_ = rotation;
    DeviceListenerWrapper::onOrientationData(myo, timestamp, rotation);
  }

  // Calibrate sets the "start" position to use as a reference in order to
  // determine the orientation of the user's arm. Currently this start position
  // is the user's arm fully extended directly in front.
  void calibrateOrientation() { mid_ = rotation_; }

  float getRelativeArmAngle() const;
  float getRelativeWristAngle() const;
  Arm getArmOrientation() const;
  Wrist getWristOrientation() const;

 private:
  myo::Quaternion<float> rotation_, mid_;
};

Orientation::Orientation(DeviceListenerWrapper& parent_feature)
    : rotation_(), mid_() {
  parent_feature.addChildFeature(this);
}

float Orientation::getRelativeArmAngle() const {
  return OrientationUtility::RelativeOrientation(
      mid_, rotation_, OrientationUtility::QuaternionToPitch);
}

// TODO: add a multiplier because your forearm only rotates a fraction of the
// angle your wrist rotates.
float Orientation::getRelativeWristAngle() const {<commit_msg>Uninline onOrientationData<commit_after>/* Provides an easy interface for determining the basic orientation of the
 * user's arm and wrist.
 */

#ifndef MYO_INTELLIGESTURE_ORIENTATION_H_
#define MYO_INTELLIGESTURE_ORIENTATION_H_

#include <myo/myo.hpp>

#include "DeviceListenerWrapper.h"
#include "OrientationUtility.h"

class Orientation : public DeviceListenerWrapper {
 public:
  enum class Arm { unknown, forearmLevel, forearmDown, forearmUp };
  enum class Wrist { unknown, palmSideways, palmDown, palmUp };

  Orientation(DeviceListenerWrapper& parent_feature);

  virtual void onOrientationData(
      myo::Myo* myo, uint64_t timestamp,
      const myo::Quaternion<float>& rotation) override;

  // Calibrate sets the "start" position to use as a reference in order to
  // determine the orientation of the user's arm. Currently this start position
  // is the user's arm fully extended directly in front.
  void calibrateOrientation() { mid_ = rotation_; }

  float getRelativeArmAngle() const;
  float getRelativeWristAngle() const;
  Arm getArmOrientation() const;
  Wrist getWristOrientation() const;

 private:
  myo::Quaternion<float> rotation_, mid_;
};

Orientation::Orientation(DeviceListenerWrapper& parent_feature)
    : rotation_(), mid_() {
  parent_feature.addChildFeature(this);
}

void Orientation::onOrientationData(myo::Myo* myo, uint64_t timestamp,
                                    const myo::Quaternion<float>& rotation) {
  rotation_ = rotation;
  DeviceListenerWrapper::onOrientationData(myo, timestamp, rotation);
}

float Orientation::getRelativeArmAngle() const {
  return OrientationUtility::RelativeOrientation(
      mid_, rotation_, OrientationUtility::QuaternionToPitch);
}

// TODO: add a multiplier because your forearm only rotates a fraction of the
// angle your wrist rotates.
float Orientation::getRelativeWristAngle() const {
{'fraction_non_alphanumeric': 0.08692029991668981, 'fraction_numerical': 0.0016662038322688142, 'mean_word_length': 4.9438943894389435, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3663007', 'n_tokens_mistral': 1060, 'n_tokens_neox': 998, 'n_words': 305}