Skip to content

Commit 392b15e

Browse files
committed
starting cleanup
1 parent 6f43b32 commit 392b15e

File tree

10 files changed

+7
-56
lines changed

10 files changed

+7
-56
lines changed
-1 KB
Binary file not shown.

data_handler.py

+2-38
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
import numpy as np
22
import cv2
3-
from datetime import datetime
4-
import pickle as pkl
53
import pathlib
64

7-
from pytest import param
85
import os
96
import esim_torch as esim_torch
10-
import glob
117
import torch
128

139

@@ -54,6 +50,7 @@ def visualize_data(shared_data):
5450
neg_th = None
5551
pos_th = None
5652
dir_name="spikes_output"
53+
title = "Sim2E Visualizer"
5754
while True:
5855
width = shared_data[0]
5956
height = shared_data[1]
@@ -123,15 +120,10 @@ def visualize_data(shared_data):
123120
recording = False
124121

125122
frame_counter += 1
126-
127-
128-
129-
cv2.imshow("", all_frames)
123+
cv2.imshow(title, all_frames)
130124
if cv2.waitKey(1) == 27:
131125
break
132126

133-
134-
135127
cv2.destroyAllWindows()
136128

137129
def render(x, y, t, p, shape):
@@ -170,31 +162,3 @@ def get_depth_frame(width, height, frame, stereo):
170162
frame = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
171163
frame = cv2.flip(frame, 0)
172164
return frame
173-
174-
def get_spike_frame(frame, prev_frame, pos_th, neg_th):
175-
pos_th/=1000
176-
neg_th/=1000
177-
178-
src_shape = (frame.shape[0], frame.shape[1], 3)
179-
colored_frame = None
180-
if prev_frame is not None:
181-
spikes_frame = getSpikesFrom2Frames(prev_frame, frame, pos_th, neg_th).flatten()
182-
shape = [int(x) for x in spikes_frame.shape]
183-
colored_frame = np.zeros(shape=shape+[3], dtype="uint8")
184-
colored_frame[spikes_frame==-1] = [255, 0, 0]
185-
colored_frame[spikes_frame==1] = [0, 0, 255]
186-
colored_frame = colored_frame.reshape(src_shape)
187-
188-
return frame, colored_frame
189-
190-
def getSpikesFrom2Frames(prev_frame, frame, pos_th, neg_th):
191-
192-
frame = np.array(np.log(frame), dtype=np.float16)
193-
prev_frame = np.array(np.log(prev_frame), dtype=np.float16)
194-
deltas = np.array(frame-prev_frame, dtype=np.float16)
195-
deltas = np.where(deltas >= pos_th, 1, deltas)
196-
deltas = np.where(deltas <= -neg_th, -1, deltas)
197-
deltas = np.where(deltas > 1, 0, deltas)
198-
deltas = np.where(deltas < -1 , 0, deltas)
199-
200-
return deltas

main.py

+1-9
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,6 @@
11
import asyncio
2-
from cgitb import handler
3-
from collections import defaultdict
4-
from datetime import date
5-
from email.policy import default
6-
import enum
72
import logging
8-
from re import S
9-
import time
10-
from turtle import update
11-
from typing import AsyncIterable, Iterable
3+
from typing import AsyncIterable
124

135
import grpc
146
import UnityStreamer_pb2

project/simulation/__pycache__/mjremote.cpython-39.pyc

100755100644
-25 Bytes
Binary file not shown.

project/simulation/mjremote.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import re
1+
22
import socket
33
import struct
44

project/simulation/scene.py

-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414
import mujoco_py as mjc
1515
import os
1616
import numpy as np
17-
import glfw
18-
import cv2
1917
from .utilities import *
2018

2119
class Mujocoation:

project/simulation/state_machine.py

+2-5
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,12 @@
1010
Each state is a dictionary of joint torques
1111
1212
"""
13-
from cmath import acos, asin
14-
from multiprocessing.connection import wait
15-
import random
13+
from cmath import acos
1614
from cv2 import sqrt
1715
import numpy as np
18-
from sympy import rot_axis1, rot_axis2, rot_axis3
16+
from sympy import rot_axis1, rot_axis2
1917

2018
from .utilities import *
21-
import mujoco_py as mjc
2219

2320

2421
class States:

requirements.txt

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
lpips==0.1.4
22
dynamixel-sdk==3.7.31
33
sympy==1.11.1
4+
dv==1.0.10

unity_builds/unity.lock

0 Bytes
Binary file not shown.

utils/txt_to_h5.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import glob
22
import argparse
33
import os
4-
import h5py
54
import pandas as pd
65
import numpy as np
76
from event_packagers import *

0 commit comments

Comments
 (0)