-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #25 from wearable-motion-capture/summary_paper
Summary paper
- Loading branch information
Showing
12 changed files
with
232 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
import atexit | ||
import logging | ||
import queue | ||
import signal | ||
import threading | ||
from datetime import datetime | ||
from pathlib import Path | ||
|
||
import wear_mocap_ape.config as config | ||
from wear_mocap_ape.record.watch_only_rec import WatchOnlyRecorder | ||
|
||
from wear_mocap_ape.stream.listener.imu import ImuListener | ||
from wear_mocap_ape.data_types import messaging | ||
|
||
import argparse | ||
|
||
# Instantiate the parser | ||
parser = argparse.ArgumentParser(description='records data from the watch in standalone mode') | ||
# Required arguments | ||
parser.add_argument('ip', type=str, | ||
help=f'put your local IP here. ' | ||
f'The script will listen to watch data on ' | ||
f'PORT {config.PORT_LISTEN_WATCH_IMU_LEFT}') | ||
parser.add_argument('file', type=str, | ||
help=f'recorded data will be written into this file') | ||
args = parser.parse_args() | ||
|
||
logging.basicConfig(level=logging.INFO) | ||
|
||
# listener and publisher run in separate threads. Listener fills the queue, publisher empties it | ||
q = queue.Queue() | ||
|
||
# the listener fills the que with received and parsed smartwatch data | ||
imu_l = ImuListener( | ||
ip=args.ip, | ||
msg_size=messaging.watch_only_imu_msg_len, | ||
port=config.PORT_LISTEN_WATCH_IMU_LEFT # the smartwatch app sends on this PORT | ||
) | ||
imu_w_l = threading.Thread( | ||
target=imu_l.listen, | ||
args=(q,) | ||
) | ||
|
||
watch_rec = WatchOnlyRecorder(file=args.file) | ||
|
||
prev_time = datetime.now() | ||
active = True | ||
file = Path(args.file) | ||
|
||
header = [ | ||
"timestamp", | ||
"sw_dt", | ||
"sw_h", | ||
"sw_m", | ||
"sw_s", | ||
"sw_ns", | ||
"sw_rotvec_w", | ||
"sw_rotvec_x", | ||
"sw_rotvec_y", | ||
"sw_rotvec_z", | ||
"sw_rotvec_conf", | ||
"sw_gyro_x", | ||
"sw_gyro_y", | ||
"sw_gyro_z", | ||
"sw_lvel_x", | ||
"sw_lvel_y", | ||
"sw_lvel_z", | ||
"sw_lacc_x", | ||
"sw_lacc_y", | ||
"sw_lacc_z", | ||
"sw_pres", | ||
"sw_grav_x", | ||
"sw_grav_y", | ||
"sw_grav_z", | ||
"sw_forward_w", | ||
"sw_forward_x", | ||
"sw_forward_y", | ||
"sw_forward_z", | ||
"sw_init_pres" | ||
] | ||
|
||
if not file.parent.exists(): | ||
raise UserWarning(f"Directory does not exist {file.parent}") | ||
|
||
with open(file, 'w') as fd: | ||
fd.write(",".join(header) + "\n") | ||
|
||
|
||
def processing_loop(sensor_q: queue = None): | ||
logging.info(f"[RAW_RECORDER] starting loop") | ||
|
||
# used to estimate delta time and processing speed in Hz | ||
start = datetime.now() | ||
dat = 0 | ||
|
||
# this loops while the socket is listening and/or receiving data | ||
while active: | ||
|
||
# processing speed output | ||
now = datetime.now() | ||
if (now - start).seconds >= 5: | ||
start = now | ||
logging.info(f"[RAW_RECORDER] {dat / 5} Hz") | ||
dat = 0 | ||
|
||
# get the most recent smartwatch data row from the queue | ||
row = sensor_q.get() | ||
while sensor_q.qsize() > 5: | ||
row = sensor_q.get() | ||
|
||
msg = list(row) | ||
with open(file, 'a') as fd: | ||
msg.insert(0, datetime.now()) | ||
msg = [str(x) for x in msg] | ||
fd.write(",".join(msg) + "\n") | ||
dat += 1 | ||
|
||
|
||
recorder = threading.Thread( | ||
target=processing_loop, | ||
args=(q,) | ||
) | ||
|
||
imu_w_l.start() | ||
recorder.start() | ||
|
||
|
||
def terminate_all(*args): | ||
imu_l.terminate() | ||
watch_rec.terminate() | ||
|
||
|
||
# make sure all handler exit on termination | ||
atexit.register(terminate_all) | ||
signal.signal(signal.SIGTERM, terminate_all) | ||
signal.signal(signal.SIGINT, terminate_all) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+4.04 MB
src/wear_mocap_ape/data_deploy/nn/7cb5cdf94ef4c66388c7f15f642005d5e008146a/checkpoint.pt
Binary file not shown.
76 changes: 76 additions & 0 deletions
76
src/wear_mocap_ape/data_deploy/nn/7cb5cdf94ef4c66388c7f15f642005d5e008146a/results.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
{ | ||
"model": "DropoutLSTM", | ||
"hidden_layer_count": 3, | ||
"hidden_layer_size": 128, | ||
"epochs": 200, | ||
"batch_size": 128, | ||
"learning_rate": 0.0015, | ||
"dropout": 0.2, | ||
"sequence_len": 6, | ||
"normalize": true, | ||
"seq_overlap": true, | ||
"create_norm_stats": true, | ||
"early_stopping": 10, | ||
"hash": "7cb5cdf94ef4c66388c7f15f642005d5e008146a", | ||
"y_targets_n": "ORI_CAL_LARM_UARM", | ||
"x_inputs_n": "WATCH_PHONE_CAL", | ||
"y_targets_v": [ | ||
"gt_larm_6drr_cal_1", | ||
"gt_larm_6drr_cal_2", | ||
"gt_larm_6drr_cal_3", | ||
"gt_larm_6drr_cal_4", | ||
"gt_larm_6drr_cal_5", | ||
"gt_larm_6drr_cal_6", | ||
"gt_uarm_6drr_cal_1", | ||
"gt_uarm_6drr_cal_2", | ||
"gt_uarm_6drr_cal_3", | ||
"gt_uarm_6drr_cal_4", | ||
"gt_uarm_6drr_cal_5", | ||
"gt_uarm_6drr_cal_6" | ||
], | ||
"x_inputs_v": [ | ||
"sw_dt", | ||
"sw_gyro_x", | ||
"sw_gyro_y", | ||
"sw_gyro_z", | ||
"sw_lvel_x", | ||
"sw_lvel_y", | ||
"sw_lvel_z", | ||
"sw_lacc_x", | ||
"sw_lacc_y", | ||
"sw_lacc_z", | ||
"sw_grav_x", | ||
"sw_grav_y", | ||
"sw_grav_z", | ||
"sw_6drr_cal_1", | ||
"sw_6drr_cal_2", | ||
"sw_6drr_cal_3", | ||
"sw_6drr_cal_4", | ||
"sw_6drr_cal_5", | ||
"sw_6drr_cal_6", | ||
"sw_pres_cal", | ||
"ph_gyro_x", | ||
"ph_gyro_y", | ||
"ph_gyro_z", | ||
"ph_lvel_x", | ||
"ph_lvel_y", | ||
"ph_lvel_z", | ||
"ph_lacc_x", | ||
"ph_lacc_y", | ||
"ph_lacc_z", | ||
"ph_grav_x", | ||
"ph_grav_y", | ||
"ph_grav_z", | ||
"ph_6drr_cal_1", | ||
"ph_6drr_cal_2", | ||
"ph_6drr_cal_3", | ||
"ph_6drr_cal_4", | ||
"ph_6drr_cal_5", | ||
"ph_6drr_cal_6" | ||
], | ||
"datetime": "2024-02-02 14:17:35", | ||
"Loss/train": 0.09550117918352286, | ||
"Loss/test": 0.21292609498402634, | ||
"Loss/b_train": 0.09740018165459235, | ||
"Loss/b_test": 0.21205891988034561 | ||
} |
Binary file added
BIN
+9.36 MB
src/wear_mocap_ape/data_deploy/nn/7ffa47dfbf2e1a16057e0253a1c2ba01e465d55a/checkpoint.pt
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters