Coder Social home page Coder Social logo

tactile-brush-python's Introduction

Tactile Brush

This repository contains a python implementation of the original TactileBrush algorithm found here:

Requirements

  • sortedcontainers : install via pip install sortedcontainers

Example

# Grid with 2 lines and 4 columns with a spacing of 2.5 cm
t = TactileBrush(2, 4, 2.5) 

# Create a stroke that starts at the top left and ends at the bottom right
# Coordinates are given in units (not centimetres!)
s = Stroke(0, 1, 3, 0, 1000, 1) 

# Run algorithm
t.compute_stroke_steps(s)

t.pretty_print()

Output of pretty_print():

Time 0 ms:
         Physical actuator at column 0 and line 1 triggered for 216.69191919191914 msec with intensity 1
Time 116.64141414141412 ms:
         Physical actuator at column 1 and line 0 triggered for 545.0130088766451 msec with intensity 0.5773502691896257
         Physical actuator at column 1 and line 1 triggered for 545.0130088766451 msec with intensity 0.816496580927726
Time 338.34557698194055 ms:
         Physical actuator at column 2 and line 0 triggered for 714.1481156839282 msec with intensity 0.816496580927726
         Physical actuator at column 2 and line 1 triggered for 714.1481156839282 msec with intensity 0.5773502691896258
Time 614.1729740007977 ms:
         Physical actuator at column 3 and line 0 triggered for 385.8270259992023 msec with intensity 1

JSON Converter

The PatternConverter.py script allows you to create a vibration pattern from a stroke that can then be used with Vibration Pattern Player.

Setup

Setup the mapping of actuators and the grid size in the config.json file.

{
    "mapping": 
    {
        "0,0": 4,
        "1,0" : 5,
        "2,0" : 6,
        "3,0" : 7,
        "0,1" : 0,
        "1,1" : 1,
        "2,1" : 2,
        "3,1" : 3,
        "0,2" : 8,
        "1,2" : 9,
        "2,2" : 10,
        "3,2" : 11,
        "0,3" : 12,
        "1,3" : 13,
        "2,3" : 14,
        "3,3" : 15
    }, 
    "grid":
    {
        "columns" : 4, 
        "lines" : 4, 
        "spacing" : 2.5 
    }
}

mapping: Maps grid coordinates to a vibration pin.
columns: The number of columns your grid has.
lines: The number of lines your grid has.
spacing: The spacing in centimetres between each vibration motor.

Run application

Simply run the PatternConverter.py in a terminal of your choice and follow the instructions. The script prints a JSON string in the terminal after completion.

tactile-brush-python's People

Contributors

jjarvis89 avatar

Stargazers

Dennis Wittchen avatar

Watchers

Oliver Korn avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.