Clone wiki

LetYourBodyMove / Home / ToolKitAndroidApps

Content

Section 4 - Run the Toolkit

In this section we discuss how you can connect the toolkit with an app. First we give a general overview on how to import the Android sample projects and how you can deploy them on your devices. Finally, we present a set of sample apps that you can use as starting point for your own prototypes.

Android IDE Installation

You need an IDE (Android Studio) to install the apps to your mobile and to change the apps to fit your own use case. In the repository you find .apk files, but mind that they will not work for your Android version or you want to change the module name.

The .apk file for each app is located in "ToolKit/AndroidApps/<AppName>/apk" where <AppName> is the project foler name of the app (for example Wizard-of-OzPrototyping).

If you don't have Android Studio installed, follow the link below (surely you can use any other IDE). With Android Studio you can easily open the projects of the repository.

Install Android Studio

Import and Build

Open Android Studio and load the Wizard-of-OzPrototyping App located in "<your created folder>\ToolKit\AndroidApps\Wizard-of-OzPrototyping".

Android_Studio_Open_Dialog_edited_small.png

After having opened the Android Studio project, it will start to build and you will be able to see the project structure in the project tab.

Android_Studio_Opened_edited.png

The app module contains files for the GUI and files for the communication with the toolkit. In the figure above, the red rect shows the activity class that implements the interaction and lifecycle of the app. The blue rects highlight the class files that implements the communication with the toolkit.

To run the app, click the play button (green rect) in the tool bar after Gradle synchronisation is finished to build.

Activate Debugging

You need to switch on the debugging mode on your mobile to deploy an app with Android Studio. For smartphones or tablets follow the link below that describes how to enable the debug mode:

There are some more hints on how to develop apps on wearables and smartwatches: * Activate the debugging mode for wearables

Android 6.0 and above uses a new permission manger. Therefore you need to enable the permission as described in How to Manage App Permissions on Android 6.0 to use Bluetooth.

However, before connecting to the toolkit you need to switch on the Bluetooth on your mobile (the app do not through any exceptions).

Deploy the App

Connect your mobile to your PC. Then click on play and select your mobile device. The app should be open on your mobile device.

app_study_software_gestures_not_connected_resized.png

When the app is opened, it might not be connected to the EMS module, in which case both buttons are grey, and switches to green when the app is paired, like shown below.

The left button activates channel 1 and the right button activates channel 2 of the toolkit. This means, that the EMS-Signals of the activated channel are directed to the electrodes. With the sliders below the buttons you can adjust the strength of the EMS-signal.

The radio buttons under the sliders send predefined patterns to the EMS-Toolkit or a text command. The first signal form is the standard. It is only "on" if you press the button and "off" if you release the button. The next four buttons apply diffrent patterns (sawtooth, sqarewave, sine and slowly increasing the EMS intensity). For the syntax of the text commands see the following table and read the "Protocol of the Toolkit" paragraph in our paper.

ecp_small.jpg

Test the Toolkit

Test the Bluetooth Connection

  1. Enable Bluetooth on your mobile. Start the Wizard-of-Oz prototyping app, which you transferred to your device in the previous step.

  2. Connect your toolkit to a power source (7-12V Battery) or plug the USB cable in. Wait until the orange LED on the Arduino glows. This shows that the initiliziation is done (should take up to 20 seconds). Now the toolkit is ready to connect.

  3. Tap on settings in the Wizard-of-Oz app on your mobile. Tap on "Current Device". Enter your <your-device-name> that you defined in your Arduino code. Tap on connect. The two buttons should become green and the blue LED on the toolkit should glow.

    app_study_software_gestures_connected_resized.png

  4. Tap on the Buttons, the green and red LED on the Toolkit should glow.

Use the toolkit

Before you go on, make sure that you read the section about the safety issues. In this section we will show you how you can use the toolkit with the Wizard of Oz App.

Now it is time to feel EMS. First try it without the toolkit. Connect the EMS/TENS device with its cable to electrodes. Make sure that the device is powered off. Then place the electrodes on your forearm. For The placement see the pictures below. With the shown placements you can either flex your hand or extend it.

handDown_small.jpg handUp_small.jpg

Again make shure that you read the section about the safety issures. If you did not read the manual of your EMS/TENS device STOP here and read it!

Now you should have placed the electrode on your forearm. The electrodes should be connected with the EMS/TENS device. At this point turn the EMS/TENS device on. You will may have to set some parameters. We use the following values for intensity, pulse width and frequency:

  • intensity: depends on the user. Start with low values. Increase slowly!!!
  • frequency: 80Hz (a frequency lower than 50Hz will result in a shaking of your hand)
  • pulse width: 50µs

EMS_Device_small.jpg

To be safe, start with using the lowest intensity value your EMS device provides. You should feel a prickling. Slowly increase the intensity on your EMS device until you see the wished effect. Stop if it feels uncomfortable. Decrease the intensity on you EMS-device, to a value that is comfortable. If the effect is not the wished one, turn off the EMS device and move the electrodes on the skin to another position. Start again with the lowest intensity on your EMS-device and redo the procedure of slowly increasing the intensity.

After you tested the hardware very carefully and EMS on your body, connect your toolkit to your arm:

Power off your EMS/TENS device and connect it with the toolkit. Use the connectors you built in section 2 or you already had. Place the electrodes on your arm (if you removed the electrodes) and connect them to the toolkit.

If you now press the buttons you schould feel no difference. Mind that the EMS Device is off.

