Skip to content

Commit 12276ac

Browse files
rhenthornandermi
andauthored
henthorn/sim pblog (#44)
* Created buoy-type logging for buoy_sim * Clean up formatting to match buoy logging * Fix flake8 and pep8 erros * Fix flake8 and pep8 errors 2 * Fix flake8 and pep8 errors 3 * Formatting erros in launch script - empty line needed * Add epoch seconds offset to simulation time, log that value as the timestamp * Corrected header line * Move log home and file interval to class attributes * Add pblog args (#47) * add launch args for log paths; add ros2 param for interval; fix symlinks; add rosdeps Signed-off-by: Michael Anderson <anderson@mbari.org> * Update package.xml fix rosdep * fix atexit gzip Signed-off-by: Michael Anderson <anderson@mbari.org> * linter Signed-off-by: Michael Anderson <anderson@mbari.org> * update default pblog root; stop gzipping at exit; fix gzipping at start Signed-off-by: Michael Anderson <anderson@mbari.org> * remove unused import Signed-off-by: Michael Anderson <anderson@mbari.org> * Correct faulty CrossbowID value from 5 to 3 --------- Signed-off-by: Michael Anderson <anderson@mbari.org> Co-authored-by: Rich Henthorn <henthorn@mbari.org> * Corrected error: using pc_header to calculate the 'blank' cells in a record when xb_header, bc_header, and sc_header should have been used * tweak msg time a little Signed-off-by: Michael Anderson <anderson@mbari.org> * Fix pbcmd terminate (#50) * add async proxy to await future for pack rate calls Signed-off-by: Michael Anderson <anderson@mbari.org> * typo Signed-off-by: Michael Anderson <anderson@mbari.org> --------- Signed-off-by: Michael Anderson <anderson@mbari.org> * line buffered csv Signed-off-by: Michael Anderson <anderson@mbari.org> * linter Signed-off-by: Michael Anderson <anderson@mbari.org> * Update sim_pblog/sim_pblog/sim_pblog.py * fix data loss with log rolling Signed-off-by: Michael Anderson <anderson@mbari.org> * bugfix Signed-off-by: Michael Anderson <anderson@mbari.org> * linter Signed-off-by: Michael Anderson <anderson@mbari.org> * linter Signed-off-by: Michael Anderson <anderson@mbari.org> * Convert SC values from newtons and meters to lbs and inches --------- Signed-off-by: Michael Anderson <anderson@mbari.org> Co-authored-by: Michael Anderson <anderson@mbari.org>
1 parent 9ab7d81 commit 12276ac

File tree

16 files changed

+972
-13
lines changed

16 files changed

+972
-13
lines changed

.gitignore

Lines changed: 129 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,132 @@ __pycache__
22
*.swp
33
*.save*
44

5-
splinter/include/splinter
6-
splinter/lib
7-
splinter/splinter
8-
splinter/assets
9-
splinter/CREDITS.md
10-
splinter/docs
11-
splinter/README_SPLINTER.md
5+
# Byte-compiled / optimized / DLL files
6+
__pycache__/
7+
*.py[cod]
8+
*$py.class
9+
10+
# C extensions
11+
*.so
12+
13+
# Distribution / packaging
14+
.Python
15+
build/
16+
develop-eggs/
17+
dist/
18+
downloads/
19+
eggs/
20+
.eggs/
21+
lib/
22+
lib64/
23+
parts/
24+
sdist/
25+
var/
26+
wheels/
27+
pip-wheel-metadata/
28+
share/python-wheels/
29+
*.egg-info/
30+
.installed.cfg
31+
*.egg
32+
MANIFEST
33+
34+
# PyInstaller
35+
# Usually these files are written by a python script from a template
36+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
37+
*.manifest
38+
*.spec
39+
40+
# Installer logs
41+
pip-log.txt
42+
pip-delete-this-directory.txt
43+
44+
# Unit test / coverage reports
45+
htmlcov/
46+
.tox/
47+
.nox/
48+
.coverage
49+
.coverage.*
50+
.cache
51+
nosetests.xml
52+
coverage.xml
53+
*.cover
54+
*.py,cover
55+
.hypothesis/
56+
.pytest_cache/
57+
58+
# Translations
59+
*.mo
60+
*.pot
61+
62+
# Django stuff:
63+
*.log
64+
local_settings.py
65+
db.sqlite3
66+
db.sqlite3-journal
67+
68+
# Flask stuff:
69+
instance/
70+
.webassets-cache
71+
72+
# Scrapy stuff:
73+
.scrapy
74+
75+
# Sphinx documentation
76+
docs/_build/
77+
78+
# PyBuilder
79+
target/
80+
81+
# Jupyter Notebook
82+
.ipynb_checkpoints
83+
84+
# IPython
85+
profile_default/
86+
ipython_config.py
87+
88+
# pyenv
89+
.python-version
90+
91+
# pipenv
92+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
93+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
94+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
95+
# install all needed dependencies.
96+
#Pipfile.lock
97+
98+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
99+
__pypackages__/
100+
101+
# Celery stuff
102+
celerybeat-schedule
103+
celerybeat.pid
104+
105+
# SageMath parsed files
106+
*.sage.py
107+
108+
# Environments
109+
.env
110+
.venv
111+
env/
112+
venv/
113+
ENV/
114+
env.bak/
115+
venv.bak/
116+
117+
# Spyder project settings
118+
.spyderproject
119+
.spyproject
120+
121+
# Rope project settings
122+
.ropeproject
123+
124+
# mkdocs documentation
125+
/site
126+
127+
# mypy
128+
.mypy_cache/
129+
.dmypy.json
130+
dmypy.json
131+
132+
# Pyre type checker
133+
.pyre/

buoy_api_py/buoy_api/interface.py

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -233,36 +233,56 @@ def use_sim_time(self, enable=True):
233233
self.set_parameters([Parameter('use_sim_time', Parameter.Type.BOOL, enable)])
234234

235235
# set publish rate of PC Microcontroller telemetry
236-
def set_pc_pack_rate_param(self, rate_hz=50.0):
236+
def set_pc_pack_rate_param(self, rate_hz=50.0, blocking=True):
237+
return asyncio.run(self._set_pc_pack_rate_param(rate_hz, blocking))
238+
239+
async def _set_pc_pack_rate_param(self, rate_hz=50.0, blocking=True):
237240
request = SetParameters.Request()
238241
request.parameters = [Parameter(name='publish_rate',
239242
value=float(rate_hz)).to_parameter_msg()]
240243
self.pc_pack_rate_param_future_ = self.pc_pack_rate_param_client_.call_async(request)
241244
self.pc_pack_rate_param_future_.add_done_callback(self.param_response_callback)
245+
if blocking:
246+
await self.pc_pack_rate_param_future_
242247

243248
# set publish rate of SC Microcontroller telemetry
244-
def set_sc_pack_rate_param(self, rate_hz=50.0):
249+
def set_sc_pack_rate_param(self, rate_hz=50.0, blocking=True):
250+
return asyncio.run(self._set_sc_pack_rate_param(rate_hz, blocking))
251+
252+
async def _set_sc_pack_rate_param(self, rate_hz=50.0, blocking=True):
245253
request = SetParameters.Request()
246254
request.parameters = [Parameter(name='publish_rate',
247255
value=float(rate_hz)).to_parameter_msg()]
248256
self.sc_pack_rate_param_future_ = self.sc_pack_rate_param_client_.call_async(request)
249257
self.sc_pack_rate_param_future_.add_done_callback(self.param_response_callback)
258+
if blocking:
259+
await self.sc_pack_rate_param_future_
250260

251261
# set publish rate of PC Microcontroller telemetry
252-
def set_pc_pack_rate(self, rate_hz=50):
262+
def set_pc_pack_rate(self, rate_hz=50, blocking=True):
263+
return asyncio.run(self._set_pc_pack_rate(rate_hz, blocking))
264+
265+
async def _set_pc_pack_rate(self, rate_hz=50, blocking=True):
253266
request = PCPackRateCommand.Request()
254267
request.rate_hz = int(rate_hz)
255268

256269
self.pc_pack_rate_future_ = self.pc_pack_rate_client_.call_async(request)
257270
self.pc_pack_rate_future_.add_done_callback(self.default_service_response_callback)
271+
if blocking:
272+
await self.pc_pack_rate_future_
258273

259274
# set publish rate of SC Microcontroller telemetry
260-
def set_sc_pack_rate(self, rate_hz=50):
275+
def set_sc_pack_rate(self, rate_hz=50, blocking=True):
276+
return asyncio.run(self._set_sc_pack_rate(rate_hz, blocking))
277+
278+
async def _set_sc_pack_rate(self, rate_hz=50, blocking=True):
261279
request = SCPackRateCommand.Request()
262280
request.rate_hz = int(rate_hz)
263281

264282
self.sc_pack_rate_future_ = self.sc_pack_rate_client_.call_async(request)
265283
self.sc_pack_rate_future_.add_done_callback(self.default_service_response_callback)
284+
if blocking:
285+
await self.sc_pack_rate_future_
266286

267287
def send_pump_command(self, duration_mins, blocking=True):
268288
return asyncio.run(self._send_pump_command(duration_mins, blocking))

pbcmd/pbcmd/pbcmd.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ def sc_pack_rate(parser):
156156
print('Executing sc_pack_rate to Set the CANBUS packet rate ' +
157157
f'from the Spring Controller: {args.rate_hz} Hz')
158158
_pbcmd = _PBCmd()
159-
_pbcmd.set_sc_pack_rate_param(args.rate_hz)
159+
_pbcmd.set_sc_pack_rate(args.rate_hz)
160160

161161

162162
def pc_PackRate(parser):
@@ -169,7 +169,7 @@ def pc_PackRate(parser):
169169
print('Executing pc_PackRate to Set the CANBUS packet rate ' +
170170
f'from the Power Controller: {args.rate_hz} Hz')
171171
_pbcmd = _PBCmd()
172-
_pbcmd.set_pc_pack_rate_param(args.rate_hz)
172+
_pbcmd.set_pc_pack_rate(args.rate_hz)
173173

174174

175175
def pc_Scale(parser):

0 commit comments

Comments
 (0)