• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Myo类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.thalmic.myo.Myo的典型用法代码示例。如果您正苦于以下问题:Java Myo类的具体用法?Java Myo怎么用?Java Myo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Myo类属于com.thalmic.myo包,在下文中一共展示了Myo类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: onDemoPressed

import com.thalmic.myo.Myo; //导入依赖的package包/类
public void onDemoPressed(View v)
{
    final Hub hub = Hub.getInstance();
    Thread t1 = new Thread(new Runnable() {
        public void run() {
            if(hub.getConnectedDevices().isEmpty())
            {
                Log.e("Logue_SSJ", "device not found");
            }
            else
            {
                com.thalmic.myo.Myo myo = hub.getConnectedDevices().get(0);
                startVibrate(myo, hub);
            }
        }
    });
    t1.start();
}
 
开发者ID:hcmlab,项目名称:ssj,代码行数:19,代码来源:MainActivity.java


示例2: onOrientationData

import com.thalmic.myo.Myo; //导入依赖的package包/类
@Override
public void onOrientationData(Myo myo, long l, Quaternion quaternion)
{
       orientationW = quaternion.w();
       orientationX = quaternion.x();
       orientationY = quaternion.y();
       orientationZ = quaternion.z();

	float roll = (float) Math.atan2(2.0 * (quaternion.w() * quaternion.x() + quaternion.y() * quaternion.z()), 1.0 - 2.0 * (quaternion.x() * quaternion.x() + quaternion.y() * quaternion.y()));
	float pitch = (float) Math.asin(Math.max(-1.0, Math.min(1.0, 2.0 * (quaternion.w() * quaternion.y() - quaternion.z() * quaternion.x()))));
	float yaw = (float) Math.atan2(2.0 * (quaternion.w() * quaternion.z() + quaternion.x() * quaternion.y()), 1.0 - 2.0 * (quaternion.y() * quaternion.y() + quaternion.z() * quaternion.z()));

	// Convert the floating point angles in radians to a scale from 0 to 18.
	rollW = (int) ((roll + (float) Math.PI) / (Math.PI * 2.0) * 18);
	pitchW = (int) ((pitch + (float) Math.PI / 2.0) / Math.PI * 18);
	yawW = (int) ((yaw + (float) Math.PI) / (Math.PI * 2.0) * 18);
}
 
开发者ID:hcmlab,项目名称:ssj,代码行数:18,代码来源:MyoListener.java


示例3: onOrientationData

import com.thalmic.myo.Myo; //导入依赖的package包/类
@Override
public void onOrientationData(Myo myo, long timestamp, Quaternion rotation) {
    // Calculate Euler angles (roll, pitch, and yaw) from the quaternion.
    double roll = Math.toDegrees(Quaternion.roll(rotation));
    double pitch = Math.toDegrees(Quaternion.pitch(rotation));
    double yaw = Math.toDegrees(Quaternion.yaw(rotation));
    // Adjust roll and pitch for the orientation of the Myo on the arm.
    if (myo.getXDirection() == XDirection.TOWARD_ELBOW) {
        roll *= -1;
        pitch *= -1;
    }

    MyoOrientationDataFrame frame = new MyoOrientationDataFrame(MyoSensor.this, timestamp, roll, pitch, yaw);

    sendNewData(frame);
}
 
开发者ID:gradlman,项目名称:SensorLib,代码行数:17,代码来源:MyoSensor.java


示例4: main

import com.thalmic.myo.Myo; //导入依赖的package包/类
public static void main(String[] args) {
	try {
		Hub hub = new Hub("com.example.emg-data-sample");

		System.out.println("Attempting to find a Myo...");
		Myo myo = hub.waitForMyo(10000);

		if (myo == null) {
			throw new RuntimeException("Unable to find a Myo!");
		}

		System.out.println("Connected to a Myo armband!");
		myo.setStreamEmg(StreamEmgType.STREAM_EMG_ENABLED);
		DeviceListener dataCollector = new EmgDataCollector();
		hub.addListener(dataCollector);

		while (true) {
			hub.run(1000 / 20);
			System.out.println(dataCollector);
		}
	} catch (Exception e) {
		System.err.println("Error: ");
		e.printStackTrace();
		System.exit(1);
	}
}
 
开发者ID:glaudiston,项目名称:project-bianca,代码行数:27,代码来源:EmgDataSample.java


示例5: main