Now turn your EMS/TENS Device on. We use the following values for intensity, pulse width and frequency (same as above):

  • intensity: depends on the user. Start with low values. Increase slowly!!!
  • frequency: 80Hz (a frequency lower than 50Hz will result in a shaking of your hand)
  • pulse width: 50µs

To be safe, start with using the lowest intensity value your EMS device provides. Now press the button for the channel you use and hold it. Slowly increase the intensity on your EMS device until you see the wished effect. Stop if it feels uncomfortable. Decrease the intensity on you EMS-device, to a value which is comfortable. If the effect is not the wished one, turn off the EMS device and move the electrodes on the skin to another position. Start again with the lowest intensity on your EMS-device and redo the procedure of slowly increasing the intensity.

Do not increase the intensity on your EMS/TENS device if you haven't touched the button of the corresponding channel! If you do not hold the button while increasing the intensity you could feel pain when you turn on the toolkit, because the intensity you set is too high.

Note: Always test the current step-by-step before you change something in the app. Always stay in a confortable level!

At last try the system and check the possibilities you have. The Wizard of Oz apps offers you options to decrease the intensity and to use predefined patterns.

Sample Apps

We provide some sample apps to you:

Wizard-of-Oz prototyping

WoZApp_small.jpg

The Wizard-of-Oz prototyping app can connect to one EMS module and activate two channels. Our EMS device can generate two independent signals. Four electrodes are needed to actuate two muscles. The app activates a channel while the user presses a button. The signal intensity may be adjusted with a slider. Different patterns may be chosen: Immediately on, square wave signal with a 1s period, sawtooth signal (linearly increasing intensity, then off and starting again), sine wave signal, and inverse sawtooth signal (linearly decreasing, then on). Finally, there is a text field for sending custom protocol messages. Each time the button is pressed, one custom message is sent.

Connecting Multiple Devices

GestureApp.jpg

Actuating multiple muscles requires additional control modules andEMS devices. This is useful for more complex haptic feedback, like graspingor lifting an object. Each button activates one channel while it is pressed. It is also possible to changethe intensity and use individual messages. The app can be used as a “gesture key-board” using chording.

Myo Remote Control

myoDeve_small.jpg

The remote control app shows how to use data from external sensors such as the Myo 7 to control muscle activation. In this case the mobile device serves as a gateway between the EMS module and the Myo device. This setup enables a remote control for another person: Attaching the EMS pads to one person and having the Myo device worn by a second person. The detected movements of the second person can then be transmitted to the first person and replayed or otherwise mapped.

If you like to use or improve this app you will need the Android Myo SDK from Thalmic Labs. Under the following link you will find the resources you need. You will need to create an account to download the Android Myo SDK.

Download Myo SDK for Android

Getting started with the Myo SDK for Android

Event triggering

SwatchApp-small.jpg

The smartwatch app runs on a Moto 360 and extends that device with force feedback. For specific notifications, such as an alarm, it can actuate a muscle. In this sense the user becomes the output device for notifications. For example, when an alarm is ringing the user starts waving the hand. Different movements or rhythms may be used for different kinds of notifications.

As discussed in "Activate the debugging mode for wearables" fist you need switch on the debugging mode on your smartwatch. Then froward the app over your paired mobile to the smartwatch.

Open a terminal and go the Library/Android/sdk/platform-tools/ path and run there the following commands:

adb forward tcp:4444 localabstract:/adb-hub
adb connect localhost:4444

After that in your mobile int the Android Wear companion should switch the stae to: Host: connected Target: connected

Afterwars deploy the smartwatch app. It usually take a while (up to 40s) until it opens.

Simple On-Off

app_simple_on-off_small.png

The Simple On-Off App can connect to one EMS module and activate two channels. The app activates a channel while the user presses a button. The app has no possibility to regulate the intensity of the EMS signal and only activates or deactivates a channel at 100% intensity.

Implement your own App

Use one of the sample app and consider how we connect to the toolkit module. You can also send the commands to the provided Bluetooth service from every other module.

// The device needs acess to Bluetooth so give it a reference to the Bluetooth service.
EMSModule emsModule = new EMSModule((BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE), "");

//Add an Observer to the device. It will be notified if the connection state of the device change.
emsModule.getBluetoothLEConnector().addObserver(someObserver); 

//EMSX is a placeholder for the BT-Name of your toolkit
emsModule.setDeviceName("EMSX"); 

// The EMS Module will try to connect to the toolkit. You can close the connection by using emsModule.disconnect()
emsModule.connect(); 

//Now you can send commands to the Toolkit. There are two options.

//1. Send commands in Textmode use the sendMessageToBoard(String msg) function.

//This will activate channel 1 with intensity 100% for 1000 ms.
emsModule.sendMessageToBoard("C0I100T1000G"); 

//2.  or use the setIntensityOnChannelForTime(int intensity, int channel, long time) method.

// This will generate the same behaviour as the first method.
emsModule.setIntensityOnChannelForTime(100, 0, 1000);


/*If you like to use one of the predifined patterns, you could use the following functions on emsModule:

Sets a predefined pattern for a channel. Read the part about the Wizard of Oz app. It uses the patterns.

setPattern(int pattern, int channel);

The patterns are:

0 : constant high
1 : saw tooth
2 : square wave
3 : sine wave
4 : slowly increasing
5 : text mode

//returns the current active pattern
getPattern(int channel);

//starts playing the pattern
startCommand(int channel);

//stops playing the pattern
stopCommand(int channel);

*/

If you build an interesting app, share it with the community! Contact us for further details.


Back to Section 3 Back to Home

Updated