Millions of people spend 7-8 hours a day sitting in front of their computers. One common trait is apparent among people with improper computer usage: a head-forward posture. Since people usually sit while using a computer, people also tend to slouch and bend their spine into a curve as well [1]. Neck pain caused by improper computer usage can be prevented through mindfulness training without the need for uncomfortable equipment.
This head forward posture has been shown to exert considerable pressure on the human neck. A normal human head weighs around 10 to 12 pounds (4.54 kg). An assessment of stresses found that a 15 degrees head forward posture increased the effective weight on the neck portion of the spine to 27 pounds (12.25 kg). According to one study, work-related neck pain is twice as likely for those sitting with 20 degree neck flexion. I built this app to help remind me when my head is too close to the computer and to improve the overall quality of my coding lifestyle. The current stage consists of an open source Android application developed by the author which provides notifications when the user is too close to the computer.
Step 1: Start the server on the PiInstall Walabot SDK.
We will use the Python library Flask to serve the Walabot target distance, so on your Raspberry Pi
pip install flask --user
git clone https://gist.github.com/justinshenk/aa1e1eb7ceb87fd82f0b655b5ad20c8a posture-server
cd posture-server
python3 server.py
The Python script server.py provides an endpoint to get the distance from the Walabot using a Flask server:
#!/usr/local/env python
import json
import time
from flask import Flask, jsonify, request, Response
app = Flask(__name__)
distance=0
@app.route('/set')
def set():
global distance
distance = request.args.get('distance')
return jsonify(distance)
@app.route('/status')
def status():
return Response(json.dumps({'status':distance}))
if __name__ == '__main__':
app.run(host='0.0.0.0', port=3000)
In another terminal window start sensing target distance with Walabot:
python3 distance.py
The distance to the target/user is accessed via the internal API
wlbt.get_targets()
and the target depth is accessed via zPosCm and updated on the server with a URL variable:
distance = str(targets[0].zPosCm)
r = requests.get("http://localhost:3000/set?distance=" + distance)
Step 2. Start the Android appDownload the Android app.
The app uses GraphView for displaying the data and HTTP long polling to request the status.
// Get distance via JsonObjectRequest
String url ="http://192.168.0.100:3000/status"; // replace with Pi IP address
final JsonObjectRequest jsonObjectRequest = new JsonObjectRequest
(Request.Method.GET, url, null, new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
Double distance = 0.;
try {
distance = response.getDouble("status");
// Update graph
dataset = updateData(dataset, distance);
...
// Update text display
currDistance.setText("Distance: " + String.format("%.2f", distance));
...
// Poll every second
new Timer().scheduleAtFixedRate(new TimerTask() {
@Override
public void run() {
queue.add(jsonObjectRequest);
}
}, 0, 1000);
Source code for the Android app is available at https://github.com/justinshenk/Walabot-PosturePal. Build it yourself or simply install the APK. Open the app.
Step 3: CalibrateThe Android app is used to set a reference posture for comparison and modify the sensitivity of the device.
Notifications are delivered to the Android app when the user is closer than the calibrated distance.
The method of detectionPosture is tracked using Walabot to determine distance. The distance of the head to the monitor is inferred from the distance reported by the sensor. Data is saved and visualized on the Android app.
ConclusionPosture Pal combines the power of the Walabot sensor with the convenience of a Raspberry Pi and Android app to provide computer users with mindfulness training and ultimately better posture.
Reference1 - Tittiranonda, Burastero, & Rempel, 1999
Comments