|
15 | 15 | from datetime import datetime, timedelta, timezone |
16 | 16 | import json |
17 | 17 | import math |
18 | | -import numpy as np |
19 | 18 | import os.path |
20 | 19 | from platformdirs import user_config_dir |
21 | 20 | from pathlib import Path |
@@ -589,8 +588,7 @@ def collect_duration(self, |
589 | 588 | t0 = timedelta() |
590 | 589 |
|
591 | 590 | if self.time_format == "ms": |
592 | | - if isinstance(times, (collections.abc.Sequence, |
593 | | - np.ndarray)) and not isinstance(times, str): |
| 591 | + if isinstance(times, collections.abc.Sequence) and not isinstance(times, str): |
594 | 592 | t0 = timedelta(milliseconds=times[0]) |
595 | 593 | else: |
596 | 594 | t0 = timedelta(milliseconds=times) |
@@ -664,9 +662,7 @@ def collect_duration(self, |
664 | 662 | t1 = timedelta() |
665 | 663 |
|
666 | 664 | if self.time_format == "ms": |
667 | | - if isinstance(times, |
668 | | - (collections.abc.Sequence, |
669 | | - np.ndarray)) and not isinstance(times, str): |
| 665 | + if isinstance(times,collections.abc.Sequence) and not isinstance(times, str): |
670 | 666 | t1 = timedelta(milliseconds=times[-1]) |
671 | 667 | else: |
672 | 668 | t1 = timedelta(milliseconds=times) |
@@ -728,44 +724,4 @@ def printProgressBar(iteration, |
728 | 724 | print() |
729 | 725 |
|
730 | 726 |
|
731 | | -if __name__ == "__main__": |
732 | | - |
733 | | - print(""" |
734 | | -#Example code: |
735 | | -%pip install practable |
736 | | -import matplotlib.pyplot as plt |
737 | | -from practable.core import Experiment |
738 | | -
|
739 | | -messages = [] |
740 | | - |
741 | | -#modify with actual group code and experiment name |
742 | | -with Experiment('g-open-xxxxx','Spinner 51', exact=True) as expt: |
743 | | - |
744 | | - # Command a step of 2 radians & collect the data |
745 | | - expt.command('{"set":"mode","to":"stop"}') |
746 | | - expt.command('{"set":"mode","to":"position"}') |
747 | | - expt.command('{"set":"parameters","kp":1,"ki":0,"kd":0}') |
748 | | -
|
749 | | - time.sleep(0.5) |
750 | | - |
751 | | - expt.command('{"set":"position","to":2}') |
752 | | - |
753 | | - expt.ignore(0.5) |
754 | | - messages = expt.collect(1.5) |
755 | | - |
756 | | - # Process the data |
757 | | - ts = expt.extract_series(messages, "t") |
758 | | - ds = expt.extract_series(messages, "d") |
759 | | - cs = expt.extract_series(messages, "c") |
760 | | - |
761 | | - t = np.array(ts) |
762 | | - t = t - t[0] |
763 | | - |
764 | | - # Plot the data |
765 | | - plt.figure() |
766 | | - plt.plot(t/1e3,ds,'-b',label="position") |
767 | | - plt.plot(t/1e3,cs,':r',label="set point") |
768 | | - plt.xlabel("time(s)") |
769 | | - plt.ylabel("position(rad)") |
770 | | - plt.legend() |
771 | | -""") |
| 727 | + |
0 commit comments