diff --git a/examples/joint.h5 b/examples/joint.h5 new file mode 100644 index 0000000000000000000000000000000000000000..3686ac081b34e2eccf099720f99914a6678e4909 Binary files /dev/null and b/examples/joint.h5 differ diff --git a/examples/thd_joint_joint.h5 b/examples/thd_joint_joint.h5 new file mode 100644 index 0000000000000000000000000000000000000000..9fd3ea7a85ce98963baab038a576b2ee7351ed2f Binary files /dev/null and b/examples/thd_joint_joint.h5 differ diff --git a/pyproject.toml b/pyproject.toml index f8ace50d8ee784fec3853ad322b0408f6fdafc2c..66171355b48e78eed7661712531767b5f24be79d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "h5schemas" -version = "0.1.0" +version = "0.1.12" description = "Add your description here" readme = "README.md" authors = [ diff --git a/src/h5schemas/joint/__init__.py b/src/h5schemas/joint/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/src/h5schemas/joint/add_joint.py b/src/h5schemas/joint/add_joint.py new file mode 100644 index 0000000000000000000000000000000000000000..add81374607a372cd0b51b56e3da0fe223956462 --- /dev/null +++ b/src/h5schemas/joint/add_joint.py @@ -0,0 +1,28 @@ +from h5py import File, Group +from thd_json import joint +from h5schemas.scan_schema import open_schema +from h5schemas.initialize_dataset import initialize_dataset + + +def init_joint(h5_file: File | Group): + schema_groups = get_source_schemas() + initialize_dataset(h5_file, schema_groups) + + +def get_source_schemas(): + return open_schema(joint, "joint.json") + + +def add_joint_sample(h5_file: File | Group, joint_value_rad): + dst = h5_file["q"] + dst.resize((dst.shape[0] + 1,)) + dst[-1,] = joint_value_rad + + +if __name__ == "__main__": + test_file = File("./examples/joint.h5", "w") + init_joint(test_file) + + add_joint_sample(test_file, 1.0) + add_joint_sample(test_file, 2.0) + add_joint_sample(test_file, 3.0) diff --git a/src/h5schemas/thd_joint_states/__init__.py b/src/h5schemas/thd_joint_states/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/src/h5schemas/thd_joint_states/add_thd_joint_states.py b/src/h5schemas/thd_joint_states/add_thd_joint_states.py new file mode 100644 index 0000000000000000000000000000000000000000..682ce8c0dad3a35aaf76e0ec6ea991807ce1354a --- /dev/null +++ b/src/h5schemas/thd_joint_states/add_thd_joint_states.py @@ -0,0 +1,65 @@ +from h5py import File, Group +from thd_json import thd_joint_states +from h5schemas.scan_schema import open_schema +from h5schemas.initialize_dataset import initialize_dataset +from h5schemas.joint.add_joint import add_joint_sample + + +def init_thd_joint_states(h5_file: File | Group): + schema_groups = get_source_schemas() + initialize_dataset(h5_file, schema_groups) + + +def get_source_schemas(): + return open_schema(thd_joint_states, "thd_joint_states.json") + + +def add_thd_joint_states_sample( + h5_file: File | Group, + master_joint_e1: float | None = None, + master_joint_a1: float | None = None, + master_joint_a2: float | None = None, + master_joint_a3: float | None = None, + master_joint_a4: float | None = None, + master_joint_a5: float | None = None, + master_joint_a6: float | None = None, + slave_joint_e1: float | None = None, + slave_joint_a1: float | None = None, + slave_joint_a2: float | None = None, + slave_joint_a3: float | None = None, + slave_joint_a4: float | None = None, + slave_joint_a5: float | None = None, + slave_joint_a6: float | None = None, + table_joint_a1: float | None = None): + + + add_joint_sample(h5_file["/master_joint_e1"], master_joint_e1) + + add_joint_sample(h5_file["/master_joint_a1"], master_joint_a1) + add_joint_sample(h5_file["/master_joint_a2"], master_joint_a2) + add_joint_sample(h5_file["/master_joint_a3"], master_joint_a3) + add_joint_sample(h5_file["/master_joint_a4"], master_joint_a4) + add_joint_sample(h5_file["/master_joint_a5"], master_joint_a5) + add_joint_sample(h5_file["/master_joint_a6"], master_joint_a6) + + add_joint_sample(h5_file["/slave_joint_e1"], slave_joint_e1) + + add_joint_sample(h5_file["/slave_joint_a1"], slave_joint_a1) + add_joint_sample(h5_file["/slave_joint_a2"], slave_joint_a2) + add_joint_sample(h5_file["/slave_joint_a3"], slave_joint_a3) + add_joint_sample(h5_file["/slave_joint_a4"], slave_joint_a4) + add_joint_sample(h5_file["/slave_joint_a5"], slave_joint_a5) + add_joint_sample(h5_file["/slave_joint_a6"], slave_joint_a6) + + add_joint_sample(h5_file["/table_joint_a1"], table_joint_a1) + +if __name__ == "__main__": + import numpy as np + + + test_file = File("./examples/thd_joint_joint.h5", "w") + init_thd_joint_states(test_file) + + add_thd_joint_states_sample(test_file, *np.arange(15)) + add_thd_joint_states_sample(test_file, *np.arange(15, 30)) + diff --git a/uv.lock b/uv.lock index d5b322e2d676f2c9021288d4d67c58cafc031600..dcf914aae7e0effa6c70bec0b18e8306d336b1ac 100644 --- a/uv.lock +++ b/uv.lock @@ -52,7 +52,7 @@ wheels = [ [[package]] name = "h5schemas" -version = "0.1.0" +version = "0.1.12" source = { editable = "." } dependencies = [ { name = "h5py" }, @@ -64,7 +64,7 @@ dependencies = [ requires-dist = [ { name = "h5py", specifier = ">=3.13.0" }, { name = "jsonref", specifier = ">=1.1.0" }, - { name = "thd-json", git = "https://mygit.th-deg.de/roboct/definitions/json_schemas" }, + { name = "thd-json", git = "https://mygit.th-deg.de/roboct-public/roboct-schemas" }, ] [[package]] @@ -418,8 +418,8 @@ wheels = [ [[package]] name = "thd-json" -version = "0.1.11" -source = { git = "https://mygit.th-deg.de/roboct/definitions/json_schemas#549627970741441756a671333ac8e5f949241eb3" } +version = "0.1.12" +source = { git = "https://mygit.th-deg.de/roboct-public/roboct-schemas#f9f601e871cd8a514e4df9884a17777bc2474c21" } dependencies = [ { name = "hatchling" }, { name = "hypothesis" },