Skip to content

Commit 95654f4

Browse files
committed
improved logging and stuff
1 parent 30c8953 commit 95654f4

File tree

7 files changed

+55
-21
lines changed

7 files changed

+55
-21
lines changed

proj/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import pyinspect
22

3-
pyinspect.install_traceback()
3+
pyinspect.install_traceback(all_locals=False)
44

55
# Set up logging
6-
from proj.utils.logging import log, rich_to_txt
6+
from proj.utils.logging import log
77

88
# import stuff
99
from proj.model.config import Config

proj/environment/trajectories.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from sklearn.metrics import mean_squared_error
55
from rich.table import Table
66
import logging
7+
from rich import print
78

89
from fcutils.maths.geometry import (
910
calc_angle_between_points_of_vector_2d,
@@ -14,7 +15,7 @@
1415
from fcutils.maths.filtering import line_smoother
1516

1617
from proj.utils.misc import interpolate_nans
17-
from proj import log, rich_to_txt
18+
from proj import log
1819

1920

2021
def complete_given_xy(x, y, params, planning_params):
@@ -82,7 +83,21 @@ def compute_trajectory_stats(
8283
)
8384

8485
# log stuff
85-
logging.info(rich_to_txt(table), extra={"markup": True})
86+
logging.info(
87+
f"""
88+
Trajectory metadata
89+
90+
91+
n_points = {n_points}
92+
distance_travelled = {round(distance_travelled, 2)}
93+
waypoint_density = {round(waypoint_density, 2)}
94+
start_goal_distance = {round(start_goal_distance, 2)}
95+
duration = {round(duration, 2)}
96+
lookahead = {lookahead}
97+
perc_lookahead = {perc_lookahead}
98+
"""
99+
)
100+
print(table)
86101

87102
if waypoint_density < 2 or waypoint_density > 3:
88103
log.info(

proj/model/config.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
STATE_SIZE=5,
66
INPUT_SIZE=2,
77
ANGLE_IDX=2, # state vector index which is angle, used to fit diff in
8-
R=np.diag([1.0e-06, 1.0e-06]), # control cost
9-
Q=np.diag([10, 10, 10, 3, 0]), # state cost | x, y, theta, v, omega
8+
R=np.diag([1.0e-04, 1.0e-04]), # control cost
9+
Q=np.diag([30, 30, 30, 3, 0]), # state cost | x, y, theta, v, omega
1010
Sf=np.diag([0, 0, 0, 0, 0]), # final state cost
1111
)
1212

@@ -70,7 +70,7 @@ class Config:
7070
min_speed=80,
7171
min_dist=0, # if agent is within this distance from trajectory end the goal is considered achieved
7272
# ? for trajectories from data
73-
px_to_cm=1 / 30.8, # convert px values to cm
73+
px_to_cm=1 / 8, # convert px values to cm
7474
# dist_th=60, # keep frames only after moved away from start location
7575
dist_th=-1,
7676
resample=True, # if True when using tracking trajectory resamples it
@@ -116,6 +116,11 @@ def __init__(self,):
116116
self.Q = params["Q"]
117117
self.Sf = params["Sf"]
118118

119+
# Adjust mouse length for plotting
120+
self.mouse["length"] = (
121+
self.mouse["length"] * self.trajectory["px_to_cm"]
122+
)
123+
119124
def config_dict(self):
120125
return dict(
121126
dt=self.dt,

proj/paths.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
from pathlib import Path
33

44
if sys.platform == "darwin":
5-
# trials_cache = "/Users/federicoclaudi/Dropbox (UCL - SWC)/Rotation_vte/Locomotion/control/behav_data/m46_cache.h5"
6-
trials_cache = "/Users/federicoclaudi/Dropbox (UCL - SWC)/Rotation_vte/Locomotion/control/behav_data/zanes.h5"
5+
trials_cache = "/Users/federicoclaudi/Dropbox (UCL - SWC)/Rotation_vte/Locomotion/control/behav_data/m46_cache.h5"
6+
# trials_cache = "/Users/federicoclaudi/Dropbox (UCL - SWC)/Rotation_vte/Locomotion/control/behav_data/zanes.h5"
77

88
main_fld = Path(
99
"/Users/federicoclaudi/Dropbox (UCL - SWC)/Rotation_vte/Locomotion/control"
@@ -14,8 +14,8 @@
1414

1515
db_app = "/Users/federicoclaudi/Dropbox (UCL - SWC)/Apps/loco_upload"
1616
else:
17-
# trials_cache = "D:\\Dropbox (UCL - SWC)\\Rotation_vte\\Locomotion\\control\\behav_data\\m46_cache.h5"
18-
trials_cache = "D:\\Dropbox (UCL - SWC)\\Rotation_vte\\Locomotion\\control\\behav_data\\zanes.h5"
17+
trials_cache = "D:\\Dropbox (UCL - SWC)\\Rotation_vte\\Locomotion\\control\\behav_data\\m46_cache.h5"
18+
# trials_cache = "D:\\Dropbox (UCL - SWC)\\Rotation_vte\\Locomotion\\control\\behav_data\\zanes.h5"
1919

2020
main_fld = Path(
2121
"D:\\Dropbox (UCL - SWC)\\Rotation_vte\\Locomotion\\control"
@@ -28,12 +28,12 @@
2828

2929
# winstor paths
3030
winstor_main = Path("/nfs/winstor/branco/Federico/Locomotion/control/data")
31-
# winstor_trial_cache = (
32-
# "/nfs/winstor/branco/Federico/Locomotion/control/m46_cache.h5"
33-
# )
34-
3531
winstor_trial_cache = (
36-
"/nfs/winstor/branco/Federico/Locomotion/control/zanes.h5"
32+
"/nfs/winstor/branco/Federico/Locomotion/control/m46_cache.h5"
3733
)
3834

35+
# winstor_trial_cache = (
36+
# "/nfs/winstor/branco/Federico/Locomotion/control/zanes.h5"
37+
# )
38+
3939
winstor_db_app = ""

proj/utils/logging.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,6 @@
2020
logging_console = Console(record=True)
2121

2222

23-
def rich_to_txt(obj):
24-
logging_console.print(obj)
25-
return logging_console.export_text()
26-
27-
2823
# Disable logging some packages
2924
for module in [
3025
"matplotlib",

run_allocentric.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
# %%
2+
3+
import pyinspect
4+
5+
pyinspect.install_traceback(all_locals=False)
6+
7+
28
from proj import (
39
Model,
410
Environment,

workspace.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
from proj import Model
2+
from rich import print
3+
from sympy import latex
4+
from pylatexenc.latex2text import LatexNodes2Text
5+
6+
model = Model()
7+
model.get_combined_dynamics_kinematics()
8+
9+
g, inp, M = model.matrixes["g"], model.matrixes["inp"], model.matrixes["M"]
10+
11+
mod = g + M * inp
12+
13+
print(LatexNodes2Text().latex_to_text((latex(inp))))

0 commit comments

Comments
 (0)