How to use run_callback method in lisa

Best Python code snippet using lisa_python

drone_pid.py

Source:drone_pid.py Github

copy

Full Screen

...95 # If tuning roll, then also initialize gain values for roll PID controller96 roll_params = {'tau_p': 0, 'tau_d': 0, 'tau_i': 0}97 98 # Call run_callback, passing in the dicts of thrust and roll gain values99 hover_error, max_allowed_velocity, drone_max_velocity, max_allowed_oscillations, total_oscillations = run_callback(thrust_params, roll_params, VISUALIZE=VISUALIZE)100 101 # Calculate best_error from above returned values102 best_error = None103 104 # Implement your code to use twiddle to tune the params and find the best_error105 106 # Return the dict of gain values that give the best error.107 108 return thrust_params, roll_params109def find_parameters_with_int(run_callback, tune='thrust', DEBUG=False, VISUALIZE=False): 110 '''111 Student implementation of twiddle algorithm will go here. Here you can focus on 112 tuning gain values for Thrust test case with Integral error113 114 Args:115 run_callback: A handle to DroneSimulator.run() method. You should call it with your116 PID gain values that you want to test with. It returns an error value that indicates 117 how well your PID gain values followed the specified path.118 119 tune: This will be passed by the test harness. 120 A value of 'thrust' means you only need to tune gain values for thrust. 121 A value of 'both' means you need to tune gain values for both thrust and roll.122 123 DEBUG: Whether or not to output debugging statements during twiddle runs124 VISUALIZE: Whether or not to output visualizations during twiddle runs125 126 Returns:127 tuple of the thrust_params, roll_params:128 thrust_params: A dict of gain values for the thrust PID controller129 thrust_params = {'tau_p': 0.0, 'tau_d': 0.0, 'tau_i': 0.0}130 roll_params: A dict of gain values for the roll PID controller131 roll_params = {'tau_p': 0.0, 'tau_d': 0.0, 'tau_i': 0.0}132 '''133 134 # Initialize a list to contain your gain values that you want to tune, e.g.,135 params = [0,0,0]136 137 # Create dicts to pass the parameters to run_callback138 thrust_params = {'tau_p': params[0], 'tau_d': params[1], 'tau_i': params[2]}139 140 # If tuning roll, then also initialize gain values for roll PID controller141 roll_params = {'tau_p': 0, 'tau_d': 0, 'tau_i': 0}142 143 # Call run_callback, passing in the dicts of thrust and roll gain values144 hover_error, max_allowed_velocity, drone_max_velocity, max_allowed_oscillations, total_oscillations = run_callback(thrust_params, roll_params, VISUALIZE=VISUALIZE)145 146 # Calculate best_error from above returned values147 best_error = None148 149 # Implement your code to use twiddle to tune the params and find the best_error150 151 # Return the dict of gain values that give the best error.152 153 return thrust_params, roll_params154def find_parameters_with_roll(run_callback, tune='both', DEBUG=False, VISUALIZE=False): 155 '''156 Student implementation of twiddle algorithm will go here. Here you will 157 find gain values for Thrust as well as Roll PID controllers.158 159 Args:160 run_callback: A handle to DroneSimulator.run() method. You should call it with your161 PID gain values that you want to test with. It returns an error value that indicates 162 how well your PID gain values followed the specified path.163 164 tune: This will be passed by the test harness. 165 A value of 'thrust' means you only need to tune gain values for thrust. 166 A value of 'both' means you need to tune gain values for both thrust and roll.167 168 DEBUG: Whether or not to output debugging statements during twiddle runs169 VISUALIZE: Whether or not to output visualizations during twiddle runs170 171 Returns:172 tuple of the thrust_params, roll_params:173 thrust_params: A dict of gain values for the thrust PID controller174 thrust_params = {'tau_p': 0.0, 'tau_d': 0.0, 'tau_i': 0.0}175 roll_params: A dict of gain values for the roll PID controller176 roll_params = {'tau_p': 0.0, 'tau_d': 0.0, 'tau_i': 0.0}177 '''178 # Initialize a list to contain your gain values that you want to tune, e.g.,179 params = [0,0,0]180 181 # Create dicts to pass the parameters to run_callback182 thrust_params = {'tau_p': params[0], 'tau_d': params[1], 'tau_i': params[2]}183 184 # If tuning roll, then also initialize gain values for roll PID controller185 roll_params = {'tau_p': 0, 'tau_d': 0, 'tau_i': 0}186 187 # Call run_callback, passing in the dicts of thrust and roll gain values188 hover_error, max_allowed_velocity, drone_max_velocity, max_allowed_oscillations, total_oscillations = run_callback(thrust_params, roll_params, VISUALIZE=VISUALIZE)189 190 # Calculate best_error from above returned values191 best_error = None192 193 # Implement your code to use twiddle to tune the params and find the best_error194 195 # Return the dict of gain values that give the best error.196 197 return thrust_params, roll_params198def who_am_i():199 # Please specify your GT login ID in the whoami variable (ex: jsmith322).200 whoami = ''...

