Skip to content

Commit

Permalink
Merge pull request #95 from LaboratoireMecaniqueLille/release/2.0.4
Browse files Browse the repository at this point in the history
Release of version 2.0.4
  • Loading branch information
WeisLeDocto authored Feb 7, 2024
2 parents b9ffd74 + b7daa6b commit f7ceb73
Show file tree
Hide file tree
Showing 16 changed files with 698 additions and 13 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/python_package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Installs the Python dependencies, installs Crappy, and checks that it imports
name: Python Package

on:
# Runs on pull requests targeting the default branch
pull_request:
types: [opened, edited, reopened, synchronize]
branches: ["master", "develop"]

# May also be started manually
workflow_dispatch:

# Runs automatically every first day of the month
schedule:
- cron: '0 12 1 * *'

jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
os: [ubuntu-latest, windows-latest, macos-latest]

steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }} on ${{ matrix.os }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: python -m pip install --upgrade pip wheel build setuptools
- name: Install Crappy
run: python -m pip install .
- name: Import Crappy
run: python -c "import crappy; print(crappy.__version__)"
4 changes: 4 additions & 0 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
# PIERROOOTT owns the Gstreamer cameras
/src/crappy/camera/gstreamer_* @WeisLeDocto @PIERROOOTT

# PIERROOOTT owns the Phidget hardware
/src/crappy/actuator/phidgets_stepper4a.py @WeisLeDocto @PIERROOOTT
/src/crappy/inout/phidgets_wheatstone_bridge.py @WeisLeDocto @PIERROOOTT

# PIERROOOTT owns the Opencv cameras
/src/crappy/camera/opencv_* @WeisLeDocto @PIERROOOTT

Expand Down
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from time import gmtime, strftime
from re import match

__version__ = '2.0.3'
__version__ = '2.0.4'

# -- Project information -----------------------------------------------------

Expand Down
7 changes: 7 additions & 0 deletions docs/source/crappy_docs/actuators.rst
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,13 @@ Oriental ARD-K
:members: open, get_position, set_speed, set_position, stop, close
:special-members: __init__

Phidget Stepper4A
+++++++++++++++++
.. autoclass:: crappy.actuator.Phidget4AStepper
:members: open, set_speed, set_position, get_speed, get_position, stop,
close
:special-members: __init__

Pololu Tic
++++++++++
.. autoclass:: crappy.actuator.PololuTic
Expand Down
6 changes: 6 additions & 0 deletions docs/source/crappy_docs/inouts.rst
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,12 @@ OpSens HandySens
:members: open, get_data, close
:special-members: __init__

Phidget Wheatstone Bridge
+++++++++++++++++++++++++
.. autoclass:: crappy.inout.PhidgetWheatstoneBridge
:members: open, get_data, close
:special-members: __init__

PiJuice
+++++++
.. autoclass:: crappy.inout.PiJuice
Expand Down
5 changes: 5 additions & 0 deletions docs/source/crappy_docs/modifiers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ Differentiate
.. autoclass:: crappy.modifier.Diff
:special-members: __init__, __call__

DownSampler
+++++++++++
.. autoclass:: crappy.modifier.DownSampler
:special-members: __init__, __call__

Integrate
+++++++++
.. autoclass:: crappy.modifier.Integrate
Expand Down
48 changes: 38 additions & 10 deletions docs/source/features.rst
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,17 @@ Supported Actuators
This object hasn't been maintained nor tested for a while, it is not sure
that it still works as expected !

- :ref:`Phidget Stepper4A`

Drives 4A bipolar stepper motors using Phidget's `Stepper4A <https://
www.phidgets.com/?prodid=1278>`_ in speed or in position, by using several
Phidget libraries.

.. Important::
This Actuator must be connected to Phidget's VINT Hub to work. See the
following link `<https://www.phidgets.com/?prodid=1278#Tab_User_Guide>`_
to connect properly to the Hub.

- :ref:`Pololu Tic`

Drives Pololu's `Tic <https://www.pololu.com/category/212/tic-stepper-motor-
Expand Down Expand Up @@ -675,16 +686,6 @@ Sensors
Reads voltages from Sparfun's `'Qwiic Scale' NAU7802 <https://www.sparkfun.
com/products/15242>`_ load cell conditioner. Communicates over I2C.

- :ref:`PiJuice`

Reads the charging status and battery level of Kubii's `PiJuice <https://
www.kubii.com/fr/14-chargeurs-alimentations-raspberry/2019-pijuice-hat-kubii
-3272496008793.html>`_ Raspberry Pi power supply.

.. Important::
This InOut was written for a specific application, so it may not be
usable as-is in the general case.

- :ref:`OpSens HandySens`

Reads data from OpSens' `single channel signal conditioner <https://opsens-
Expand All @@ -696,6 +697,26 @@ Sensors
This object hasn't been maintained nor tested for a while, it is not sure
that it still works as expected !

- :ref:`Phidget Wheatstone Bridge`

Reads volatges from Phidget's `Wheatstone Bridge <https://www.phidgets.com/
?prodid=957>`_ load cell conditioner, by using several Phidget libraries.

.. Important::
This InOut must be connected to Phidget's VINT Hub to work. See the
following link `<https://www.phidgets.com/?prodid=957#Tab_User_Guide>`_ to
connect properly to the Hub.

- :ref:`PiJuice`

Reads the charging status and battery level of Kubii's `PiJuice <https://
www.kubii.com/fr/14-chargeurs-alimentations-raspberry/2019-pijuice-hat-kubii
-3272496008793.html>`_ Raspberry Pi power supply.

.. Important::
This InOut was written for a specific application, so it may not be
usable as-is in the general case.

- :ref:`Spectrum M2I 4711`

Reads voltages from Spectrum's `M2i 4711 EXP <https://spectrum-
Expand Down Expand Up @@ -817,6 +838,7 @@ On-the-fly data modification (Modifiers)
----------------------------------------

.. sectionauthor:: Antoine Weisrock <[email protected]>
.. sectionauthor:: Pierre Margotin <[email protected]>

- :ref:`Demux`

Expand All @@ -828,6 +850,12 @@ On-the-fly data modification (Modifiers)

Calculates the time derivative of a given label.

- :ref:`DownSampler`

Transmits the values to downstream Blocks only once every given number of
points. The values that are not sent are discarded. The values are directly
sent without being altered.

- :ref:`Integrate`

Integrates a given label over time.
Expand Down
80 changes: 80 additions & 0 deletions examples/modifiers/downsampler.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# coding: utf-8

"""
This example demonstrates the use of the DownSampler Modifier. It does not
require any specific hardware to run, but necessitates the matplotlib Python
module to be installed.
The DownSampler Modifier transmits only one data point every n received points
received from its upstream Block. It is therefore useful for reducing the data
rate in a given Link.
Here, a sine wave is generated by a Generator Block and sent to two Grapher
Blocks for display. One Grapher displays it as it is generated, and the other
displays it downsampled by a DownSampler Modifier. Because the frequency of the
sine wave is 1 Hz and the frequency of the Generator Block is twice that of the
DownSampler, the value passed to the second Grapher are always close to 1 or
-1, the peak of the sine wave.
After starting this script, just watch how the raw signal is transformed by the
DownSampler Modifier and alternates between 1 and -1. Also notice how the
initial data rate of the signal is divided when passing through the DownSampler
Modifier. This demo ends after 22s. You can also hit CTRL+C to stop it
earlier, but it is not a clean way to stop Crappy.
"""

import crappy
import numpy as np

if __name__ == '__main__':

# This Generator Block generates a sine wave for the Graphers to display. It
# sends it to one Grapher that displays it as is, and to another Grapher that
# receives it downsampled by the DownSampler Modifier
gen = crappy.blocks.Generator(
# Generating a sine wave of amplitude 2 and frequency 1 and phase pi/2
({'type': 'Sine',
'condition': 'delay=20',
'amplitude': 2,
'freq': 1,
'phase': np.pi/2},),
freq=30, # Lowering the default frequency because it's just a demo
cmd_label='sine', # The label carrying the generated signal

# Sticking to default for the other arguments
)

# This Grapher Block displays the raw sine wave it receives from the
# Generator. As the Generator runs at 30Hz, 30 data points are received each
# second for display
graph = crappy.blocks.Grapher(
('t(s)', 'sine'), # The names of the labels to plot on the graph
interp=False, # Not linking the displayed spots, to better see the
# frequency of the input
length=100, # Only displaying the data for the last 100 points

# Sticking to default for the other arguments
)

# This Grapher Block displays the downsampled sine wave it receives from the
# Generator. Because the frequency of the sine wave is 1 Hz and the frequency
# of the Generator Block is twice that of the DownSampler, only values close
# to 1 and -1 are received.
graph_down = crappy.blocks.Grapher(
('t(s)', 'sine'), # The names of the labels to plot on the graph
interp=False, # Not linking the displayed spots, to better see the
# frequency of the input

# Sticking to default for the other arguments
)

# Linking the Block so that the information is correctly sent and received
crappy.link(gen, graph)
crappy.link(gen, graph_down,
# Adding a DownSampler Modifier for downsampling the sine
# wave before sending to the Grapher. A data point is sent for
# display once every 15 received points
modifier=crappy.modifier.DownSampler(15))

# Mandatory line for starting the test, this call is blocking
crappy.start()
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"
[project]
name = "crappy"
dynamic = ["readme"]
version = "2.0.3"
version = "2.0.4"
description = "Command and Real-time Acquisition in Parallelized Python"
license = {file = "LICENSE"}
keywords = ["control", "command", "acquisition", "multiprocessing"]
Expand Down
2 changes: 1 addition & 1 deletion src/crappy/__version__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# coding: utf-8

__version__ = '2.0.3'
__version__ = '2.0.4'
1 change: 1 addition & 0 deletions src/crappy/actuator/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from .kollmorgen_servostar_300 import ServoStar300
from .newport_tra6ppd import NewportTRA6PPD
from .oriental_ard_k import OrientalARDK
from .phidgets_stepper4a import Phidget4AStepper
from .pololu_tic import PololuTic
from .schneider_mdrive_23 import SchneiderMDrive23

Expand Down
Loading

0 comments on commit f7ceb73

Please sign in to comment.