import com.thalmic.myo.Myo; //导入依赖的package包/类
public static void main(String[] args) {
	try {
		Hub hub = new Hub("com.example.hello-myo");

		System.out.println("Attempting to find a Myo...");
		Myo myo = hub.waitForMyo(10000);

		if (myo == null) {
			throw new RuntimeException("Unable to find a Myo!");
		}

		System.out.println("Connected to a Myo armband!");
		DeviceListener dataCollector = new DataCollector();
		hub.addListener(dataCollector);

		while (true) {
			hub.run(1000 / 20);
			System.out.print(dataCollector);
		}
	} catch (Exception e) {
		System.err.println("Error: ");
		e.printStackTrace();
		System.exit(1);
	}
}
 
开发者ID:glaudiston,项目名称:project-bianca,代码行数:26,代码来源:HelloMyo.java


示例6: processData

import com.thalmic.myo.Myo; //导入依赖的package包/类
@Override
public void processData(Myo myo, long timestamp, Vector3 vector, DataType type) {
	super.processData(myo, timestamp, vector, type);
	
	if(type.equals(DataType.GYROSCOPE)) {
		
		if (timestamp - formTimeDiff > TIME_DIFF) {

			//Log.i("BicepCurl", "Gyro x: "+vector.x());
			//Log.i("BicepCurl", "Gyro y: "+vector.y());
			//Log.i("BicepCurl","Gyro z: "+vector.z());
		
			if(started) {
				if (vector.x() > formThreshold) {
					myo.vibrate(VibrationType.SHORT);
					formTimeDiff = timestamp;
					form = false;
				}
			}
		
		}
		
	}

}
 
开发者ID:myofit,项目名称:MyoFit,代码行数:26,代码来源:BicepCurl.java


示例7: onOrientationData

import com.thalmic.myo.Myo; //导入依赖的package包/类
@Override
public void onOrientationData(Myo myo, long timestamp, Quaternion rotation) {
  
  Quaternion normalized = rotation.normalized();

  double roll = Math.atan2(2.0f * (normalized.getW() * normalized.getX() + normalized.getY() * normalized.getZ()),
      1.0f - 2.0f * (normalized.getX() * normalized.getX() + normalized.getY() * normalized.getY()));
  double pitch = Math.asin(2.0f * (normalized.getW() * normalized.getY() - normalized.getZ() * normalized.getX()));
  double yaw = Math.atan2(2.0f * (normalized.getW() * normalized.getZ() + normalized.getX() * normalized.getY()),
      1.0f - 2.0f * (normalized.getY() * normalized.getY() + normalized.getZ() * normalized.getZ()));

  rollW = Math.round((roll + Math.PI) / (Math.PI * 2.0) * scale);
  pitchW = Math.round((pitch + Math.PI / 2.0) / Math.PI * scale);
  yawW = Math.round((yaw + Math.PI) / (Math.PI * 2.0) * scale);

  delta = (myodata.roll - rollW != 0) || (myodata.pitch - pitchW != 0) || (myodata.yaw - yawW != 0);

  if (delta) {
    myodata.roll = rollW;
    myodata.pitch = pitchW;
    myodata.yaw = yawW;

    myodata.timestamp = timestamp;
    invoke("publishMyoData", myodata);
  }
}
 
开发者ID:MyRobotLab,项目名称:myrobotlab,代码行数:27,代码来源:MyoThalmic.java


示例8: onDisconnect

import com.thalmic.myo.Myo; //导入依赖的package包/类
@Override
public void onDisconnect(Myo myo, long l)
{
	Log.i("Disconnected from Myo");

	reset();
}
 
开发者ID:hcmlab,项目名称:ssj,代码行数:8,代码来源:MyoListener.java


示例9: onAccelerometerData

import com.thalmic.myo.Myo; //导入依赖的package包/类
@Override
public void onAccelerometerData(Myo myo, long l, Vector3 vector3)
{
	accelerationX = (float) vector3.x();
	accelerationY = (float) vector3.y();
	accelerationZ = (float) vector3.z();
}
 
开发者ID:hcmlab,项目名称:ssj,代码行数:8,代码来源:MyoListener.java


示例10: vibrate

import com.thalmic.myo.Myo; //导入依赖的package包/类
public void vibrate(Myo myo,
                    int duration1, byte strength1,
                    int duration2, byte strength2,
                    int duration3, byte strength3,
                    int duration4, byte strength4,
                    int duration5, byte strength5,
                    int duration6, byte strength6) {
    byte[] vibrate2Command = createForVibrate2(duration1, strength1, duration2, strength2, duration3, strength3, duration4, strength4, duration5, strength5, duration6, strength6);
    this.writeControlCommand(myo.getMacAddress(), vibrate2Command);
}
 
