Code Monkey home page Code Monkey logo

hotwing-core's Introduction

About

This repository consists of a Python Module, which contains the core libraries for the HotWing-CLI and HotWing-GUI projects. This Module provides a series of classes and functions to aid in creating GCode for 4-Axis CNC foam cutters, specifically working with wing profiles, interpolating new profiles, and computing reverse kinematics for the CNC.

Build Status Coverage Versions License: GPL v3

Installation

pip install hotwing-core

Docs

You can find the docs here : https://jasonhamilton.github.io/hotwing-core/index.html

Working With HotWing

Coordinate

A Coordinate is the most basic building block. It represents a point in 2D space and simply contains x and y values. If we want to lay out some coordinates that look like:

Coordinate Visual Representation

We can use the following code:

from hotwing_core import Coordinate

c1 = Coordinate(0,0)
c2 = Coordinate(0.25,0.2)
c3 = Coordinate(0.5,0.25)

# you can add, subtract and multiply Coordinates
c4 = c2+c3 # 0.75,0.45

You can find more info on the Coordinate's methods and functionality in the Documentation: https://jasonhamilton.github.io/hotwing-core/coordinate.html

Surface

A Surface is simply a list of Coordinates, which, when connected with lines, represents a Surface. A Surface contains the information to represent the top or bottom of an airfoil.

If we want to make something like this: Surface Visual Representation

We can do so like:

from hotwing_core import Coordinate
from hotwing_core import Surface

# A list of coordinates that will make up a Surface
# These coordinates should be in either ascending or descending order based on the x value.
coords=[
   Coordinate(1.000, 0.000),
   Coordinate(0.900, 0.015),
   Coordinate(0.800, 0.030),
   Coordinate(0.700, 0.045),
   Coordinate(0.600, 0.060),
   Coordinate(0.500, 0.075),
   Coordinate(0.400, 0.090),
   Coordinate(0.300, 0.105),
   Coordinate(0.200, 0.100),
   Coordinate(0.100, 0.075),
   Coordinate(0.000, 0.000)
]

s = Surface(coords)

The Surface has a bunch of methods you can use, however you'll probably be interacting with the Profile method and letting it handle the lower-level interacton with the Surface object.

You can find more info on the Surface's methods and functionality in the Documentation https://jasonhamilton.github.io/hotwing-core/surface.html

Profile

Next up is the Profile object. A profile is made up of two Surface objects a top and a bottom, which together make up a profile. A profile would look visually like:

Profile Visual Representation

You can create a profile using

from hotwing_core import Coordinate
from hotwing_core import Surface
from hotwing_core import Profile


top = [
   Coordinate(1.000, 0.000),
   Coordinate(0.900, 0.015),
   Coordinate(0.800, 0.030),
   Coordinate(0.700, 0.045),
   Coordinate(0.600, 0.060),
   Coordinate(0.500, 0.075),
   Coordinate(0.400, 0.090),
   Coordinate(0.300, 0.105),
   Coordinate(0.200, 0.100),
   Coordinate(0.100, 0.075),
   Coordinate(0.000, 0.000),
]
bottom = [
   Coordinate(1.000, 0),
   Coordinate(0.900, -0.00375),
   Coordinate(0.800, -0.0075),
   Coordinate(0.700, -0.01125),
   Coordinate(0.600, -0.015),
   Coordinate(0.500, -0.01875),
   Coordinate(0.400, -0.0225),
   Coordinate(0.300, -0.02625),
   Coordinate(0.200, -0.025),
   Coordinate(0.100, -0.01875),
   Coordinate(0.000, 0),
]

both = top+bottom

# You can create a profile from a list of Coordinates
p = Profile(both)

# You can create a Coordinate from two - top and bottom – Surface objects.
p = Profile(Surface(top),Surface(bottom))

# You can open an airfoil from dat (Selig or Lednicer format) a file on your hard drive
p = Profile("profiles/myprofile.dat")

