Пример #1
0
    jobject getJavaPose(JNIEnv * env, myo::Pose pose) {
        std::string poseString;
        switch(pose.type()) {
            case myo::Pose::rest:
                poseString = "Rest";
                break;
            case myo::Pose::fist:
                poseString = "Fist";
                break;
            case myo::Pose::waveIn:
                poseString = "WaveIn";
                break;
            case myo::Pose::waveOut:
                poseString = "WaveOut";
                break;
            case myo::Pose::fingersSpread:
                poseString = "FingersSpread";
                break;
            case myo::Pose::doubleTap:
                poseString = "DoubleTap";
                break;
            case myo::Pose::unknown:
            default:
                poseString = "Unknown";
                break;
        };

        jclass poseClass = env->FindClass("net/johnluetke/myojni/jni/Pose");
        jfieldID poseFieldID = env->GetStaticFieldID(poseClass, poseString.c_str(), "Lnet/johnluetke/myojni/jni/Pose;");
        jobject javaPoseObject = env->GetStaticObjectField(poseClass, poseFieldID);

        return javaPoseObject;
    }
Пример #2
0
Pose::Pose(const myo::Pose& pose) {
  switch (pose.type()) {
    case myo::Pose::rest:
      type_ = rest;
      break;
    case myo::Pose::fist:
      type_ = fist;
      break;
    case myo::Pose::waveIn:
      type_ = waveIn;
      break;
    case myo::Pose::waveOut:
      type_ = waveOut;
      break;
    case myo::Pose::fingersSpread:
      type_ = fingersSpread;
      break;
    case myo::Pose::doubleTap:
      type_ = doubleTap;
      break;
    default:
      type_ = unknown;
      break;
  }
}
Пример #3
0
void vrpn_Tracker_ThalmicLabsMyo::onPose(myo::Myo* myo, uint64_t timestamp, myo::Pose pose)
{
	if (myo != _myo)
		return;
	vrpn_gettimeofday(&_timestamp, NULL);
	double dt = vrpn_TimevalDurationSeconds(_timestamp, vrpn_Button::timestamp);
	vrpn_Button::timestamp = _timestamp;
	

	//	std::cout << "Myo switched to pose " << pose.toString() << "." << std::endl;

	buttons[0] = _locked;
	// reset all buttons to 0. Maybe we should only do this if rest is on ?
	for (int i = 1; i < libmyo_num_poses + 1; ++i)
		buttons[i] = 0;
	buttons[pose.type() + 1] = 1;

	vrpn_Button::report_changes();
}
Пример #4
0
void myouse::MyouseListener::onPose(myo::Myo * myo, uint64_t timestamp,
	myo::Pose pose)
{
	std::cout << "Pose: " << pose << std::endl;
	switch (pose.type())
	{
	case myo::Pose::rest:
		unclickLeft();
		unclickRight();
		unclickMiddle();
		isScrolling = false;
		break;
	case myo::Pose::fist:
		clickLeft();
		break;
	case myo::Pose::waveIn:
		clickMiddle();
		break;
	case myo::Pose::waveOut:
		isScrolling = true;
		break;
	case myo::Pose::fingersSpread:
		clickRight();
		break;
	case myo::Pose::thumbToPinky:
		isEnabled = !isEnabled;
		myo->vibrate(myo::Myo::vibrationMedium);
		if (isEnabled)
		{
			std::cout << "Myouse enabled." << std::endl;
			rollOffset = rawRoll;
			pitchOffset = rawPitch;
			yawOffset = rawYaw;
		}
		else
		{
			std::cout << "Myouse disabled." << std::endl;
		}
		break;
	default:
		break;
	}
}
  void print() {
    std::cout << std::string(25, '\n') << std::endl; // act as if the screen is refreshed
    std::cout << '\r'; // clear the current line;
    std::cout << "Welcome to MyoAVG! Myo found and connected!" << std::endl;
    if (onArm) {
      std::string poseString = currentPose.toString();

      std::cout << '[' << (whichArm == myo::armLeft ? "L" : "R") << ']'
		<< '[' << poseString << std::string(14 - poseString.size(), ' ') << ']';

      std::cout << std::endl;
      if (this->avgc->initialized) {
	this->avgc->print_map();
      }
    }
    std::cout << "Your position: " << avgc->c_x << ", " << avgc->c_y << std::endl;
    std::cout << "Your facing: " << avgc->current_facing() << std::endl;
    std::cout << "Your Progress: " << this->game_progress() << std::endl;
    std::cout << std::flush;
  }
 void onPose(myo::Myo* myo, uint64_t timestamp, myo::Pose pose)
 {
     std::cout << "Myo " << identifyMyo(myo) << " switched to pose " << pose.toString() << "." << std::endl;
 }
 // Pose
 void onPose(myo::Myo* myo, uint64_t timestamp, myo::Pose pose)
 {
   this->addEventData(myo, timestamp, "pose", new StringEventData(pose.toString()));
 }