简体   繁体   English

Project Tango原始数据(IMU和RGBD)

[英]Project Tango Raw Data (IMU and RGBD)

I'm a beginner in android and with the Tango (I just wanted to say it to prevent possible mistakes) and I'm using the Project Tango Tablet (Yellowstone). 我是Android和Tango的初学者(我只是想说这是为了防止可能的错误),并且我正在使用Project Tango Tablet(Yellowstone)。 I want to do slam with it, that's why I want to get the raw data. 我想对此大满贯,这就是为什么我要获取原始数据。

Currently I know how to get poseData and cloud of point. 目前,我知道如何获取poseData和点云。 I read that it was not possible to get IMU and RGBD. 我读到不可能获得IMU和RGBD。 But instead of RGBD the RGB picture wich is display by some sample could be enought, but I don't know get it. 但是用某些示例显示RGB图片而不是RGBD是足够的,但是我不知道该怎么做。 I think that it will probably works with "onFrameAvailable(int i)" but I don't really know how to get the RGB picture. 我认为它可能会与“ onFrameAvailable(int i)”一起使用,但我真的不知道如何获取RGB图片。

For the IMU data I saw that there is an EVENT_IMU with "onTangoEvent(TangoEvent tangoEvent)". 对于IMU数据,我看到有一个带有“ onTangoEvent(TangoEvent tangoEvent)”的EVENT_IMU。 But it never happens/is never handled when it's supposed to be a high frequency event right ? 但是当它应该是高频事件时,它永远不会发生/永远不会被处理对吗? However I handle the EVENT_FEATURE_TRACKING (= 5) and EVENT_FISHEYE_CAMERA (= 2) so "onTangoEvent(TangoEvent tangoEvent)" works. 但是我处理了EVENT_FEATURE_TRACKING(= 5)和EVENT_FISHEYE_CAMERA(= 2),所以“ onTangoEvent(TangoEvent tangoEvent)”可以工作。 So my questions are the following : 所以我的问题如下:

  1. How can I get the RGB picture ? 如何获得RGB图片? (in matrix, buffer or anything else) (在矩阵,缓冲区或其他任何形式中)
  2. Why the EVENT_IMU is never handled ? 为什么从未处理EVENT_IMU?
  3. Is there a way to get the IMU data or something equivalent ? 有没有办法获取IMU数据或等效数据?

Thanks for your answers 谢谢你的回答

I forgot to say it, but I solved my problem. 我忘了说了,但是我解决了我的问题。 The Tango's API doesn't allow to get the raw data (IMU and RGBD). Tango的API不允许获取原始数据(IMU和RGBD)。 But you can get the RGB with the c api via the TangoImageBuffer. 但是您可以通过TangoImageBuffer使用c API获得RGB。 You will get an MV21 picture. 您将获得MV21图片。 You will be able to convert each pixel in "RGB single pixel" and then convert this pixel in RGBA data. 您将能够将每个像素转换为“ RGB单个像素”,然后将其转换为RGBA数据。

For the IMU, just forget the Tango's API and use the android API. 对于IMU,只需忘记Tango的API并使用android API。 You can get it easily and then transfer it to a server. 您可以轻松获取它,然后将其传输到服务器。 I my case I do this by using ros publisher. 我的情况下,我是通过使用ros Publisher实现的。 Thanks to this I'm able to get something like 500 poses/sec, 35 point cloud/sec and 900 IMU/sec. 多亏了这一点,我才能获得大约500个姿势/秒,35个点云/秒和900个IMU /秒的速度。 If you are interested by using ros you can check this ROS Rviz visualization of Tango Pose data . 如果您对使用ros感兴趣,可以查看此ROS Rviz可视化Tango Pose数据

----- EDIT -------- Here the code from my git (see next question in comment) as I'll delete it : -----编辑--------在这里,我将删除git中的代码(请参阅注释中的下一个问题):

