Skip to content

Instantly share code, notes, and snippets.

import krpc
import math
import time
# http://brettbeauregard.com/blog/2011/04/improving-the-beginners-pid-introduction/
class PIDController(object):
""" A robust PID """
def __init__(self, input, setpoint, kp, ki, kd, outmin = 0, outmax = 0):
@theodoregoetz
theodoregoetz / ctypes_mock.py
Created February 24, 2016 17:41
Python unittest.mock to handle ctypes calls to underlying native binary libraries.
import re
from ctypes import *
from nose.tools import *
from six import *
from unittest.mock import *
def ref_to_pointer(ref, ctype):
'''convert byref() object to real pointer'''
addr = int(re.search(r'(0x[\dabcdefABCDEF]+)',repr(ref)).group(1), 0)
@djungelorm
djungelorm / autopilot.py
Created February 16, 2016 02:48
kRPC AutoPilot
import krpc
import time
import numpy
import math
def main():
conn = krpc.connect()
vessel = conn.space_center.active_vessel
# Point prograde, 0 degree roll