MainActivity.java
Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2011 Google Inc.
00003  * 
00004  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
00005  * use this file except in compliance with the License. You may obtain a copy of
00006  * the License at
00007  * 
00008  * http://www.apache.org/licenses/LICENSE-2.0
00009  * 
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
00012  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
00013  * License for the specific language governing permissions and limitations under
00014  * the License.
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           //requestWindowFeature(Window.FEATURE_NO_TITLE);
00067           //getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
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           /*SubMenu subPreview = menu.addSubMenu("Color settings");
00084       subPreview.add(1,VIEW_MODE_RGBA,0,"RGB Color").setChecked(true);
00085       subPreview.add(1,VIEW_MODE_GRAY,0,"Grayscale");
00086       subPreview.add(1,VIEW_MODE_CANNY,0,"Canny edges");
00087       subPreview.setGroupCheckable(1, true, true);
00088       
00089       SubMenu subCompression = menu.addSubMenu("Compression");
00090 //      subCompression.add(2,IMAGE_TRANSPORT_COMPRESSION_NONE,0,"None");
00091       subCompression.add(2,IMAGE_TRANSPORT_COMPRESSION_PNG,0,"Png");
00092       
00093       SubMenu subCompressionRate = subCompression.addSubMenu(2,IMAGE_TRANSPORT_COMPRESSION_JPEG,0,"Jpeg");
00094       subCompression.setGroupCheckable(2, true, true);
00095       subCompressionRate.setHeaderTitle("Compression quality");
00096       subCompressionRate.getItem().setChecked(true);
00097       subCompressionRate.add(3,50,0,"50");
00098       subCompressionRate.add(3,60,0,"60");
00099       subCompressionRate.add(3,70,0,"70");
00100       subCompressionRate.add(3,80,0,"80").setChecked(true);
00101       subCompressionRate.add(3,90,0,"90");
00102       subCompressionRate.add(3,100,0,"100");
00103       subCompressionRate.setGroupCheckable(3, true, true);*/
00104 
00105       return true;
00106   }
00107 
00108   @Override
00109   public boolean onOptionsItemSelected(MenuItem item)
00110   {      
00111       /*if(item.getGroupId() == 1)
00112       {
00113           viewMode = item.getItemId();
00114           item.setChecked(true);
00115       }
00116       
00117       if(item.getGroupId() == 2)
00118       {
00119           imageCompression = item.getItemId();
00120           item.setChecked(true);
00121       }
00122       
00123       if(item.getGroupId() == 3)
00124       {
00125           imageCompressionQuality = item.getItemId();
00126           item.setChecked(true);
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 }


android_sensors_driver
Author(s): Chad Rockey (chadrockey@gmail.com)
autogenerated on Sun Oct 5 2014 22:10:14