import android.Manifest;
import android.app.Activity;
import android.content.Context;

import android.content.pm.PackageManager;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;

import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;

import android.os.Bundle;
import android.support.v4.app.ActivityCompat;

public class IMU implements SensorEventListener {
    private long timestampAccelerometerSensor, timestampLinearAccelerationSensor, timestampRotationSensor;
    private long timestampGravitySensor, timestampGyroscopeSensor, timestampMagneticFieldSensor;
    private String  tAccelerometerSensor, tLinearAccelerationSensor, tRotationSensor;
    private String tGravitySensor, tGyroscopeSensor, tMagneticFieldSensor, tGPS;

    private long countAccelerometerSensor, countLinearAccelerationSensor, countRotationSensor;
    private long countGravitySensor, countGyroscopeSensor, countMagneticFieldSensor;

    //for GPS
    private LocationManager locationManager;
    private LocationListener locationListener;
    private double longitude, latitude;

    //for IMU
    private SensorManager mSensorManager;
    private Sensor accelerometerSensor;
    private Sensor linearAccelerationSensor;
    private Sensor rotationSensor;
    private Sensor gravitySensor;
    private Sensor gyroscopeSensor;

    private Sensor magneticFieldSensor;

    float accelerationForce[] = new float[3];//Including gravity, Acceleration force along x,y,z axis in m/s²
    float linearAccelerationForce[] = new float[3];//Excluding gravity, Acceleration force along x,y,z axis in m/s²
    float gravity[] = new float[3];//Force of gravity along x,y,z axis in m/s²
    float gyroscope[] = new float[3];//Rate of rotation around x,y,z axis in rad/s
    float rotation[] = new float[4]; //Rotation vector component along the x,y,z axis and Scalar component of the rotation vector
    float magneticField[] = new float[3];//Geomagnetic field strength along x,y,z axis uT


public void create(){
        mSensorManager = (SensorManager) mainActivity.getSystemService(Context.SENSOR_SERVICE);

        locationManager = (LocationManager) mainActivity.getSystemService(Context.LOCATION_SERVICE);
        locationListener = new LocationListener() {
            @Override
            public void onLocationChanged(Location location) {
                //gpsView.setText("Longitude: " + location.getLongitude() + "\nLatitude: " + location.getLatitude());
                //Log.i("GPS","Longitude: " + location.getLongitude() + "\nLatitude: " + location.getLatitude());
                tGPS = TangoJNINative.getCurrentTimeMillisString();
                longitude = location.getLongitude();
                latitude = location.getLatitude();
            }

            @Override
            public void onStatusChanged(String provider, int status, Bundle extras) {

            }

            @Override
            public void onProviderEnabled(String provider) {
                //gpsStatusView.setText("GPS ---> On");
            }

            @Override
            public void onProviderDisabled(String provider) {
                //gpsStatusView.setText("GPS ---> Off");
            }
        };

        if (ActivityCompat.checkSelfPermission(mainActivity, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(mainActivity, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
            // TODO: Consider calling
            //    ActivityCompat#requestPermissions
            // here to request the missing permissions, and then overriding
            //   public void onRequestPermissionsResult(int requestCode, String[] permissions,
            //                                          int[] grantResults)
            // to handle the case where the user grants the permission. See the documentation
            // for ActivityCompat#requestPermissions for more details.
            return;
        }
        locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, locationListener);

        String locationProvider = LocationManager.NETWORK_PROVIDER;
        Location firstLocation = locationManager.getLastKnownLocation(locationProvider);
        longitude = firstLocation.getLongitude();
        latitude = firstLocation.getLatitude();

        setSensors();
        setSensorsListeners();
    }

public void pause(){
        mSensorManager.unregisterListener(this);
    }

    public void resume(){
        setSensorsListeners();
    }

    private void setSensors(){
        accelerometerSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
        linearAccelerationSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_LINEAR_ACCELERATION);
        rotationSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_ROTATION_VECTOR);
        gravitySensor = mSensorManager.getDefaultSensor(Sensor.TYPE_GRAVITY);
        gyroscopeSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_GYROSCOPE);

        magneticFieldSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD);
    }

    private void setSensorsListeners(){
        mSensorManager.registerListener(this, accelerometerSensor , SensorManager.SENSOR_DELAY_NORMAL);
        mSensorManager.registerListener(this, linearAccelerationSensor , SensorManager.SENSOR_DELAY_NORMAL);
        mSensorManager.registerListener(this, rotationSensor , SensorManager.SENSOR_DELAY_NORMAL);
        mSensorManager.registerListener(this, gravitySensor , SensorManager.SENSOR_DELAY_NORMAL);
        mSensorManager.registerListener(this, gyroscopeSensor , SensorManager.SENSOR_DELAY_NORMAL);

        mSensorManager.registerListener(this, magneticFieldSensor , SensorManager.SENSOR_DELAY_NORMAL);
    }

    @Override
    public void onSensorChanged(SensorEvent event) {
        getIMU(event);
    }

    @Override
    public void onAccuracyChanged(Sensor sensor, int accuracy) {

    }

    private void getIMU(SensorEvent e){
        switch(e.sensor.getType()){
            case Sensor.TYPE_ACCELEROMETER:
                accelerationForce[0] = e.values[0];
                accelerationForce[1] = e.values[1];
                accelerationForce[2] = e.values[2];
                countAccelerometerSensor++;
                timestampAccelerometerSensor = e.timestamp;
                tAccelerometerSensor = TangoJNINative.getCurrentTimeMillisString();
                break;
            case Sensor.TYPE_LINEAR_ACCELERATION:
                linearAccelerationForce[0] = e.values[0];
                linearAccelerationForce[1] = e.values[1];
                linearAccelerationForce[2] = e.values[2];
                countLinearAccelerationSensor++;
                timestampLinearAccelerationSensor = e.timestamp;
                tLinearAccelerationSensor = TangoJNINative.getCurrentTimeMillisString();
                break;
            case Sensor.TYPE_ROTATION_VECTOR:
                rotation[0] = e.values[0];
                rotation[1] = e.values[1];
                rotation[2] = e.values[2];
                rotation[3] = e.values[3];
                countRotationSensor++;
                timestampRotationSensor = e.timestamp;
                tRotationSensor = TangoJNINative.getCurrentTimeMillisString();
                break;
            case Sensor.TYPE_GRAVITY:
                gravity[0] = e.values[0];
                gravity[1] = e.values[1];
                gravity[2] = e.values[2];
                countGravitySensor++;
                timestampGravitySensor = e.timestamp;
                tGravitySensor = TangoJNINative.getCurrentTimeMillisString();
                break;
            case Sensor.TYPE_GYROSCOPE:
                gyroscope[0] = e.values[0];
                gyroscope[1] = e.values[1];
                gyroscope[2] = e.values[2];
                countGyroscopeSensor++;
                timestampGyroscopeSensor= e.timestamp;
                tGyroscopeSensor = TangoJNINative.getCurrentTimeMillisString();
                break;
            case Sensor.TYPE_MAGNETIC_FIELD:
                magneticField[0] = e.values[0];
                magneticField[1] = e.values[1];
                magneticField[2] = e.values[2];
                countMagneticFieldSensor++;
                timestampMagneticFieldSensor = e.timestamp;
                tMagneticFieldSensor = TangoJNINative.getCurrentTimeMillisString();
                break;
        }
    }
}

maybe it's too late to ask you. 也许为时已晚。 But is there any chance that you can give me your code to get IMU measurements and RGB-video from Project-Tango. 但是,您是否有可能给我您的代码以从Project-Tango获得IMU测量值和RGB视频。 I'm dealing with this problem now. 我正在处理这个问题。 Tks a lot! Tks很多!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM