def __init__(self): super().__init__() self.model = Hopper() self.__setOptimizationParams__(total_duration=0.4, epsilon=0.) self.opti = ca.Opti() self.var_dt = False self.__setVariables__() self.__setConstraints__() self.__setCosts__()
def main(): theCompressor = Compresser() # create a Compressor object theHopper = Hopper() # create a Hopper object theHopper.fill_coal() # fill out the Hopper object with coal # loop through and have the Compressor object take coal out of the Hopper # and compress it. for i in range(10): print(theHopper) theCompressor.get_coal(theHopper) theCompressor.compress() print(theCompressor)
def __init__(self, db, interface, related_interface, sniffer_name, enable_hopping, use_24=True, use_pop5=False): self.db = db self.sniffer_name = sniffer_name self.interface = interface self.enable_hopping = enable_hopping # Check interface existance if not self._iface_exists(interface): print "Exiting: Interface %s doesn't exist" % interface sys.exit(1) if related_interface and not self._iface_exists(related_interface): print "Exiting: Related interface %s doesn't exist" % interface sys.exit(1) # Logging header = 'SNIFF' if sniffer_name: header += '_' + sniffer_name self.log = Log(self.db, use_stdout=True, header=header) # Submodules self.packet_parser = PacketParser(self.log) self.hopper = Hopper(self.log, interface, related_interface) ret = self.hopper.configure(use_24=use_24, use_pop5=use_pop5) if ret is False: sys.exit(1) config.conf.sniff_promisc = 0 self.log.info("Promiscuous mode disabled") self.watchdog = WatchDog(interval=20)
# local endpoint when running trained brain locally in docker container url = "http://localhost:5000/v1/prediction" response = requests.get(url, json=state) action = response.json() return action if __name__ == '__main__': logging.basicConfig() log = logging.getLogger("hopper") log.setLevel(level='DEBUG') # we will use our environment (wrapper of OpenAI env) hopper = Hopper(iteration_limit=1000) # setting initial camera position hopper.initialize_camera(distance=2, yaw=10, pitch=-20) <<<<<<< HEAD ======= # setting initial camera position hopper.initialize_camera(distance=2, yaw=10, pitch=-20) >>>>>>> a7a19c68ba9116d31ce4ce6aa41b78dcd515d250 # specify which agent you want to use, # BonsaiAgent that uses trained Brain or # RandomAgent that randomly selects next action agent = BonsaiAgent()
import sys sys.path.append('../libs') import numpy as np from hopper import Hopper #raw_traj = np.array([[0,1,1.5,2,3,5,6,7,9,10], [0, 0.18559, 0.1813, 0.1921, 0.273, 0.567, 0.784, 0.674, 0.9373, 0.8389], [1.483, 2.485, 0.792, 1.13, 4.21, 11.78, 18.292, 8.11, 9.32, 12.31], [10.483, 21.485, 9.792, 21.13, 24.21, 31.78, 38.292, 28.11, 19.32, 112.31]]) test_hopper = Hopper()
from math import sqrt from hopper import Hopper from hopperUtil import * desiredPrecision = 2 N = 25 tf = 2*1.6 legLength = 0.16 r0 = [0, legLength/2] rf = [1.0, legLength] v0 = [0, 0] w0 = 0 hipOffset = {'front': {'x': 0.5, 'z': -0.25}, 'hind': {'x': -0.5, 'z': -0.25}} matlab_hopper = eng.Hopper(legLength, hipOffset) hop = Hopper(N, eng, matlab_hopper) # hop.mdt_precision = int(ceil(-np.log2(desiredPrecision))) hop.dtBounds = tuple((1/sqrt(legLength/9.81))*np.array([0.05, 0.2])) hop.dtNom = 0.04*(1/sqrt(legLength/9.81)) hop.rotationMax = np.pi/8 hop.nOrientationSectors = 1 #int(floor(np.pi/8/desiredPrecision)) print 'hop.nOrientationSectors = %d' % hop.nOrientationSectors hop.velocityMax = 3. hop.positionMax = 1.5*rf[0]/legLength hop.forceMax = 3. hop.angularVelocityMax = 5. addThreePlatfomWorld(hop, legLength, 0.3*legLength) #addFlatWorld(hop, legLength) hop.constructVisualizer() m_nlp = hop.constructPyomoModel() def normL2(m, var):