Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 package org.ros.android.android_sensors_driver;
00018
00019 import android.content.Context;
00020 import android.hardware.SensorManager;
00021 import android.location.LocationManager;
00022 import android.os.Bundle;
00023 import android.util.Log;
00024 import android.view.Menu;
00025 import android.view.MenuItem;
00026 import android.view.SubMenu;
00027 import android.view.Window;
00028 import android.view.WindowManager;
00029 import org.ros.address.InetAddressFactory;
00030 import org.ros.android.RosActivity;
00031 import org.ros.node.NodeConfiguration;
00032 import org.ros.node.NodeMainExecutor;
00033
00040 public class MainActivity extends RosActivity
00041 {
00042
00043
00044 private NavSatFixPublisher fix_pub;
00045 private ImuPublisher imu_pub;
00046
00047 private LocationManager mLocationManager;
00048 private SensorManager mSensorManager;
00049
00050
00051 public MainActivity()
00052 {
00053 super("Ros Android Sensors Driver", "Ros Android Sensors Driver");
00054 }
00055
00056 @Override
00057 protected void onPause()
00058 {
00059 super.onPause();
00060 }
00061
00062 @Override
00063 protected void onCreate(Bundle savedInstanceState)
00064 {
00065 super.onCreate(savedInstanceState);
00066
00067
00068 setContentView(R.layout.main);
00069
00070 mLocationManager = (LocationManager)this.getSystemService(Context.LOCATION_SERVICE);
00071 mSensorManager = (SensorManager)this.getSystemService(SENSOR_SERVICE);
00072 }
00073
00074 @Override
00075 protected void onResume()
00076 {
00077 super.onResume();
00078 }
00079
00080 @Override
00081 public boolean onCreateOptionsMenu(Menu menu) {
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105 return true;
00106 }
00107
00108 @Override
00109 public boolean onOptionsItemSelected(MenuItem item)
00110 {
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128 return true;
00129 }
00130
00131 @Override
00132 protected void init(NodeMainExecutor nodeMainExecutor)
00133 {
00134 NodeConfiguration nodeConfiguration2 = NodeConfiguration.newPublic(InetAddressFactory.newNonLoopback().getHostAddress());
00135 nodeConfiguration2.setMasterUri(getMasterUri());
00136 nodeConfiguration2.setNodeName("android_sensors_driver_nav_sat_fix");
00137 this.fix_pub = new NavSatFixPublisher(mLocationManager);
00138 nodeMainExecutor.execute(this.fix_pub, nodeConfiguration2);
00139
00140 NodeConfiguration nodeConfiguration3 = NodeConfiguration.newPublic(InetAddressFactory.newNonLoopback().getHostAddress());
00141 nodeConfiguration3.setMasterUri(getMasterUri());
00142 nodeConfiguration3.setNodeName("android_sensors_driver_imu");
00143 this.imu_pub = new ImuPublisher(mSensorManager);
00144 nodeMainExecutor.execute(this.imu_pub, nodeConfiguration3);
00145
00146 }
00147 }