Full Screen

Full Screen

indiclient.py

Source:indiclient.py Github

copy

Full Screen

...31 def device_names(self):32 return [d.getDeviceName() for d in self.getDevices()]33 def newDevice(self, d):34 device = Device(d.getDeviceName(), self)35 self.run_callback('on_new_device', device)36 def removeDevice(self, d):37 self.run_callback('on_device_removed', d.getDeviceName())38 def newProperty(self, p):39 self.run_callback('on_new_property', device=p.getDeviceName(), group=p.getGroupName(), property_name=p.getName())40 def removeProperty(self, p):41 self.run_callback('on_remove_property', p)42 def newBLOB(self, bp):43 self.run_callback('on_new_blob', bp)44 def newSwitch(self, svp):45 self.run_callback('on_new_switch', svp)46 def newNumber(self, nvp):47 self.run_callback('on_new_number', nvp)48 def newText(self, tvp):49 self.run_callback('on_new_text', tvp)50 def newLight(self, lvp):51 self.run_callback('on_new_light', lvp)52 def newMessage(self, d, m):53 device = Device(d.getDeviceName(), self)54 message = device.get_queued_message(m)55 self.run_callback('on_new_message', device, message)56 def serverConnected(self):57 self.run_callback('on_server_connected') 58 def serverDisconnected(self, code):59 self.run_callback('on_server_disconnected', code)60 def run_callback(self, name, *args, **kwargs):61 callback = self.callbacks.get(name)62 if callback:63 callback(*args, **kwargs)64 def __devices_by_interface(self, interface):65 return [x.name for x in self.devices() if interface in x.interfaces]66 67 def __str__(self):68 return 'INDI client connected to {0}:{1}'.format(self.host, self.port)69 def __repr__(self):...

Full Screen

Full Screen

__init__.py

Source:__init__.py Github

copy

Full Screen

1from ..core.context import Context2from ..util import BaseList3from typing import Union, Sequence4class Callback():5 """6 Callback for running operations(training, evaluation, prediction, etc.).7 """8 def __init__(self):9 super().__init__()10 def begin(self, ctx: Context):11 pass12 def end(self, ctx: Context):13 pass14 def step_begin(self, ctx: Context):15 pass16 17 def step_end(self, ctx: Context):18 pass19 def epoch_begin(self, ctx: Context):20 pass21 def epoch_end(self, ctx: Context):22 pass23# callback or sequence of callbacks24C_SEQ = Union[Callback, Sequence[Callback]]25class CallbackContainer(Callback, BaseList):26 """27 Maintaining a list that contains callbacks, combination mode.28 """29 def __init__(self, callbacks: C_SEQ = None):30 super().__init__()31 BaseList.__init__(self, callbacks)32 def begin(self, ctx: Context):33 for run_callback in self:34 run_callback.begin(ctx)35 36 def end(self, ctx: Context):37 for run_callback in self:38 run_callback.end(ctx)39 40 def step_begin(self, ctx: Context):41 for run_callback in self:42 run_callback.step_begin(ctx)43 44 def step_end(self, ctx: Context):45 for run_callback in self:46 run_callback.step_end(ctx)47 48 def epoch_begin(self, ctx: Context):49 for run_callback in self:50 run_callback.epoch_begin(ctx)51 52 def epoch_end(self, ctx: Context):53 for run_callback in self:...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run lisa automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful