semvec/pypi-packages huggingface dataset:
attrs2bin 0.0.1
Binary serializer for attrs-based classes
Requires Python: >=3.6

# attrs2bin
`attrs2bin` is a Python library that lets you serialize/deserialize your [`attrs`](https://www.attrs.org/en/stable/)-based classes to/from a byte stream. It is compatible with Rust's [`bincode`](https://github.com/servo/bincode), so you can seralize objects in Python, send the resulting byte stream through a socket or any other transport and deserialize it back to a Rust object. It can also deserialize objects from a socket (see below).

# Example

`attrs2bin` provides just two simple funcions: `serialize()`, which takes an object and returns a byte stream, and `deserialize()`, that takes a byte stream and an `attrs`-based class and returns an object.

```import attr
import attrs2bin

@attr.s(auto_attribs=True)
class Sprite:
    name: str
    x: int
    y: int

my_sprite = Sprite("My sprite", 35, 70)
serialized = attrs2bin.serialize(my_sprite)
deserialized = attrs2bin.deserialize(serialized, Sprite)
assert my_sprite == deserialized
```

# What can be serialized?

Objects of any `attrs`-based class can be serialized, as long as all their fields have a type (using type annotations or `attr.ib(type=...)`). `attrs2bin` ships with serializer for the following types:

* `int`
* `float`
* `bytes`
* `str`
* `bool`

You can create and register your own serializers for specific types by creating a class that implements `attrs2bin.interfaces.ITypeSerializer` and calling `attrs2bin.register_serializer()`.

# Deserializing from a socket

Instead of `deserialize(bytes, cls)`, you can use `deserialize_from_socket(sck, cls)`, which will read the necessary bytes from a socket and return a Python object. `sck` must be any object that implements `attrs2bin.interfaces.IReadableSocket`.

# Rust compatibility

The serializers that ships with `attrs2bin` are all compatible with Rust's [`bincode`](https://github.com/servo/bincode) library. Keep under your pillow the following table in order to create compatible types between Python and Rust:

| Python type                   | Rust type     |
| ---------------------------   |:-------------:|
| `int` / `attrs2bin.SignedInt` | `i64`         |
| `attrs2bin.UnsignedInt`       | `u64`         |
| `float` / `attrs2bin.Float64` | `f64`         |
| `attrs2bin.Float32`           | `f32`         |
| `bytes`                       | `Vec<u8>`     |
| `str`                         | `String`      |
| `bool`                        | `bool`        |
pybuildit 1.0.1
python API for Buildit Actuator

# Buildit

Buildit Actuator を制御する為のPython3用ライブラリ


## Install

### Windows

```
$ pip3 install pybuildit
```

### Ubuntu

```
$ sudo apt-get -y install python3-tk
$ pip3 install pybuildit
```

## Usage

### pybuildit library

* ライブラリについてのドキュメント
    * https://www.smartrobotics.jp/products/buildit/latest/pybuildit.pdf

* 初期化
    * ※ 以下のデバイスファイル名やCOMポート番号は環境に合わせて変更する必要があります
```
>>> from pybuildit import *
>>> buildit = Buildit(port="/dev/ttyXXXX") #for Linux (例: /dev/ttyUSB0)
>>> buildit = Buildit(port="COMX") #for Win (例：COM8)
>>> deviceId = 1
```


* 現在の位置や速度といった情報の取得

```
>>> qss = buildit.query_servo_status(deviceId)
>>> print("position[deg]: ", qss.position(unit="deg"))
>>> print("velocity[rpm]: ", qss.velocity(unit="rpm"))
>>> print("temperature[℃]: ", qss.temperature())
>>> print("state: ", buildit.last_mcp_status().str_state())
```

* 速度制御と位置制御の方法

```
>>> buildit.force_ready(deviceId)
>>> buildit.set_ref_velocity(deviceId, 40, unit="rpm")
>>> buildit.set_ref_position(deviceId, 180, unit="deg")

```


### builditctl

builditctl は Buildit の各メソッドをコマンドラインから呼び出す為のツールです。
アクチュエーターの状態を確認する場合は以下のように実行します。

```
$ builditctl query-servo-status -d 1 -p /dev/ttyXXXX
state: STATE_HOLD
pos: -51636
vel: 0
cur: 0
ref: 0
temp: 26
faults: NO_FAULTS
```

速度制御を行う場合は以下のように実行します。

```
$ builditctl ready -d 1 -p /dev/ttyXXXX

$ builditctl set-ref-velocity 2500 -d 1 -p /dev/ttyXXXX # 指定速度の単位は [rpm/100]
0
```

位置制御を行う場合は以下のように実行します。

```
$ builditctl stop -d 1 -p /dev/ttyXXXX

$ builditctl set-ref-position 2500 -d 1 -p /dev/ttyXXXX # 指定位置の単位は [360/65536 度]
-39775
```


### builditct-gui

builditctl は Buildit の各メソッドをコマンドラインから呼び出す為のツールです。

```
$ builditctl-gui
```

ポートを選択し、Connectボタンを押した後、各種ボタンを使ってデバイスを操作することが出来ます。