RCDroid - Presentation 3rd

166
-1

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
166
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
0
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide
  • Before server connected with client, you need to define what Service do you want. It has xx services such as Camera, blablabla.
  • This method will wait client to connect server. After it’s connected ServerContainer will release Container object
  • After it’s connected. Now, you need to be create the objects (that have the number of port on microcontroller) of any device and put the device to the container
  • If you want to create your own device, you need to extends BaseDevice for example.You can control device by setting pulseWidth whatever you want and call execute() to activate it. In this example it’s a led light.
  • RCDroid - Presentation 3rd

    1. 1. RCDroidRobot Controller With Android Phone IT 52 - 11
    2. 2. AGENDA• Part 0 : Overview• Part 1 : API• Part 2 : Android application• Part 3 : RCDroid circuit• Part 4 : Show off IT 52-11 2
    3. 3. Part 0 : Overview IT 52-11 3
    4. 4. Command between server to mobile• DEV:65 12 0• DEV:21 200 0• DDS:65 12• REQGPS• SON:1• SOFF:2 IT 52-11 4
    5. 5. Command signal From Mobile to Microcontroller IT 52-11 5
    6. 6. Part 1 : API - How to use• initialize server• Waiting for client• initialize device• control device• receive data from mobile phone IT 52-11 6
    7. 7. initialize server Service Request Server Container Ready IT 52-11 7
    8. 8. Waiting for client ServerContainer Container ClientConnection IT 52-11 8
    9. 9. initialize deviceCreateDeviceObject Register to container Set Default • OPTIONNAL State IT 52-11 9
    10. 10. control deviceJust simply call the method It’s easy, Isn’t It? IT 52-11 10
    11. 11. receive data from mobile phone REGISTER• Sensor Listener Listener • onSensorChange• Battery • registerSensorListe • onLocationChange Listener ner • onGetNewVideoFr• Disconnect • registerLocationList ame Listener ener • batteryChanged• Location Implements • registerVideoListen • onClientDisconnect Listener er ed Waiting for Interface• Video Listener • setBatteryListener • setOnDisconnectLi Event stener IT 52-11 11
    12. 12. Part 2 : Android application IT 52-11 12
    13. 13. Part 3 : RCDroid circuit IT 52-11 13
    14. 14. RCDroidPart 4 : Let’s the Show begin!
    15. 15. RCDroidThe time for question
    16. 16. RCDroidThank you, see you again on d day
    17. 17. RCDroidappendix
    18. 18. initialize serviceServiceRequests sr = new ServiceRequests();sr.addRequest(ServiceRequests.USE_CAMERA);sr.addRequest(ServiceRequests.USE_COMPASS);sr.addRequest(ServiceRequests.USE_SENSOR_TYPE_ACCELEROMETER);sr.addRequest(ServiceRequests.USE_SENSOR_TYPE_MAGNETIC_FIELD);ServerContainer sc = new ServerContainer(8012, sr); IT 52-11 18
    19. 19. Waiting for clientContainer container = sc.getContainer(); IT 52-11 19
    20. 20. initialize deviceServoMotor dv_wheel = new ServoMotor(PIC16F877A.PORTDB0);SpeedControl dv_motor = new SpeedControl(PIC16F877A.PORTDB1);SwitchControl light = new SwitchControl(PIC16F877A.PORTBB0);container.registerDevice(dv_wheel);container.registerDevice(dv_motor);container.registerDevice(light);dv_motor.setDefaultState(sm2.getPulseWidthBySpeed(0));container.addDeviceDefaultState(dv_motor); IT 52-11 20
    21. 21. public class SwitchControl extends BaseDevice { public SwitchControl(int port) { super(port); } public void on(){ pulseWidth = 200; execute(); } public void off(){ pulseWidth = 0; execute(); } public void toggle(){ if(pulseWidth == 200) pulseWidth = 0; else pulseWidth = 200; execute();} } initialize device Cont. IT 52-11 21
    22. 22. control devicedv_wheel.setDegree(0);dv_wheel.setDegree(90);dv_wheel.setDegree(180);dv_motor.setSpeed(0);dv_motor.setSpeed(80);dv_motor.setSpeed(-40);light.on();light.off();light.toggle(); IT 52-11 22
    23. 23. receive data from mobile phone - Sensorcontainer.registerSensorListener(sensorListener);container.sensorOn(ServiceRequests.USE_COMPASS);container.sensorOn(ServiceRequests.USE_SENSOR_TYPE_MAGNETIC_FIELD);container.sensorOn(ServiceRequests.USE_SENSOR_TYPE_ACCELEROMETER);@Overridepublic void onSensorChange(SensorEvent e) { if (e.type == ServiceRequests.USE_COMPASS) { System.out.println(e.values[0]); }} IT 52-11 23
    24. 24. receive data from mobile phone - Locationcontainer.registerLocationListener(locationListener);container.requestLocation();container.requestLastKnownLocation();@Override public void onLocationChange(LocationEvent e) { System.out.println(e.latitude+”:”+e.longitude); } IT 52-11 24
    25. 25. receive data from mobile phone - Cameracontainer.registerVideoListener(videoListener);@Override public void onGetNewVideoFrame(VideoEvent e) { //you can get BufferedImage by use e.image } IT 52-11 25
    26. 26. receive data from mobile phone - Batterycontainer.setBatteryListener(this);@Override public void phoneBatteryChanged(int level) { // percent unit } @Override public void batteryChanged(int level) { // maximum is 0 and minimum is 4. } IT 52-11 26
    27. 27. receive data from mobile phone - Disconnectcontainer.setOnDisconnectListener(DisconnectListener);@Overridepublic void onClientDisconnected() { System.exit(0);} IT 52-11 27
    28. 28. receive data from mobile phone – Capture Audio- Capture microphone on Mobile to Servercontainer.captureAudio();container.stopAudio();- Capture microphone on Server to MobileSpeaker sk = container.getSpeaker();sk.startCapture();sk.stopCapture(); IT 52-11 28

    ×