# You can open an airfoil from dat (Selig or Lednicer format) via a URL:
p = Profile(“http://m-selig.ae.illinois.edu/ads/coord/e374.dat”)

The Profile has lots of nifty methods built into it so you can rotate, trim, scale, offset, interpolate, etc. Check out the documentation here: https://jasonhamilton.github.io/hotwing-core/profile.html

Rib

A Rib is a representation of a slice of a wing. A Rib contains a Profile with the airfoil's coordinates, with which it can perform modifications such as scaling, offseting, rotating, and trimming for sheeting allowance (on the top or the bottom) and stock allowance (on the front or back).

from hotwing_core import Rib

## Create Rib
r1 = Rib("http://m-selig.ae.illinois.edu/ads/coord/e374.dat",   # Dat file to use -  File or URL
         scale=10,               # Width of the Rib - Scales the dat file profile
         xy_offset=None,         # Offset 
         top_sheet=0.0625,       # Sheeting allowance top - this will make the foil smaller by this 
                                 #     amount
         bottom_sheet=0.0625,    # Sheeting allowance bottom
         front_stock=0.5,        # Trims the front of the airfoil by this amount.  You would glue 
                                 #     wooden stock here and shape it
         tail_stock=1.25,        # Trims the trailing edge of the foil.  You would put tail stock 
                                 #     here and shape to the foil.
         rotation=0,               # The angle to rotate the rib in degrees - positive number points 
                                 #     the nose upward
         rotation_pos=0.5 )        # Where the rotation point should occur.  0.25 = 25% along the 
                                 #     chord (starting from the front)

# you can get the manipulated profile
r1.profile

# you can get the manipulated profile (pre-sheeting)
r1.airfoil_profile

Documentation: https://jasonhamilton.github.io/hotwing-core/rib.html

Panel

A Panel contains two Ribs and makes up a panel of a wing. If you took the plywood ribs, placed them a distance apart, then sheeted them, you would get the equivalent of what a Panel represents.

from hotwing_core import Coordinate
from hotwing_core import Profile
from hotwing_core import Rib
from hotwing_core import Panel

## Create Root Rib
r1 = Rib("http://airfoiltools.com/airfoil/seligdatfile?airfoil=s6063-il",
        scale=10,
        xy_offset=None,
        top_sheet=0.0625,
        bottom_sheet=0.0625,
        front_stock=0.5,
        tail_stock=1.25 )

## Create Tip Rib   
r2 = Rib("http://airfoiltools.com/airfoil/seligdatfile?airfoil=rg14-il",
        scale=10,
        xy_offset=Coordinate(0, 0),
        top_sheet=0.0625,
        bottom_sheet=0.0625,
        front_stock=0.5,
        tail_stock=1.25 )

# Setup Panel - takes the two ribs, at a specified distance of 24 units (inches or centimeters)
p = Panel(r1, r2, 24)

# A Panel can be trimmed.  Say for example, the machine you will be using to cut your wing will
# only cut wings up to 12 units.  We can use the Panel.trim_panel classmethod to create a new,
# Panel.  The trim_panel will handle the interpolation and creation of a new Rib and Panel.
p1 = Panel.trim_panel(p, 0, 12)# cut at 0 (no cut will occur) and at 12 - new panel is 12 units long.
p2 = Panel.trim_panel(p, 12, 24)# cut at 12 and at 24 (no cut will occur) - new panel is 12 units long.

Docs: https://jasonhamilton.github.io/hotwing-core/panel.html

Machine

A Machine is a representation of the 4-Axis CNC hotwire foam cutting machine. You pass the Machine a Panel object and the Machine will handle generating the Gcode for you.

from hotwing_core import Machine


# Setup Machine
m = Machine(24,                           # Width between pillars of machine
            kerf=0.075,                   # Allowance for wire size and melted foam
            profile_points=200,           # number of points to use for each surface when 
                                          #  iterpolating
            )

# Load panel into machine (p1 is the panel created in the previous step)
# The offset is the distance the left of the panel will be from the left of the machine --
#     If you want it centered, for this example use an offset of 6 -- 
#        (24-12[machine width-panel width]) -> 12/2(equal amount on each side)
m.load_panel(panel=p1,left_offset=6)

# Generate GCode
# safe_height is where the machine can move without hitting anything
gcode = m.generate_gcode(safe_height=5)

# Output to screen
print gcode

Docs: https://jasonhamilton.github.io/hotwing-core/machine.html

Putting it All Together

from hotwing_core import Profile
from hotwing_core import Rib
from hotwing_core import Machine
from hotwing_core import Panel
from hotwing_core import Coordinate

## Setup Rib
r1 = Rib("http://airfoiltools.com/airfoil/seligdatfile?airfoil=s6063-il",
         scale=10,
         xy_offset=None,
         top_sheet=0.0625,
         bottom_sheet=0.0625,
         front_stock=0.5,
         tail_stock=1.25 )
         
r2 = Rib("http://airfoiltools.com/airfoil/seligdatfile?airfoil=rg14-il",
         scale=10,
         xy_offset=Coordinate(0, 0),
         top_sheet=0.0625,
         bottom_sheet=0.0625,
         front_stock=0.5,
         tail_stock=1.25 )

# Setup Panel
p = Panel(r1, r2, 24)

# Trim Panel
p1 = Panel.trim(p, 0, 12)

# Setup Machine
m = Machine(24, kerf=0.075, profile_points=200)

# Load panel into machine
m.load_panel(panel=p1,left_offset=6)
m.gcode_formatter_name = "debug"

# Generate GCode
gcode = m.generate_gcode(safe_height=5)

# Output to screen
print(gcode)

Testing

Tests are located in the test folder. Make sure you have the dependencies in requirements_dev.txt installed.

From the root folder (hotwing-core) run:

# Run all tests
pytest

# Run tests but allow print statements to output text - useful for debugging
pytest -s

# Run tests and show coverage
pytest --cov=hotwing_core

# Run tests, show coverage and show lines not covered by tests
pytest --cov=hotwing_core --cov-report term-missing

hotwing-core's People

Contributors

jasonhamilton avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

hotwing-core's Issues

Full code output

Can you write a output mode where you output all 4 axes of the GCode?
Like:
G00 X0 Y0 Z0 U0
G01 X1 Y0 Z0 U0

not like:
G00 X0 Y0 Z0 U0
G01 X1

Fuse cutting

Hello Jason,
after your help I can cut really pretty wings with your software. My next step would be to cut fuselage sections. For the prof of concept i started with a circle but the interpolation of the top surface is not correct. I will attache a screenshot of the Grbl Controller and my .dat file with the coordinates.

Maybe you find the solution for this problem?
image

former1.dat.txt

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.