로봇을 조종하자 3/4 UNIT 17 로봇 SW 콘텐츠 교육원 조용수. 학습 목표 스마트 폰의 센서를 사용할 수 있다. 2.

Slides:



Advertisements
Similar presentations
Sensors.  Hardware devices that take measurements of the physical environment  Some examples  3-axis Accelerometer  3-axis Magnetic field sensor 
Advertisements

@2011 Mihail L. Sichitiu1 Android Introduction Hello World.
Chien-Chung Shen Manifest and Activity Chien-Chung Shen
Getting Started with Android APIs Ivan Wong. Motivation - “Datasheet” - Recently exposed to what’s available in Android - So let’s see what API’s are.
Mobile Application Development Selected Topics – CPIT 490
Android Tutorial Team 3 Jerry Yu Mayank Mandava Mu Du Will Wangles.
로봇 모니터링 2/2 UNIT 21 로봇 SW 콘텐츠 교육원 조용수. 학습 목표 Broadcasting Service 2.
Social Media Apps Programming Min-Yuh Day, Ph.D. Assistant Professor Department of Information Management Tamkang University
로봇 전화번호부 4/4 UNIT 12 로봇 SW 콘텐츠 교육원 조용수. 학습 목표 뷰 홀더 패턴을 사용할 수 있다. 토스트를 사용할 수 있다. 클릭 이벤트를 처리할 수 있다. 2.
2012 내장형 시스템 설계  Full Color LED 디바이스 구성  Full Color LED 디바이스 드라이버  Full Color LED JNI 라이브러리 작성  Full Color LED 안드로이드 App 구현  JNI 라이브러리.
1/29/ Android Programming: FrameLayout By Dr. Ramji M. Makwana Professor and Head, Computer Engineering Department A.D. Patel.
Android Programming-Activity Lecture 4. Activity Inside java folder Public class MainActivity extends ActionBarActivity(Ctrl + Click will give you the.
Android - Broadcast Receivers
로봇 모션 편집기 4/4 UNIT 25 로봇 SW 콘텐츠 교육원 조용수. 학습 목표 에디트 텍스트를 사용할 수 있다. 아이템을 삭제할 수 있다. 아이템을 편집할 수 있다. 2.
로봇 모니터링 1/2 UNIT 20 로봇 SW 콘텐츠 교육원 조용수. 학습 목표 Message Queue Handler 2.
Activity 생명주기 UNIT 13 로봇 SW 콘텐츠 교육원 조용수. 학습 목표 Logcat 액티비티 생명주기를 설명할 수 있다. 현재 상태를 저장할 수 있다. 2.
Custom Widget 1 UNIT 26 로봇 SW 콘텐츠 교육원 조용수. 캔버스 public void drawColor(int color) 2 public class ControllerView extends View { public ControllerView(Context.
1 Introducing Activity and Intent. 2 Memory LinearLayout, weight=2 LinearLayout, weight=1 TextView ListView.
데이터 저장 & Fragment UNIT 28 로봇 SW 콘텐츠 교육원 조용수. 데이터 저장 & Fragment SharedPreference 로 데이터 저장 Fragment 의 이해 2.
Mobile Device Development Camera and Sensors Dr.YingLiang Ma.
Android Boot Camp Demo Application – Part 1. Development Environment Set Up Download and install Java Development Kit (JDK) Download and unzip Android.
로봇을 조종하자 4/4 UNIT 18 로봇 SW 콘텐츠 교육원 조용수. 학습 목표 Intent Activity 호출 2.
목차 한국기술교육대학교 강사: 김 영 준 ㈜헬로앱스 1일차 아두이노 제어 실습
로봇을 조종하자 1/5 UNIT 14 로봇 SW 콘텐츠 교육원 조용수. 학습 목표 터치 이벤트를 처리할 수 있다. 2.
Custom Widget 2 UNIT 27 로봇 SW 콘텐츠 교육원 조용수. 학습 목표 Custom Widget –Canvas 를 이용하여 Custom Widget 을 만든다. 2.
Android Alert Dialog. Alert Dialog Place Button to open the dialog. public class MainActivity extends ActionBarActivity { private static Button button_sbm;
Lecture 4: Sensors Topics: Motion, Position, and Environmental Sensors Date: Feb 11, 2016.
Google map v2.
CMPE419 Mobile Application Development Asst.Prof.Dr.Ahmet Ünveren SPRING Computer Engineering Department Asst.Prof.Dr.Ahmet Ünveren
CMPE419 Mobile Application Development Asst.Prof.Dr.Ahmet Ünveren SPRING Computer Engineering Department Asst.Prof.Dr.Ahmet Ünveren
Sensors in Android.
Lecture 4: Sensors Topics: Motion, Position, and Environmental Sensors
Lab7 – Appendix.
Introduction to android
Lecture 3 Zablon Ochomo Android Layouts Lecture 3 Zablon Ochomo
Android Introduction Hello World
UNIT 11 로봇 전화번호부 3/4 로봇 SW 콘텐츠 교육원 조용수.
CS240: Advanced Programming Concepts
GUI Programming Fundamentals
滑動版面 建國科技大學 資管系 饒瑞佶 2013/7 V1.
Android Notifications
Lecture 4: Sensors Topics: Motion, Position, and Environmental Sensors.
Android Widgets 1 7 August 2018
Broadcast Receivers A Android Component where you can register for system or application events, receive and react to broadcast intent. Each broadcast.
CS499 – Mobile Application Development
Android Introduction Camera.
Picasso Revisted.
CIS 470 Mobile App Development
CIS 470 Mobile App Development
CIS 470 Mobile App Development
Many thanks to Jun Bum Lim for his help with this tutorial.
CMPE419 Mobile Application Development
UNIT 08 그림책 만들기 2/2 로봇 SW 콘텐츠 교육원 조용수.
HNDIT2417 Mobile Application Development
滑動 建國科技大學 資管系 饒瑞佶.
Lecture 4: Sensors Topics: Motion, Position, and Environmental Sensors.
CIS 470 Mobile App Development
CIS 493/EEC 492 Android Sensor Programming
CIS 470 Mobile App Development
Mobile Programming Sensors in Android.
Mobile Programming Gestures in Android.
Adding Components to Activity
BLP 4216 MOBİL UYGULAMA GELİŞTİRME-2
CMPE419 Mobile Application Development
CMPE419 Mobile Application Development
CIS 470 Mobile App Development
Mobile Programming Broadcast Receivers.
Android Sensor Programming
CIS 694/EEC 693 Android Sensor Programming
CIS 694/EEC 693 Android Sensor Programming
Presentation transcript:

로봇을 조종하자 3/4 UNIT 17 로봇 SW 콘텐츠 교육원 조용수

학습 목표 스마트 폰의 센서를 사용할 수 있다. 2

가속도 센서 좌표축 3 x z y x z y

가속도 센서 4 <RelativeLayout xmlns:android=" android:layout_width="match_parent" android:layout_height="match_parent"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" />

가속도 센서 5 public class MainActivity extends Activity implements SensorEventListener { private TextView textView; private SensorManager protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); textView = (TextView)findViewById(R.id.text); sensorManager = (SensorManager)getSystemService(Context.SENSOR_SERVICE); Sensor accelerometer = sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER); sensorManager.registerListener(this, accelerometer, SensorManager.SENSOR_DELAY_FASTEST); protected void onDestroy() { super.onDestroy(); sensorManager.unregisterListener(this); }

가속도 센서 public void onSensorChanged(SensorEvent event) { switch(event.sensor.getType()) { case Sensor.TYPE_ACCELEROMETER: textView.setText(event.values[0] + ", " + event.values[1] + ", " + event.values[2]); break; public void onAccuracyChanged(Sensor sensor, int accuracy) { }

가속도 센서 7 public class MainActivity extends RobotActivity implements SensorEventListener { private TextView textView; private SensorManager sensorManager; private float[] accelerometer = new float[3]; private boolean touchDown; private Device leftWheelDevice; private Device protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); textView = (TextView)findViewById(R.id.text); sensorManager = (SensorManager)getSystemService(Context.SENSOR_SERVICE); Sensor accelerometer = sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER); sensorManager.registerListener(this, accelerometer, SensorManager.SENSOR_DELAY_FASTEST); protected void onDestroy() { super.onDestroy(); sensorManager.unregisterListener(this); }

가속도 센서 public void onInitialized(Robot robot) { super.onInitialized(robot); leftWheelDevice = robot.findDeviceById(Albert.EFFECTOR_LEFT_WHEEL); rightWheelDevice = robot.findDeviceById(Albert.EFFECTOR_RIGHT_WHEEL); public boolean onTouchEvent(MotionEvent event) { switch(event.getAction()) { case MotionEvent.ACTION_DOWN: touchDown = true; break; case MotionEvent.ACTION_UP: touchDown = false; break; } return super.onTouchEvent(event); }

가속도 센서 public void onSensorChanged(SensorEvent event) { switch(event.sensor.getType()) { case Sensor.TYPE_ACCELEROMETER: accelerometer[0] = event.values[0]; accelerometer[1] = event.values[1]; accelerometer[2] = event.values[2]; textView.setText(event.values[0] + ", " + event.values[1] + ", " + event.values[2]); break; public void onAccuracyChanged(Sensor sensor, int accuracy) { }

가속도 센서 public void onExecute() { if(touchDown == false) { leftWheelDevice.write(0); rightWheelDevice.write(0); return; } int h = (int)(accelerometer[1] * 24); if(h > 100) h = 100; else if(h < -100) h = -100; int v = (int)(accelerometer[0] * 24) - 127; if(v > 100) v = 100; else if(v < -100) v = -100; int leftWheel = -v / 2 + h / 2; int rightWheel = -v / 2 - h / 2; leftWheelDevice.write(leftWheel); rightWheelDevice.write(rightWheel); }

가속도 센서 11 <manifest xmlns:android=" package="com.example.unit14" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="17" /> <application android:allowBackup="true" > <activity android:name="com.example.unit14.MainActivity" android:screenOrientation="landscape" >

진동 12 public class MainActivity extends RobotActivity implements SensorEventListener { private TextView textView; private SensorManager sensorManager; private float[] accelerometer = new float[3]; private boolean touchDown; private Device leftWheelDevice; private Device rightWheelDevice; private Device leftProximityDevice; private Device rightProximityDevice; private Vibrator protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); textView = (TextView)findViewById(R.id.text); sensorManager = (SensorManager)getSystemService(Context.SENSOR_SERVICE); Sensor accelerometer = sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER); sensorManager.registerListener(this, accelerometer, SensorManager.SENSOR_DELAY_FASTEST); vibrator = (Vibrator)getSystemService(Context.VIBRATOR_SERVICE); }

진동 public void onInitialized(Robot robot) { super.onInitialized(robot); leftWheelDevice = robot.findDeviceById(Albert.EFFECTOR_LEFT_WHEEL); rightWheelDevice = robot.findDeviceById(Albert.EFFECTOR_RIGHT_WHEEL); leftProximityDevice = robot.findDeviceById(Albert.SENSOR_LEFT_PROXIMITY); rightProximityDevice = robot.findDeviceById(Albert.SENSOR_RIGHT_PROXIMITY); }

진동 public void onExecute() { if(touchDown == false) { leftWheelDevice.write(0); rightWheelDevice.write(0); return; } int h = (int)(accelerometer[1] * 24); if(h > 100) h = 100; else if(h < -100) h = -100; int v = (int)(accelerometer[0] * 24) - 127; if(v > 100) v = 100; else if(v < -100) v = -100; int leftWheel = -v / 2 + h / 2; int rightWheel = -v / 2 - h / 2; leftWheelDevice.write(leftWheel); rightWheelDevice.write(rightWheel); if(leftProximityDevice.read() > 50 || rightProximityDevice.read() > 50) vibrator.vibrate(50); }

진동 15 <manifest xmlns:android=" package="com.example.unit14" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="17" /> <application android:allowBackup="true" > <activity android:name="com.example.unit14.MainActivity" android:screenOrientation="landscape" >