code
stringlengths
66
870k
docstring
stringlengths
19
26.7k
func_name
stringlengths
1
138
language
stringclasses
1 value
repo
stringlengths
7
68
path
stringlengths
5
324
url
stringlengths
46
389
license
stringclasses
7 values
def show_histogram(self, tub_paths, record_name, out): """ Produce a histogram of record type frequency in the given tub """ import pandas as pd from matplotlib import pyplot as plt from donkeycar.parts.tub_v2 import Tub output = out or os.path.basename(tub_paths...
Produce a histogram of record type frequency in the given tub
show_histogram
python
autorope/donkeycar
donkeycar/management/base.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/management/base.py
MIT
def get_activations(self, image_path, model_path, cfg): ''' Extracts features from an image returns activations/features ''' from tensorflow.python.keras.models import load_model, Model model_path = os.path.expanduser(model_path) image_path = os.path.expanduser(...
Extracts features from an image returns activations/features
get_activations
python
autorope/donkeycar
donkeycar/management/base.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/management/base.py
MIT
def plot_predictions(self, cfg, tub_paths, model_path, limit, model_type, noshow, dark=False): """ Plot model predictions for angle and throttle against data from tubs. """ import matplotlib.pyplot as plt import pandas as pd from pathlib import Pa...
Plot model predictions for angle and throttle against data from tubs.
plot_predictions
python
autorope/donkeycar
donkeycar/management/base.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/management/base.py
MIT
def execute_from_command_line(): """ This is the function linked to the "donkey" terminal command. """ commands = { 'createcar': CreateCar, 'findcar': FindCar, 'calibrate': CalibrateCar, 'tubplot': ShowPredictionPlots, 'tubhist': ShowHistogram, 'makemovie'...
This is the function linked to the "donkey" terminal command.
execute_from_command_line
python
autorope/donkeycar
donkeycar/management/base.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/management/base.py
MIT
def apply_modifications(model, custom_objects=None): """Applies modifications to the model layers to create a new Graph. For example, simply changing `model.layers[idx].activation = new activation` does not change the graph. The entire graph needs to be updated with modified inbound and outbound tensors...
Applies modifications to the model layers to create a new Graph. For example, simply changing `model.layers[idx].activation = new activation` does not change the graph. The entire graph needs to be updated with modified inbound and outbound tensors because of change in layer building function. Args...
apply_modifications
python
autorope/donkeycar
donkeycar/management/makemovie.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/management/makemovie.py
MIT
def normalize(array, min_value=0., max_value=1.): """Normalizes the numpy array to (min_value, max_value) Args: array: The numpy array min_value: The min value in normalized array (Default value = 0) max_value: The max value in normalized array (Default value = 1) Returns: ...
Normalizes the numpy array to (min_value, max_value) Args: array: The numpy array min_value: The min value in normalized array (Default value = 0) max_value: The max value in normalized array (Default value = 1) Returns: The array normalized to range between (min_value, max_val...
normalize
python
autorope/donkeycar
donkeycar/management/makemovie.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/management/makemovie.py
MIT
def run(self, args, parser): ''' Load the images from a tub and create a movie from them. Movie ''' try: import moviepy.editor as mpy except ImportError as e: logger.error(f'Please install moviepy first: {e}') return if args.tu...
Load the images from a tub and create a movie from them. Movie
run
python
autorope/donkeycar
donkeycar/management/makemovie.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/management/makemovie.py
MIT
def draw_user_input(self, record, img, img_drawon): """ Draw the user input as a green line on the image """ user_angle = float(record["user/angle"]) user_throttle = float(record["user/throttle"]) green = (0, 255, 0) self.draw_line_into_image(user_angle, user_thro...
Draw the user input as a green line on the image
draw_user_input
python
autorope/donkeycar
donkeycar/management/makemovie.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/management/makemovie.py
MIT
def draw_model_prediction(self, img, img_drawon): """ query the model for it's prediction, draw the predictions as a blue line on the image """ if self.keras_part is None: return expected = tuple(self.keras_part.get_input_shape('img_in')[1:]) actual =...
query the model for it's prediction, draw the predictions as a blue line on the image
draw_model_prediction
python
autorope/donkeycar
donkeycar/management/makemovie.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/management/makemovie.py
MIT
def draw_steering_distribution(self, img, img_drawon): """ query the model for it's prediction, draw the distribution of steering choices, only for model type of Keras Categorical """ from donkeycar.parts.keras import KerasCategorical if self.keras_part is None or type(s...
query the model for it's prediction, draw the distribution of steering choices, only for model type of Keras Categorical
draw_steering_distribution
python
autorope/donkeycar
donkeycar/management/makemovie.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/management/makemovie.py
MIT
def make_frame(self, t): ''' Callback to return an image from from our tub records. This is called from the VideoClip as it references a time. We don't use t to reference the frame, but instead increment a frame counter. This assumes sequential access. ''' if sel...
Callback to return an image from from our tub records. This is called from the VideoClip as it references a time. We don't use t to reference the frame, but instead increment a frame counter. This assumes sequential access.
make_frame
python
autorope/donkeycar
donkeycar/management/makemovie.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/management/makemovie.py
MIT
def decompose(field): """ Function to decompose a string vector field like 'gyroscope_1' into a tuple ('gyroscope', 1) """ field_split = field.split('_') if len(field_split) > 1 and field_split[-1].isdigit(): return '_'.join(field_split[:-1]), int(field_split[-1]) return field, None
Function to decompose a string vector field like 'gyroscope_1' into a tuple ('gyroscope', 1)
decompose
python
autorope/donkeycar
donkeycar/management/ui/common.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/management/ui/common.py
MIT
def update(self, record): """ This function is called everytime the current record is updated""" if not record: return field, index = decompose(self.field) if not field in record.underlying: Logger.error(f'Record: Bad record {record.underlying["_index"]} - ' ...
This function is called everytime the current record is updated
update
python
autorope/donkeycar
donkeycar/management/ui/common.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/management/ui/common.py
MIT
def add_remove(self): """ Method to add or remove a LabelBar. Depending on the value of the drop down menu the LabelBar is added if it is not present otherwise removed.""" field = self.ids.data_spinner.text if field is LABEL_SPINNER_TEXT: return if fie...
Method to add or remove a LabelBar. Depending on the value of the drop down menu the LabelBar is added if it is not present otherwise removed.
add_remove
python
autorope/donkeycar
donkeycar/management/ui/common.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/management/ui/common.py
MIT
def update(self, record): """ This method is called every time a record gets updated. """ try: img_arr = self.get_image(record) pil_image = PilImage.fromarray(img_arr) bytes_io = io.BytesIO() pil_image.save(bytes_io, format='png') bytes_io.seek...
This method is called every time a record gets updated.
update
python
autorope/donkeycar
donkeycar/management/ui/common.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/management/ui/common.py
MIT
def start(self, fwd=True, continuous=False): """ Method to cycle through records if either single <,> or continuous <<, >> buttons are pressed :param fwd: If we go forward or backward :param continuous: If we do <<, >> or <, > :return: None """...
Method to cycle through records if either single <,> or continuous <<, >> buttons are pressed :param fwd: If we go forward or backward :param continuous: If we do <<, >> or <, > :return: None
start
python
autorope/donkeycar
donkeycar/management/ui/common.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/management/ui/common.py
MIT
def step(self, fwd=True, continuous=False, *largs): """ Updating a single step and cap/floor the index so we stay w/in the tub. :param fwd: If we go forward or backward :param continuous: If we are in continuous mode <<, >> :param largs: dummy :return: ...
Updating a single step and cap/floor the index so we stay w/in the tub. :param fwd: If we go forward or backward :param continuous: If we are in continuous mode <<, >> :param largs: dummy :return: None
step
python
autorope/donkeycar
donkeycar/management/ui/common.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/management/ui/common.py
MIT
def update_speed(self, up=True): """ Method to update the speed on the controller""" values = self.ids.control_spinner.values idx = values.index(self.ids.control_spinner.text) if up and idx < len(values) - 1: self.ids.control_spinner.text = values[idx + 1] elif not up...
Method to update the speed on the controller
update_speed
python
autorope/donkeycar
donkeycar/management/ui/common.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/management/ui/common.py
MIT
def set_button_status(self, disabled=True): """ Method to disable(enable) all buttons. """ self.ids.run_bwd.disabled = self.ids.run_fwd.disabled = \ self.ids.step_fwd.disabled = self.ids.step_bwd.disabled = disabled
Method to disable(enable) all buttons.
set_button_status
python
autorope/donkeycar
donkeycar/management/ui/common.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/management/ui/common.py
MIT
def on_keyboard(self, keyboard, scancode, text=None, modifier=None): """ Method to check with keystroke has been sent. """ if text == ' ': if self.clock and self.clock.is_triggered: self.stop() self.set_button_status(disabled=False) status('Don...
Method to check with keystroke has been sent.
on_keyboard
python
autorope/donkeycar
donkeycar/management/ui/common.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/management/ui/common.py
MIT
def on_model_type(self, obj, model_type): """ Kivy method that is called if self.model_type changes. """ if self.model_type and self.model_type != 'Model type': # we cannot use get_app_screen() here as the app is not # completely build when we are entering this the first time ...
Kivy method that is called if self.model_type changes.
on_model_type
python
autorope/donkeycar
donkeycar/management/ui/pilot_screen.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/management/ui/pilot_screen.py
MIT
def map_pilot_field(self, text): """ Method to return user -> pilot mapped fields except for the initial value called Add/remove. """ if text == LABEL_SPINNER_TEXT: return text return rc_handler.data['user_pilot_map'][text]
Method to return user -> pilot mapped fields except for the initial value called Add/remove.
map_pilot_field
python
autorope/donkeycar
donkeycar/management/ui/pilot_screen.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/management/ui/pilot_screen.py
MIT
def on_index(self, obj, index): """ Kivy method that is called if self.index changes. Here we update self.current_record and the slider value. """ if get_app_screen('tub').ids.tub_loader.records: self.current_record \ = get_app_screen('tub').ids.tub_loader.records...
Kivy method that is called if self.index changes. Here we update self.current_record and the slider value.
on_index
python
autorope/donkeycar
donkeycar/management/ui/pilot_screen.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/management/ui/pilot_screen.py
MIT
def on_current_record(self, obj, record): """ Kivy method that is called when self.current_index changes. Here we update the images and the control panel entry.""" if not record: return i = record.underlying['_index'] self.ids.pilot_control.record_display = f"Reco...
Kivy method that is called when self.current_index changes. Here we update the images and the control panel entry.
on_current_record
python
autorope/donkeycar
donkeycar/management/ui/pilot_screen.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/management/ui/pilot_screen.py
MIT
def create_field_properties(self): """ Merges known field properties with the ones from the file """ field_properties = {entry.field: entry for entry in self.known_entries} field_list = self.data.get('field_mapping') if field_list is None: field_list = {} for entry in...
Merges known field properties with the ones from the file
create_field_properties
python
autorope/donkeycar
donkeycar/management/ui/rc_file_handler.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/management/ui/rc_file_handler.py
MIT
def load_action(self): """ Load the config from the file path""" if not self.file_path: return try: path = os.path.join(self.file_path, 'config.py') new_conf = load_config(path) self.config = new_conf # If load successful, store into ap...
Load the config from the file path
load_action
python
autorope/donkeycar
donkeycar/management/ui/tub_screen.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/management/ui/tub_screen.py
MIT
def load_action(self): """ Update tub from the file path""" if self.update_tub(): # If update successful, store into app config rc_handler.data['last_tub'] = self.file_path
Update tub from the file path
load_action
python
autorope/donkeycar
donkeycar/management/ui/tub_screen.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/management/ui/tub_screen.py
MIT
def set_lr(self, is_l=True): """ Sets left or right range to the current tub record index """ if not get_app_screen('tub').current_record: return self.lr[0 if is_l else 1] \ = get_app_screen('tub').current_record.underlying['_index']
Sets left or right range to the current tub record index
set_lr
python
autorope/donkeycar
donkeycar/management/ui/tub_screen.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/management/ui/tub_screen.py
MIT
def del_lr(self, is_del): """ Deletes or restores records in chosen range """ tub = get_app_screen('tub').ids.tub_loader.tub if self.lr[1] >= self.lr[0]: selected = list(range(*self.lr)) else: last_id = tub.manifest.current_index selected = list(range(...
Deletes or restores records in chosen range
del_lr
python
autorope/donkeycar
donkeycar/management/ui/tub_screen.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/management/ui/tub_screen.py
MIT
def create_filter_string(filter_text, record_name='record'): """ Converts text like 'user/angle' into 'record.underlying['user/angle'] so that it can be used in a filter. Will replace only expressions that are found in the tub inputs list. :param filter_text: input text like 'user/throt...
Converts text like 'user/angle' into 'record.underlying['user/angle'] so that it can be used in a filter. Will replace only expressions that are found in the tub inputs list. :param filter_text: input text like 'user/throttle > 0.1' :param record_name: name of the record in the express...
create_filter_string
python
autorope/donkeycar
donkeycar/management/ui/tub_screen.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/management/ui/tub_screen.py
MIT
def plot_from_current_bars(self, in_app=True): """ Plotting from current selected bars. The DataFrame for plotting should contain all bars except for strings fields and all data is selected if bars are empty. """ tub = get_app_screen('tub').ids.tub_loader.tub field_map =...
Plotting from current selected bars. The DataFrame for plotting should contain all bars except for strings fields and all data is selected if bars are empty.
plot_from_current_bars
python
autorope/donkeycar
donkeycar/management/ui/tub_screen.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/management/ui/tub_screen.py
MIT
def unravel_vectors(self): """ Unravels vector and list entries in tub which are created when the DataFrame is created from a list of records""" manifest = get_app_screen('tub').ids.tub_loader.tub.manifest for k, v in zip(manifest.inputs, manifest.types): if v == 'vector'...
Unravels vector and list entries in tub which are created when the DataFrame is created from a list of records
unravel_vectors
python
autorope/donkeycar
donkeycar/management/ui/tub_screen.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/management/ui/tub_screen.py
MIT
def update_dataframe_from_tub(self): """ Called from TubManager when a tub is reloaded/recreated. Fills the DataFrame from records, and updates the dropdown menu in the data panel.""" tub_screen = get_app_screen('tub') generator = (t.underlying for t in tub_screen.ids.tub...
Called from TubManager when a tub is reloaded/recreated. Fills the DataFrame from records, and updates the dropdown menu in the data panel.
update_dataframe_from_tub
python
autorope/donkeycar
donkeycar/management/ui/tub_screen.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/management/ui/tub_screen.py
MIT
def on_index(self, obj, index): """ Kivy method that is called if self.index changes""" if index >= 0: self.current_record = self.ids.tub_loader.records[index] self.ids.slider.value = index
Kivy method that is called if self.index changes
on_index
python
autorope/donkeycar
donkeycar/management/ui/tub_screen.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/management/ui/tub_screen.py
MIT
def on_current_record(self, obj, record): """ Kivy method that is called if self.current_record changes.""" self.ids.img.update(record) i = record.underlying['_index'] self.ids.control_panel.record_display = f"Record {i:06}"
Kivy method that is called if self.current_record changes.
on_current_record
python
autorope/donkeycar
donkeycar/management/ui/tub_screen.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/management/ui/tub_screen.py
MIT
def duty_cycle(pulse_ms:float, frequency_hz:float) -> float: """ Calculate the duty cycle, 0 to 1, of a pulse given the frequency and the pulse length :param pulse_ms:float the desired pulse length in milliseconds :param frequency_hz:float the pwm frequency in hertz :return:float duty cycle in ...
Calculate the duty cycle, 0 to 1, of a pulse given the frequency and the pulse length :param pulse_ms:float the desired pulse length in milliseconds :param frequency_hz:float the pwm frequency in hertz :return:float duty cycle in range 0 to 1
duty_cycle
python
autorope/donkeycar
donkeycar/parts/actuator.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/actuator.py
MIT
def pulse_ms(pulse_bits:int) -> float: """ Calculate pulse width in milliseconds given a 12bit pulse (as a PCA9685 would use). Donkeycar throttle and steering PWM values are based on PCA9685 12bit pulse values, where 0 is zero duty cycle and 4095 is 100% duty cycle. :param pulse_bits:int 12...
Calculate pulse width in milliseconds given a 12bit pulse (as a PCA9685 would use). Donkeycar throttle and steering PWM values are based on PCA9685 12bit pulse values, where 0 is zero duty cycle and 4095 is 100% duty cycle. :param pulse_bits:int 12bit integer in range 0 to 4095 :return:flo...
pulse_ms
python
autorope/donkeycar
donkeycar/parts/actuator.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/actuator.py
MIT
def set_pulse(self, pulse:int) -> None: """ Set the length of the pulse using a 12 bit integer (0..4095) :param pulse:int 12bit integer (0..4095) """ if pulse < 0 or pulse > 4095: logging.error("pulse must be in range 0 to 4095") pulse = clamp(pulse, 0, 40...
Set the length of the pulse using a 12 bit integer (0..4095) :param pulse:int 12bit integer (0..4095)
set_pulse
python
autorope/donkeycar
donkeycar/parts/actuator.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/actuator.py
MIT
def read_pwm(self): ''' send read requests via i2c bus to Teensy to get pwm control values from last RC input ''' h1 = self.pwm._device.readU8(self.register) # first byte of header must be 100, otherwize we might be reading # in the wrong byte offset whi...
send read requests via i2c bus to Teensy to get pwm control values from last RC input
read_pwm
python
autorope/donkeycar
donkeycar/parts/actuator.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/actuator.py
MIT
def run(self, speed): ''' Update the speed of the motor where 1 is full forward and -1 is full backwards. ''' if speed > 1 or speed < -1: raise ValueError( "Speed must be between 1(forward) and -1(reverse)") self.speed = speed self.throttle = ...
Update the speed of the motor where 1 is full forward and -1 is full backwards.
run
python
autorope/donkeycar
donkeycar/parts/actuator.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/actuator.py
MIT
def __init__(self, pin_forward:OutputPin, pin_backward:OutputPin, pwm_pin:PwmPin, zero_throttle:float=0, max_duty=0.9): """ :param pin_forward:OutputPin when HIGH the motor will turn clockwise using the output of the pwm_pin as a duty_cycle :param pin_backward:OutputPin w...
:param pin_forward:OutputPin when HIGH the motor will turn clockwise using the output of the pwm_pin as a duty_cycle :param pin_backward:OutputPin when HIGH the motor will turn counter-clockwise using the output of the pwm_pin as a duty_cycle ...
__init__
python
autorope/donkeycar
donkeycar/parts/actuator.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/actuator.py
MIT
def run(self, throttle:float) -> None: """ Update the speed of the motor :param throttle:float throttle value in range -1 to 1, where 1 is full forward and -1 is full backwards. """ if throttle is None: logger.warning("TwoWheelSteeringThrottle ...
Update the speed of the motor :param throttle:float throttle value in range -1 to 1, where 1 is full forward and -1 is full backwards.
run
python
autorope/donkeycar
donkeycar/parts/actuator.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/actuator.py
MIT
def run(self, throttle:float, steering:float) -> Tuple[float, float]: """ :param throttle:float throttle value in range -1 to 1, where 1 is full forward and -1 is full backwards. :param steering:float steering value in range -1 to 1, where -1 is fu...
:param throttle:float throttle value in range -1 to 1, where 1 is full forward and -1 is full backwards. :param steering:float steering value in range -1 to 1, where -1 is full left and 1 is full right. :return: tuple of left motor and right motor...
run
python
autorope/donkeycar
donkeycar/parts/actuator.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/actuator.py
MIT
def __init__(self, pin_forward:PwmPin, pin_backward:PwmPin, zero_throttle:float=0, max_duty = 0.9): """ pin_forward:PwmPin Takes a duty cycle in the range of 0 to 1, where 0 is fully off and 1 is fully on. When the duty_cycle > 0 the motor will turn clockw...
pin_forward:PwmPin Takes a duty cycle in the range of 0 to 1, where 0 is fully off and 1 is fully on. When the duty_cycle > 0 the motor will turn clockwise proportial to the duty_cycle pin_backward:PwmPin Takes a duty cycle in the ...
__init__
python
autorope/donkeycar
donkeycar/parts/actuator.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/actuator.py
MIT
def run(self, throttle:float) -> None: """ Update the speed of the motor :param throttle:float throttle value in range -1 to 1, where 1 is full forward and -1 is full backwards. """ if throttle is None: logger.warning("TwoWheelSteeringThrottle ...
Update the speed of the motor :param throttle:float throttle value in range -1 to 1, where 1 is full forward and -1 is full backwards.
run
python
autorope/donkeycar
donkeycar/parts/actuator.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/actuator.py
MIT
def run(self, pulse): ''' Update the speed of the motor where 1 is full forward and -1 is full backwards. ''' # I've read 90 is a good max self.throttle = dk.map_frange(pulse, -1.0, 1.0, self.min, self.max) # logger.debug(pulse, self.throttle) self.pwm.Cha...
Update the speed of the motor where 1 is full forward and -1 is full backwards.
run
python
autorope/donkeycar
donkeycar/parts/actuator.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/actuator.py
MIT
def __init__(self, states): ''' expects a list of strings to enumerate state ''' print("bvh states:", states) self.states = states self.active_state = 0 self.one_hot_state_array = [] for i in range(len(states)): self.one_hot_state_array.append(...
expects a list of strings to enumerate state
__init__
python
autorope/donkeycar
donkeycar/parts/behavior.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/behavior.py
MIT
def __init__(self, image_w=160, image_h=120, image_d=3, capture_width=3280, capture_height=2464, framerate=60, gstreamer_flip=0): ''' gstreamer_flip = 0 - no flip gstreamer_flip = 1 - rotate CCW 90 gstreamer_flip = 2 - flip vertically gstreamer_flip = 3 - rotate CW 90 '''...
gstreamer_flip = 0 - no flip gstreamer_flip = 1 - rotate CCW 90 gstreamer_flip = 2 - flip vertically gstreamer_flip = 3 - rotate CW 90
__init__
python
autorope/donkeycar
donkeycar/parts/camera.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/camera.py
MIT
def init(self): """ Query available buttons and axes given a path in the linux device tree. """ try: from fcntl import ioctl except ModuleNotFoundError: self.num_axes = 0 self.num_buttons = 0 logger.warning("no support for f...
Query available buttons and axes given a path in the linux device tree.
init
python
autorope/donkeycar
donkeycar/parts/controller.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/controller.py
MIT
def show_map(self): ''' list the buttons and axis found on this joystick ''' print ('%d axes found: %s' % (self.num_axes, ', '.join(self.axis_map))) print ('%d buttons found: %s' % (self.num_buttons, ', '.join(self.button_map)))
list the buttons and axis found on this joystick
show_map
python
autorope/donkeycar
donkeycar/parts/controller.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/controller.py
MIT
def poll(self): ''' query the state of the joystick, returns button which was pressed, if any, and axis which was moved, if any. button_state will be None, 1, or 0 if no changes, pressed, or released. axis_val will be a float from -1 to +1. button and axis will be the string labe...
query the state of the joystick, returns button which was pressed, if any, and axis which was moved, if any. button_state will be None, 1, or 0 if no changes, pressed, or released. axis_val will be a float from -1 to +1. button and axis will be the string label determined by the axis ma...
poll
python
autorope/donkeycar
donkeycar/parts/controller.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/controller.py
MIT
def pulse_width(self, high): """ :return: the PWM pulse width in microseconds. """ if high is not None: return high else: return 0.0
:return: the PWM pulse width in microseconds.
pulse_width
python
autorope/donkeycar
donkeycar/parts/controller.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/controller.py
MIT
def run(self, mode=None, recording=None): """ :param mode: default user/mode :param recording: default recording mode """ i = 0 for channel in self.channels: # signal is a value in [0, (MAX_OUT-MIN_OUT)] self.signals[i] = (self.pulse_width(channel...
:param mode: default user/mode :param recording: default recording mode
run
python
autorope/donkeycar
donkeycar/parts/controller.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/controller.py
MIT
def print_controls(self): ''' print the mapping of buttons and axis to functions ''' pt = PrettyTable() pt.field_names = ["control", "action"] for button, control in self.button_down_trigger_map.items(): pt.add_row([button, control.__name__]) for axis,...
print the mapping of buttons and axis to functions
print_controls
python
autorope/donkeycar
donkeycar/parts/controller.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/controller.py
MIT
def on_throttle_changes(self): ''' turn on recording when non zero throttle in the user mode. ''' if self.auto_record_on_throttle: recording = (abs(self.throttle) > self.dead_zone and self.mode == 'user') if recording != self.recording: self.record...
turn on recording when non zero throttle in the user mode.
on_throttle_changes
python
autorope/donkeycar
donkeycar/parts/controller.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/controller.py
MIT
def emergency_stop(self): ''' initiate a series of steps to try to stop the vehicle as quickly as possible ''' logger.warning('E-Stop!!!') self.mode = "user" self.recording = False self.constant_throttle = False self.estop_state = self.ES_START sel...
initiate a series of steps to try to stop the vehicle as quickly as possible
emergency_stop
python
autorope/donkeycar
donkeycar/parts/controller.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/controller.py
MIT
def toggle_mode(self): ''' switch modes from: user: human controlled steer and throttle local_angle: ai steering, human throttle local: ai steering, ai throttle ''' if self.mode == 'user': self.mode = 'local_angle' elif self.mode == 'local_angl...
switch modes from: user: human controlled steer and throttle local_angle: ai steering, human throttle local: ai steering, ai throttle
toggle_mode
python
autorope/donkeycar
donkeycar/parts/controller.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/controller.py
MIT
def run_threaded(self, img_arr=None, mode=None, recording=None): """ :param img_arr: current camera image or None :param mode: default user/mode :param recording: default recording mode """ self.img_arr = img_arr # # enforce defaults if they are not none....
:param img_arr: current camera image or None :param mode: default user/mode :param recording: default recording mode
run_threaded
python
autorope/donkeycar
donkeycar/parts/controller.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/controller.py
MIT
def init_trigger_maps(self): ''' init set of mapping from buttons to function calls ''' self.button_down_trigger_map = { 'select' : self.toggle_mode, 'circle' : self.toggle_manual_recording, 'triangle' : self.erase_last_N_records, 'cross' ...
init set of mapping from buttons to function calls
init_trigger_maps
python
autorope/donkeycar
donkeycar/parts/controller.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/controller.py
MIT
def init_trigger_maps(self): ''' init set of mapping from buttons to function calls ''' super(PS3JoystickSixAdController, self).init_trigger_maps() self.axis_trigger_map = { 'right_stick_horz' : self.set_steering, 'left_stick_vert' : self.set_throttle, ...
init set of mapping from buttons to function calls
init_trigger_maps
python
autorope/donkeycar
donkeycar/parts/controller.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/controller.py
MIT
def init_trigger_maps(self): ''' init set of mapping from buttons to function calls for ps4 ''' self.button_down_trigger_map = { 'share' : self.toggle_mode, 'circle' : self.toggle_manual_recording, 'triangle' : self.erase_last_N_records, '...
init set of mapping from buttons to function calls for ps4
init_trigger_maps
python
autorope/donkeycar
donkeycar/parts/controller.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/controller.py
MIT
def set_magnitude(axis_val): ''' Maps raw axis values to magnitude. ''' # Axis values range from -1. to 1. minimum = -1. maximum = 1. # Magnitude is now normalized in the range of 0 - 1. magnitude = (axis_val - minimum) / (m...
Maps raw axis values to magnitude.
set_magnitude
python
autorope/donkeycar
donkeycar/parts/controller.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/controller.py
MIT
def init_trigger_maps(self): ''' init set of mapping from buttons to function calls ''' self.button_down_trigger_map = { 'a_button': self.toggle_mode, 'b_button': self.toggle_manual_recording, 'x_button': self.erase_last_N_records, 'y_butt...
init set of mapping from buttons to function calls
init_trigger_maps
python
autorope/donkeycar
donkeycar/parts/controller.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/controller.py
MIT
def init_trigger_maps(self): ''' init set of mapping from buttons to function calls ''' super(XboxOneSwappedJoystickController, self).init_trigger_maps() # make the actual swap of the sticks self.set_axis_trigger('right_stick_horz', self.set_steering) self.set_ax...
init set of mapping from buttons to function calls
init_trigger_maps
python
autorope/donkeycar
donkeycar/parts/controller.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/controller.py
MIT
def init_trigger_maps(self): ''' init set of mapping from buttons to function calls ''' self.button_down_trigger_map = { 'start': self.toggle_mode, 'B': self.toggle_manual_recording, 'Y': self.erase_last_N_records, 'A': self.emergency_stop...
init set of mapping from buttons to function calls
init_trigger_maps
python
autorope/donkeycar
donkeycar/parts/controller.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/controller.py
MIT
def __init__(self, model_path, device_path=None): """Creates a BasicEngine with given model. Args: model_path: String, path to TF-Lite Flatbuffer file. device_path: String, if specified, bind engine with Edge TPU at device_path. Raises: ValueError: An error occurred when the output forma...
Creates a BasicEngine with given model. Args: model_path: String, path to TF-Lite Flatbuffer file. device_path: String, if specified, bind engine with Edge TPU at device_path. Raises: ValueError: An error occurred when the output format of model is invalid.
__init__
python
autorope/donkeycar
donkeycar/parts/coral.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/coral.py
MIT
def Inference(self, img): """Inference image with np array image object. This interface assumes the loaded model is trained for image classification. Args: img: numpy.array image object. Returns: List of (float) which represents inference results. Raises: RuntimeError: when...
Inference image with np array image object. This interface assumes the loaded model is trained for image classification. Args: img: numpy.array image object. Returns: List of (float) which represents inference results. Raises: RuntimeError: when tensor not a single 3 channel im...
Inference
python
autorope/donkeycar
donkeycar/parts/coral.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/coral.py
MIT
def RunInferenceWithInputTensor(self, input_tensor): """Run inference with raw input tensor. This interface requires user to process input data themselves and convert it to formatted input tensor. Args: input_tensor: numpy.array represents the input tensor. Returns: List of (float) wh...
Run inference with raw input tensor. This interface requires user to process input data themselves and convert it to formatted input tensor. Args: input_tensor: numpy.array represents the input tensor. Returns: List of (float) which represents inference. Raises: ValueError: whe...
RunInferenceWithInputTensor
python
autorope/donkeycar
donkeycar/parts/coral.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/coral.py
MIT
def __init__(self, left, right, bottom_left, bottom_right, top, bottom, fill=[255,255,255]) -> None: """ Apply a trapezoidal mask to an image, keeping image in the trapezoid and turns everything else the fill color """ self.bottom_left = bottom_left self.bottom_right = bo...
Apply a trapezoidal mask to an image, keeping image in the trapezoid and turns everything else the fill color
__init__
python
autorope/donkeycar
donkeycar/parts/cv.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/cv.py
MIT
def run(self, image): """ Apply trapezoidal mask # # # # # # # # # # # # # # xxxxxxxxxxxxxxxxxxxxxxx # xxxx ul ur xxxxxxxx min_y # xxx xxxxxxx # xx xxxxxx # x xxxxx # ll lr xx max_y ...
Apply trapezoidal mask # # # # # # # # # # # # # # xxxxxxxxxxxxxxxxxxxxxxx # xxxx ul ur xxxxxxxx min_y # xxx xxxxxxx # xx xxxxxx # x xxxxx # ll lr xx max_y
run
python
autorope/donkeycar
donkeycar/parts/cv.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/cv.py
MIT
def __init__(self, upper_left, upper_right, lower_left, lower_right, top, bottom, fill=[255,255,255]) -> None: """ Apply a trapezoidal mask to an image, where bounds are relative the the edge of the image, conserving the image pixels within the trapezoid and masking everything ...
Apply a trapezoidal mask to an image, where bounds are relative the the edge of the image, conserving the image pixels within the trapezoid and masking everything other pixels with the fill color
__init__
python
autorope/donkeycar
donkeycar/parts/cv.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/cv.py
MIT
def run(self, image): """ Apply trapezoidal mask # # # # # # # # # # # # # # xxxxxxxxxxxxxxxxxxxxxxx # xxxx ul ur xxxxxxxx min_y # xxx xxxxxxx # xx xxxxxx # x xxxxx # ll lr xx max_y ...
Apply trapezoidal mask # # # # # # # # # # # # # # xxxxxxxxxxxxxxxxxxxxxxx # xxxx ul ur xxxxxxxx min_y # xxx xxxxxxx # xx xxxxxx # x xxxxx # ll lr xx max_y
run
python
autorope/donkeycar
donkeycar/parts/cv.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/cv.py
MIT
def __init__(self, left=0, top=0, right=0, bottom=0, fill=[255, 255, 255]) -> None: """ Apply a mask to top and/or bottom of image. """ self.left = left self.top = top self.right = right self.bottom = bottom self.fill = fill self.masks = {}
Apply a mask to top and/or bottom of image.
__init__
python
autorope/donkeycar
donkeycar/parts/cv.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/cv.py
MIT
def run(self, image): """ Apply border mask # # # # # # # # # # # # # # xxxxxxxxxxxxxxxxxxxxx # # xxxxxxxxxxxxxxxxxxxxx # # xx xx # top # xx xx # # xx xx # # xxxxxxxxxxxxxxxxxxxxx # (height - bottom) ...
Apply border mask # # # # # # # # # # # # # # xxxxxxxxxxxxxxxxxxxxx # # xxxxxxxxxxxxxxxxxxxxx # # xx xx # top # xx xx # # xx xx # # xxxxxxxxxxxxxxxxxxxxx # (height - bottom) # xxxxxxxxxxxxxxxxxxxxx #...
run
python
autorope/donkeycar
donkeycar/parts/cv.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/cv.py
MIT
def __init__(self, file_path, image_w=None, image_h=None, image_d=None, copy=False): """ Part to load image from file and output as RGB image """ if file_path is None: raise ValueError("CvImage passed empty file_path") image = cv2.imread(file_path) if image i...
Part to load image from file and output as RGB image
__init__
python
autorope/donkeycar
donkeycar/parts/cv.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/cv.py
MIT
def check(self, fix=False): """ Iterate over all records and make sure we can load them. Optionally remove records that cause a problem. """ print('Checking tub:%s.' % self.path) print('Found: %d records.' % self.get_num_records()) problems = False for ix ...
Iterate over all records and make sure we can load them. Optionally remove records that cause a problem.
check
python
autorope/donkeycar
donkeycar/parts/datastore.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/datastore.py
MIT
def put_record(self, data): """ Save values like images that can't be saved in the csv log and return a record with references to the saved values that can be saved in a csv. """ json_data = {} self.current_ix += 1 for key, val in data.items(): ...
Save values like images that can't be saved in the csv log and return a record with references to the saved values that can be saved in a csv.
put_record
python
autorope/donkeycar
donkeycar/parts/datastore.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/datastore.py
MIT
def erase_last_n_records(self, num_erase): """ erase N records from the disc and move current back accordingly """ last_erase = self.current_ix first_erase = last_erase - num_erase self.current_ix = first_erase - 1 if self.current_ix < 0: self.current_...
erase N records from the disc and move current back accordingly
erase_last_n_records
python
autorope/donkeycar
donkeycar/parts/datastore.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/datastore.py
MIT
def run(self, *args): """ API function needed to use as a Donkey part. Accepts values, pairs them with their inputs keys and saves them to disk. """ assert len(self.inputs) == len(args) record = dict(zip(self.inputs, args)) self.put_record(record) return s...
API function needed to use as a Donkey part. Accepts values, pairs them with their inputs keys and saves them to disk.
run
python
autorope/donkeycar
donkeycar/parts/datastore.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/datastore.py
MIT
def run(self, *args): """ API function needed to use as a Donkey part. Accepts keys to read from the tub and retrieves them sequentially. """ record_dict = self.get_record() record = [record_dict[key] for key in args] return record
API function needed to use as a Donkey part. Accepts keys to read from the tub and retrieves them sequentially.
run
python
autorope/donkeycar
donkeycar/parts/datastore.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/datastore.py
MIT
def stack3Images(self, img_a, img_b, img_c): ''' convert 3 rgb images into grayscale and put them into the 3 channels of a single output image ''' width, height, _ = img_a.shape gray_a = self.rgb2gray(img_a) gray_b = self.rgb2gray(img_b) gray_c = self.rgb...
convert 3 rgb images into grayscale and put them into the 3 channels of a single output image
stack3Images
python
autorope/donkeycar
donkeycar/parts/datastore.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/datastore.py
MIT
def get_record(self, ix): ''' get the current record and two previous. stack the 3 images into a single image. ''' data = super(TubImageStacker, self).get_record(ix) if ix > 1: data_ch1 = super(TubImageStacker, self).get_record(ix - 1) data_ch0 = ...
get the current record and two previous. stack the 3 images into a single image.
get_record
python
autorope/donkeycar
donkeycar/parts/datastore.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/datastore.py
MIT
def __init__(self, frame_list, *args, **kwargs): ''' frame_list of [0, 10] would stack the current and 10 frames from now records togther in a single record with just the current image returned. [5, 90, 200] would return 3 frames of records, ofset 5, 90, and 200 frames in the future. ...
frame_list of [0, 10] would stack the current and 10 frames from now records togther in a single record with just the current image returned. [5, 90, 200] would return 3 frames of records, ofset 5, 90, and 200 frames in the future.
__init__
python
autorope/donkeycar
donkeycar/parts/datastore.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/datastore.py
MIT
def get_record(self, ix): ''' stack the N records into a single record. Each key value has the record index with a suffix of _N where N is the frame offset into the data. ''' data = {} for i, iOffset in enumerate(self.frame_list): iRec = ix + iOffset ...
stack the N records into a single record. Each key value has the record index with a suffix of _N where N is the frame offset into the data.
get_record
python
autorope/donkeycar
donkeycar/parts/datastore.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/datastore.py
MIT
def _update_session_info(self): """ Creates a new session id and appends it to the metadata.""" sessions = self.manifest_metadata.get('sessions', {}) if not sessions: sessions['all_full_ids'] = [] this_id, this_full_id = self.session_id sessions['last_id'] = this_id ...
Creates a new session id and appends it to the metadata.
_update_session_info
python
autorope/donkeycar
donkeycar/parts/datastore_v2.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/datastore_v2.py
MIT
def create_new_session_id(self): """ Creates a new session id and appends it to the metadata.""" sessions = self.manifest_metadata.get('sessions', {}) new_id = sessions['last_id'] + 1 if sessions else 0 new_full_id = f"{time.strftime('%y-%m-%d')}_{new_id}" return new_id, new_full...
Creates a new session id and appends it to the metadata.
create_new_session_id
python
autorope/donkeycar
donkeycar/parts/datastore_v2.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/datastore_v2.py
MIT
def close(self): """ Closing tub closes open files for catalog, catalog manifest and manifest.json""" # If records were received, write updated session_id dictionary into # the metadata, otherwise keep the session_id information unchanged if self._updated_session: ...
Closing tub closes open files for catalog, catalog manifest and manifest.json
close
python
autorope/donkeycar
donkeycar/parts/datastore_v2.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/datastore_v2.py
MIT
def __init__(self, memory, output_prefix = ""): """ Break a map into key/value pairs and write them to the output memory, optionally prefixing the key on output. Basically, take a dictionary and write it to the output. """ self.memory = memory self...
Break a map into key/value pairs and write them to the output memory, optionally prefixing the key on output. Basically, take a dictionary and write it to the output.
__init__
python
autorope/donkeycar
donkeycar/parts/explode.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/explode.py
MIT
def run(self, img_arr: np.ndarray, other_arr: List[float] = None) \ -> Tuple[Union[float, torch.tensor], ...]: """ Donkeycar parts interface to run the part in the loop. :param img_arr: uint8 [0,255] numpy array with image data :param other_arr: numpy array of addition...
Donkeycar parts interface to run the part in the loop. :param img_arr: uint8 [0,255] numpy array with image data :param other_arr: numpy array of additional data to be used in the pilot, like IMU array for the IMU model or a state v...
run
python
autorope/donkeycar
donkeycar/parts/fastai.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/fastai.py
MIT
def inference(self, img_arr: torch.tensor, other_arr: Optional[torch.tensor]) \ -> Tuple[Union[float, torch.tensor], ...]: """ Inferencing using the interpreter :param img_arr: float32 [0,1] numpy array with normalized image data :param oth...
Inferencing using the interpreter :param img_arr: float32 [0,1] numpy array with normalized image data :param other_arr: tensor array of additional data to be used in the pilot, like IMU array for the IMU model or a ...
inference
python
autorope/donkeycar
donkeycar/parts/fastai.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/fastai.py
MIT
def inference_from_dict(self, input_dict: Dict[str, np.ndarray]) \ -> Tuple[Union[float, np.ndarray], ...]: """ Inferencing using the interpreter :param input_dict: input dictionary of str and np.ndarray :return: typically tuple of (angle, throttle) """ ...
Inferencing using the interpreter :param input_dict: input dictionary of str and np.ndarray :return: typically tuple of (angle, throttle)
inference_from_dict
python
autorope/donkeycar
donkeycar/parts/fastai.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/fastai.py
MIT
def interpreter_to_output( self, interpreter_out: Sequence[Union[float, np.ndarray]]) \ -> Tuple[Union[float, np.ndarray], ...]: """ Virtual method to be implemented by child classes for conversion :param interpreter_out: input data :return: ...
Virtual method to be implemented by child classes for conversion :param interpreter_out: input data :return: output values, possibly tuple of np.ndarray
interpreter_to_output
python
autorope/donkeycar
donkeycar/parts/fastai.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/fastai.py
MIT
def run(self): ''' return True when file changed. Keep in mind that this does not mean that the file is finished with modification. ''' m_time = os.path.getmtime(self.filename) if m_time != self.modified_time: self.modified_time = m_time if self....
return True when file changed. Keep in mind that this does not mean that the file is finished with modification.
run
python
autorope/donkeycar
donkeycar/parts/file_watcher.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/file_watcher.py
MIT
def run_once(self, now): """ Collect all nmea sentences up to and including the given time """ nmea_sentences = [] if self.running: # reset start time if None if self.starttime is None: print("Resetting gps player start time.") ...
Collect all nmea sentences up to and including the given time
run_once
python
autorope/donkeycar
donkeycar/parts/gps.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/gps.py
MIT
def calculate_nmea_checksum(nmea_line): """ Given the complete nmea line (including starting '$' and ending checksum '*##') calculate the checksum from the body of the line. NOTE: this does not check for structural correctness, so you should check that '$' and '*##' checksum are present ...
Given the complete nmea line (including starting '$' and ending checksum '*##') calculate the checksum from the body of the line. NOTE: this does not check for structural correctness, so you should check that '$' and '*##' checksum are present and that the checksum matches before callin...
calculate_nmea_checksum
python
autorope/donkeycar
donkeycar/parts/gps.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/gps.py
MIT
def nmea_to_degrees(gps_str, direction): """ Convert a gps coordinate string formatted as: DDDMM.MMMMM, where DDD denotes the degrees (which may have zero to 3 digits) and MM.MMMMM denotes the minutes to a float in degrees. """ if not gps_str or gps_str == "0": return 0 ...
Convert a gps coordinate string formatted as: DDDMM.MMMMM, where DDD denotes the degrees (which may have zero to 3 digits) and MM.MMMMM denotes the minutes to a float in degrees.
nmea_to_degrees
python
autorope/donkeycar
donkeycar/parts/gps.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/gps.py
MIT
def stats(data): """ Calculate (min, max, mean, std_deviation) of a list of floats """ if not data: return None count = len(data) min = None max = None sum = 0 for x in data: if min is None or x < min: min = ...
Calculate (min, max, mean, std_deviation) of a list of floats
stats
python
autorope/donkeycar
donkeycar/parts/gps.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/gps.py
MIT
def __init__(self, samples, nstd = 1.0): """ Fit an ellipsoid to the given samples at the given multiple of the standard deviation of the samples. """ # separate out the points by axis self.x = [w[1] for w in samples] self....
Fit an ellipsoid to the given samples at the given multiple of the standard deviation of the samples.
__init__
python
autorope/donkeycar
donkeycar/parts/gps.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/gps.py
MIT
def eigsorted(cov): """ Calculate eigenvalues and eigenvectors and return them sorted by eigenvalue. """ eigenvalues, eigenvectors = np.linalg.eigh(cov) order = eigenvalues.argsort()[::-1] return eigenvalues[...
Calculate eigenvalues and eigenvectors and return them sorted by eigenvalue.
eigsorted
python
autorope/donkeycar
donkeycar/parts/gps.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/gps.py
MIT
def is_inside(self, x, y): """ Determine if the given (x,y) point is within the waypoint's fitted ellipsoid """ # if (x >= self.x_stats.min) and (x <= self.x_stats.max): # if (y >= self.y_stats.min) and (y <= self.y_stats.max): # ...
Determine if the given (x,y) point is within the waypoint's fitted ellipsoid
is_inside
python
autorope/donkeycar
donkeycar/parts/gps.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/gps.py
MIT