开发者ID:hcmlab,项目名称:ssj,代码行数:11,代码来源:Vibrate2Command.java


示例11: testChannels

import com.thalmic.myo.Myo; //导入依赖的package包/类
@Test
public void testChannels() throws Exception
{
    //setup
    Pipeline frame = Pipeline.getInstance();
    frame.options.bufferSize.set(10.0f);
    //sensor
    hcm.ssj.myo.Myo sensor = new hcm.ssj.myo.Myo();

    frame.addConsumer(new Logger(), frame.addSensor(sensor, new AccelerationChannel()), 1, 0);
    frame.addConsumer(new Logger(), frame.addSensor(sensor, new DynAccelerationChannel()), 1, 0);
    frame.addConsumer(new Logger(), frame.addSensor(sensor, new EMGChannel()), 1, 0);

    //start framework
    frame.start();

    //run test
    long end = System.currentTimeMillis() + TestHelper.DUR_TEST_NORMAL;
    try
    {
        while (System.currentTimeMillis() < end)
        {
            Thread.sleep(1);
        }
    }
    catch (Exception e)
    {
        e.printStackTrace();
    }

    frame.stop();
    frame.clear();
}
 
开发者ID:hcmlab,项目名称:ssj,代码行数:34,代码来源:MyoTest.java


示例12: onConnect

import com.thalmic.myo.Myo; //导入依赖的package包/类
@Override
public void onConnect(Myo myo, long timestamp) {
    // Set the text color of the text view to cyan when a Myo connects.
    //mTextView.setTextColor(Color.CYAN);
    MyoSensor.this.mDeviceAddress = myo.getMacAddress();
    sendNotification("Connected to " + myo.getMacAddress());
    sendConnected();
}
 
开发者ID:gradlman,项目名称:SensorLib,代码行数:9,代码来源:MyoSensor.java


示例13: onDisconnect

import com.thalmic.myo.Myo; //导入依赖的package包/类
@Override
public void onDisconnect(Myo myo, long timestamp) {
    // Set the text color of the text view to red when a Myo disconnects.
    //mTextView.setTextColor(Color.RED);
    MyoSensor.this.mDeviceAddress = null;
    sendNotification("Disconnected from " + myo.getMacAddress());

    // TODO: Check that!
    // we unregistered the listener in MyoSensor.disconnect(),
    // so we should only receive a callback if there was any failure, not
    // if the user terminated the connection
    sendConnectionLost();
}
 
开发者ID:gradlman,项目名称:SensorLib,代码行数:14,代码来源:MyoSensor.java


示例14: onOrientationData

import com.thalmic.myo.Myo; //导入依赖的package包/类
@Override
public void onOrientationData(Myo myo, long timestamp, Quaternion rotation) {

	Quaternion normalized = rotation.normalized();

	double roll = Math.atan2(2.0f * (normalized.getW() * normalized.getX() + normalized.getY() * normalized.getZ()),
			1.0f - 2.0f * (normalized.getX() * normalized.getX() + normalized.getY() * normalized.getY()));
	double pitch = Math.asin(2.0f * (normalized.getW() * normalized.getY() - normalized.getZ() * normalized.getX()));
	double yaw = Math.atan2(2.0f * (normalized.getW() * normalized.getZ() + normalized.getX() * normalized.getY()),
			1.0f - 2.0f * (normalized.getY() * normalized.getY() + normalized.getZ() * normalized.getZ()));

	rollW = ((roll + Math.PI) / (Math.PI * 2.0) * SCALE);
	pitchW = ((pitch + Math.PI / 2.0) / Math.PI * SCALE);
	yawW = ((yaw + Math.PI) / (Math.PI * 2.0) * SCALE);
}
 
开发者ID:glaudiston,项目名称:project-bianca,代码行数:16,代码来源:MyoThalmic.java


示例15: onPose

import com.thalmic.myo.Myo; //导入依赖的package包/类
@Override
public void onPose(Myo myo, long timestamp, Pose pose) {
	currentPose = pose;
	if (currentPose.getType() == PoseType.FIST) {
		myo.vibrate(VibrationType.VIBRATION_MEDIUM);
	}		
	invoke("publishPose", pose);
}
 
开发者ID:glaudiston,项目名称:project-bianca,代码行数:9,代码来源:MyoThalmic.java


示例16: main

import com.thalmic.myo.Myo; //导入依赖的package包/类
public static void main(String[] args) {
	LoggingFactory.getInstance().configure();
	LoggingFactory.getInstance().setLevel(Level.INFO);

	try {

		MyoThalmic myo = (MyoThalmic) Runtime.start("myo", "MyoThalmic");
		myo.test();

		Hub hub = new Hub("com.example.hello-myo");

		System.out.println("Attempting to find a Myo...");
		log.info("Attempting to find a Myo");

		Myo myodevice = hub.waitForMyo(10000);

		if (myodevice == null) {
			throw new RuntimeException("Unable to find a Myo!");
		}

		System.out.println("Connected to a Myo armband!");
		log.info("Connected to a Myo armband");
		DeviceListener dataCollector = new DataCollector();
		hub.addListener(dataCollector);

		while (true) {
			hub.run(1000 / 20);
			System.out.print(dataCollector);

			Runtime.start("gui", "GUIService");

		}
	} catch (Exception e) {
		Logging.logError(e);
	}
}
 
开发者ID:glaudiston,项目名称:project-bianca,代码行数:37,代码来源:MyoThalmic.java


示例17: onOrientationData

import com.thalmic.myo.Myo; //导入依赖的package包/类
@Override
   public void onOrientationData(Myo myo, long timestamp, Quaternion rotation) {
Quaternion normalized = rotation.normalized();

double roll = Math.atan2(2.0f * (normalized.getW() * normalized.getX() + normalized.getY() * normalized.getZ()), 1.0f - 2.0f * (normalized.getX() * normalized.getX() + normalized.getY() * normalized.getY()));
double pitch = Math.asin(2.0f * (normalized.getW() * normalized.getY() - normalized.getZ() * normalized.getX()));
double yaw = Math.atan2(2.0f * (normalized.getW() * normalized.getZ() + normalized.getX() * normalized.getY()), 1.0f - 2.0f * (normalized.getY() * normalized.getY() + normalized.getZ() * normalized.getZ()));

rollW = ((roll + Math.PI) / (Math.PI * 2.0) * SCALE);
pitchW = ((pitch + Math.PI / 2.0) / Math.PI * SCALE);
yawW = ((yaw + Math.PI) / (Math.PI * 2.0) * SCALE);
   }
 
开发者ID:glaudiston,项目名称:project-bianca,代码行数:13,代码来源:DataCollector.java


示例18: onPose

import com.thalmic.myo.Myo; //导入依赖的package包/类
@Override
   public void onPose(Myo myo, long timestamp, Pose pose) {
currentPose = pose;
if (currentPose.getType() == PoseType.FIST) {
    myo.vibrate(VibrationType.VIBRATION_MEDIUM);
}
   }
 
开发者ID:glaudiston,项目名称:project-bianca,代码行数:8,代码来源:DataCollector.java


示例19: onPair

import com.thalmic.myo.Myo; //导入依赖的package包/类
@Override
public void onPair(Myo myo, long timestamp, FirmwareVersion firmwareVersion) {
	if (emgSamples != null) {
		for (int i = 0; i < emgSamples.length; i++) {
			emgSamples[i] = 0;
		}
	}
}
 
开发者ID:glaudiston,项目名称:project-bianca,代码行数:9,代码来源:EmgDataCollector.java


示例20: processData

import com.thalmic.myo.Myo; //导入依赖的package包/类
@Override
public void processData(Myo myo, long timestamp, Quaternion quaternion, DataType type) {
  //ADD SUPER THING HERE

  if (myo.getXDirection().equals(XDirection.TOWARD_ELBOW))
    direction = -1;

  if(type.equals(DataType.ORIENTATION)) {

    float pitch = (float) Math.toDegrees(Quaternion.pitch(quaternion));
    float roll = (float) Math.toDegrees(Quaternion.roll(quaternion));
    float yaw = (float) Math.toDegrees(Quaternion.yaw(quaternion));

    //Log.i("BicepCurl", "pitch: "+pitch);
    //Log.i("BicepCurl", "roll: "+roll);
    //Log.i("BicepCurl", "yaw: "+yaw);

    if(started) {
      if(down && pitch > minAngle) {
        down = false;
        rep++;
        if (!form)
          form = true;
        // TODO: MAKE OPTION
        // myo.vibrate(VibrationType.SHORT);
      } else if (!down && pitch < downAngle) {
        down = true;
      }
    }
  }
}
 
开发者ID:myofit,项目名称:MyoFit,代码行数:32,代码来源:TricepKickback.java



注:本文中的com.thalmic.myo.Myo类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java TitanVertex类代码示例发布时间:2022-05-23
下一篇:
Java DSAKeyParameters类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap