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 y_transform(self, record: Union[TubRecord, List[TubRecord]]) \ -> Dict[str, Union[float, List[float]]]: """ Transforms the record into dictionary for y for training the model to x,y. All model ouputs layer's names must be matched by dictionary keys. """ raise NotImplement...
Transforms the record into dictionary for y for training the model to x,y. All model ouputs layer's names must be matched by dictionary keys.
y_transform
python
autorope/donkeycar
donkeycar/parts/keras.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/keras.py
MIT
def output_types(self) -> Tuple[Dict[str, np.typename], ...]: """ Used in tf.data, assume all types are doubles""" shapes = self.output_shapes() types = tuple({k: tf.float64 for k in d} for d in shapes) return types
Used in tf.data, assume all types are doubles
output_types
python
autorope/donkeycar
donkeycar/parts/keras.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/keras.py
MIT
def x_transform( self, records: Union[TubRecord, List[TubRecord]], img_processor: Callable[[np.ndarray], np.ndarray]) \ -> Dict[str, Union[float, np.ndarray]]: """ Transforms the record sequence into x for training the model to x, y. """ assert isi...
Transforms the record sequence into x for training the model to x, y.
x_transform
python
autorope/donkeycar
donkeycar/parts/keras.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/keras.py
MIT
def y_transform(self, records: Union[TubRecord, List[TubRecord]]) \ -> Dict[str, Union[float, List[float]]]: """ Only return the last entry of angle/throttle""" assert isinstance(records, list), 'List[TubRecord] expected' angle = records[-1].underlying['user/angle'] throttle ...
Only return the last entry of angle/throttle
y_transform
python
autorope/donkeycar
donkeycar/parts/keras.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/keras.py
MIT
def conv2d(filters, kernel, strides, layer_num, activation='relu'): """ Helper function to create a standard valid-padded convolutional layer with square kernel and strides and unified naming convention :param filters: channel dimension of the layer :param kernel: creates (kernel, kernel) ...
Helper function to create a standard valid-padded convolutional layer with square kernel and strides and unified naming convention :param filters: channel dimension of the layer :param kernel: creates (kernel, kernel) kernel matrix dimension :param strides: creates (strides, strides) ...
conv2d
python
autorope/donkeycar
donkeycar/parts/keras.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/keras.py
MIT
def core_cnn_layers(img_in, drop, l4_stride=1): """ Returns the core CNN layers that are shared among the different models, like linear, imu, behavioural :param img_in: input layer of network :param drop: dropout rate :param l4_stride: 4-th layer stride, default 1 ...
Returns the core CNN layers that are shared among the different models, like linear, imu, behavioural :param img_in: input layer of network :param drop: dropout rate :param l4_stride: 4-th layer stride, default 1 :return: stack of CNN layers
core_cnn_layers
python
autorope/donkeycar
donkeycar/parts/keras.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/keras.py
MIT
def build_3d_cnn(input_shape, s, num_outputs): """ Credit: https://github.com/jessecha/DNRacing/blob/master/3D_CNN_Model/model.py :param input_shape: image input shape :param s: sequence length :param num_outputs: output dimension :return: keras model ""...
Credit: https://github.com/jessecha/DNRacing/blob/master/3D_CNN_Model/model.py :param input_shape: image input shape :param s: sequence length :param num_outputs: output dimension :return: keras model
build_3d_cnn
python
autorope/donkeycar
donkeycar/parts/keras.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/keras.py
MIT
def run(self, forward_distance:float, steering_angle:float, timestamp:float=None) -> Tuple[float, float, float, float, float, float, float, float, float]: """ params forward_distance: distance the reference point between the front wheels has travelled ...
params forward_distance: distance the reference point between the front wheels has travelled steering_angle: angle in radians of the front 'wheel' from forward. In this case left is positive, right is negative, ...
run
python
autorope/donkeycar
donkeycar/parts/kinematics.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/kinematics.py
MIT
def run(self, forward_velocity:float, angular_velocity:float, timestamp:float=None) -> Tuple[float, float, float]: """ @param forward_velocity:float in meters per second @param angular_velocity:float in radians per second @return tuple - forward_velocity:float in meters p...
@param forward_velocity:float in meters per second @param angular_velocity:float in radians per second @return tuple - forward_velocity:float in meters per second (basically a pass through) - steering_angle:float in radians - timestamp:float ...
run
python
autorope/donkeycar
donkeycar/parts/kinematics.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/kinematics.py
MIT
def update_bicycle_front_wheel_pose(front_wheel, wheel_base, steering_angle, distance): """ Calculates the ending position of the front wheel of a bicycle kinematics model. This is expected to be called at a high rate such that we can model the the travel as a line rather than an arc. Arguments: ...
Calculates the ending position of the front wheel of a bicycle kinematics model. This is expected to be called at a high rate such that we can model the the travel as a line rather than an arc. Arguments: front_wheel -- starting pose at front wheel as tuple of (x, y, angle) where x...
update_bicycle_front_wheel_pose
python
autorope/donkeycar
donkeycar/parts/kinematics.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/kinematics.py
MIT
def bicycle_steering_angle(wheel_base:float, forward_velocity:float, angular_velocity:float) -> float: """ Calculate bicycle steering for the vehicle from the angular velocity. For car-like vehicles, calculate the angular velocity using the bicycle model and the measured max forward velocity and max st...
Calculate bicycle steering for the vehicle from the angular velocity. For car-like vehicles, calculate the angular velocity using the bicycle model and the measured max forward velocity and max steering angle.
bicycle_steering_angle
python
autorope/donkeycar
donkeycar/parts/kinematics.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/kinematics.py
MIT
def bicycle_angular_velocity(wheel_base:float, forward_velocity:float, steering_angle:float) -> float: """ Calculate angular velocity for the vehicle from the bicycle steering angle. For car-like vehicles, calculate the angular velocity using the bicycle model and the measured max forward velocity and ...
Calculate angular velocity for the vehicle from the bicycle steering angle. For car-like vehicles, calculate the angular velocity using the bicycle model and the measured max forward velocity and max steering angle.
bicycle_angular_velocity
python
autorope/donkeycar
donkeycar/parts/kinematics.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/kinematics.py
MIT
def run(self, left_distance:float, right_distance:float, timestamp:float=None) -> Tuple[float, float, float, float, float, float, float, float, float]: """ params left_distance: distance left wheel has travelled right_distance: distance right wheel has travelled times...
params left_distance: distance left wheel has travelled right_distance: distance right wheel has travelled timestamp: time of distance readings or None to use current time returns distance velocity x is horizontal position of point...
run
python
autorope/donkeycar
donkeycar/parts/kinematics.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/kinematics.py
MIT
def run(self, forward_velocity:float, angular_velocity:float, timestamp:float=None) -> Tuple[float, float, float]: """ Convert turning velocity in radians and forward velocity (like meters per second) into left and right linear wheel speeds that result in that forward speed at that turni...
Convert turning velocity in radians and forward velocity (like meters per second) into left and right linear wheel speeds that result in that forward speed at that turning angle see http://faculty.salina.k-state.edu/tim/robotics_sg/Control/kinematics/unicycle.html#calculating-wheel-velo...
run
python
autorope/donkeycar
donkeycar/parts/kinematics.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/kinematics.py
MIT
def unicycle_angular_velocity(wheel_radius:float, axle_length:float, left_velocity:float, right_velocity:float) -> float: """ Calculate angular velocity for the unicycle vehicle. For differential drive, calculate angular velocity using the unicycle model and linear wheel velocities. """ # ...
Calculate angular velocity for the unicycle vehicle. For differential drive, calculate angular velocity using the unicycle model and linear wheel velocities.
unicycle_angular_velocity
python
autorope/donkeycar
donkeycar/parts/kinematics.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/kinematics.py
MIT
def unicycle_max_angular_velocity(wheel_radius:float, axle_length:float, max_forward_velocity:float) -> float: """ Calculate maximum angular velocity for the vehicle, so we can convert between normalized and unnormalized forms of the angular velocity. For differential drive, calculate maximum angular ve...
Calculate maximum angular velocity for the vehicle, so we can convert between normalized and unnormalized forms of the angular velocity. For differential drive, calculate maximum angular velocity using the unicycle model and assuming one one wheel is stopped and one wheel is at max velocity.
unicycle_max_angular_velocity
python
autorope/donkeycar
donkeycar/parts/kinematics.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/kinematics.py
MIT
def __init__(self, max_steering_angle:float, steering_zero:float=0.0) -> None: """ @param max_steering_angle:float measured maximum steering angle in radians @param steering_zero:float value at or below which normalized steering values are considered to be zero...
@param max_steering_angle:float measured maximum steering angle in radians @param steering_zero:float value at or below which normalized steering values are considered to be zero.
__init__
python
autorope/donkeycar
donkeycar/parts/kinematics.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/kinematics.py
MIT
def run(self, steering_angle) -> float: """ @param steering angle in radians where positive radians is a left turn, negative radians is a right turn @return a normalized steering value in range -1 to 1, where -1 is full left, corresponding to positive...
@param steering angle in radians where positive radians is a left turn, negative radians is a right turn @return a normalized steering value in range -1 to 1, where -1 is full left, corresponding to positive max_steering_angle 1 is full right...
run
python
autorope/donkeycar
donkeycar/parts/kinematics.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/kinematics.py
MIT
def run(self, steering) -> float: """ @param a normalized steering value in range -1 to 1, where -1 is full left, corresponding to positive max_steering_angle 1 is full right, corresponding to negative max_steering_angle @return steering angle in radians where ...
@param a normalized steering value in range -1 to 1, where -1 is full left, corresponding to positive max_steering_angle 1 is full right, corresponding to negative max_steering_angle @return steering angle in radians where positive radians is a left turn, ...
run
python
autorope/donkeycar
donkeycar/parts/kinematics.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/kinematics.py
MIT
def differential_steering(throttle: float, steering: float, steering_zero: float = 0) -> Tuple[float, float]: """ Turn steering angle and speed/throttle into left and right wheel speeds/throttle. This basically slows down one wheel by the steering value while leaving the other w...
Turn steering angle and speed/throttle into left and right wheel speeds/throttle. This basically slows down one wheel by the steering value while leaving the other wheel at the desired throttle. So, except for the case where the steering is zero (going straight forward), ...
differential_steering
python
autorope/donkeycar
donkeycar/parts/kinematics.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/kinematics.py
MIT
def angle_in_bounds(angle, min_angle, max_angle): """ Determine if an angle is between two other angles. """ if min_angle <= max_angle: return min_angle <= angle <= max_angle else: # If min_angle < max_angle then range crosses # zero degrees, so break up test # into t...
Determine if an angle is between two other angles.
angle_in_bounds
python
autorope/donkeycar
donkeycar/parts/lidar.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/lidar.py
MIT
def plot_line(self, img, dist, theta, max_dist, draw): ''' scale dist so that max_dist is edge of img (mm) and img is PIL Image, draw the line using the draw ImageDraw object ''' center = (img.width / 2, img.height / 2) max_pixel = min(center[0], center[1]) dist =...
scale dist so that max_dist is edge of img (mm) and img is PIL Image, draw the line using the draw ImageDraw object
plot_line
python
autorope/donkeycar
donkeycar/parts/lidar.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/lidar.py
MIT
def plot_circ(self, img, dist, theta, max_dist, draw): ''' scale dist so that max_dist is edge of img (mm) and img is PIL Image, draw the circle using the draw ImageDraw object ''' center = (img.width / 2, img.height / 2) max_pixel = min(center[0], center[1]) dist...
scale dist so that max_dist is edge of img (mm) and img is PIL Image, draw the circle using the draw ImageDraw object
plot_circ
python
autorope/donkeycar
donkeycar/parts/lidar.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/lidar.py
MIT
def run(self, distances, angles): ''' takes two lists of equal length, one of distance values, the other of angles corresponding to the dist meas ''' self.frame = Image.new('RGB', self.resolution, (255, 255, 255)) draw = ImageDraw.Draw(self.frame) self.plot_scan(...
takes two lists of equal length, one of distance values, the other of angles corresponding to the dist meas
run
python
autorope/donkeycar
donkeycar/parts/lidar.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/lidar.py
MIT
def plot_polar_point(draw_context, bounds, mark_fn, mark_color, mark_px, distance, theta, max_distance, angle_direction=COUNTER_CLOCKWISE, rotate_plot=0): ''' draw a 2d polar point to the given PIL image assuming the polar origin is at the center of bounding box ...
draw a 2d polar point to the given PIL image assuming the polar origin is at the center of bounding box draw_context: PIL draw context bounds: tuple (left, top, right, bottom) indicating bounds within which the plot should be drawn. mark_fn: mark drawing function func(...
plot_polar_point
python
autorope/donkeycar
donkeycar/parts/lidar.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/lidar.py
MIT
def plot_polar_points(draw_context, bounds, mark_fn, mark_color, mark_px, measurements, max_distance, angle_direction=COUNTER_CLOCKWISE, rotate_plot=0): """ draw list of 2d polar points to given PIL image assuming the polar origin is at the center of bounding box ...
draw list of 2d polar points to given PIL image assuming the polar origin is at the center of bounding box draw_context: PIL draw context bounds: tuple (left, top, right, bottom) indicating bounds within which the plot should be drawn. mark_fn: function to draw point f...
plot_polar_points
python
autorope/donkeycar
donkeycar/parts/lidar.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/lidar.py
MIT
def plot_polar_bounds(draw_context, bounds, color, angle_direction=COUNTER_CLOCKWISE, rotate_plot=0): """ draw 2d polar bounds to given PIL image assuming the polar origin is at the center of bounding box and the bounding distance is the minimum of the width and height of the b...
draw 2d polar bounds to given PIL image assuming the polar origin is at the center of bounding box and the bounding distance is the minimum of the width and height of the bounding box draw_context: PIL draw context bounds: tuple (left, top, right, bottom) indicating bounds within which the...
plot_polar_bounds
python
autorope/donkeycar
donkeycar/parts/lidar.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/lidar.py
MIT
def run(self, measurements): ''' draw measurements to a PIL image and output the pil image measurements: list of polar coordinates as (distance, angle) tuples ''' self.frame = Image.new('RGB', self.resolution, (255, 255, 255)) bounds = (0, 0, self.frame.width...
draw measurements to a PIL image and output the pil image measurements: list of polar coordinates as (distance, angle) tuples
run
python
autorope/donkeycar
donkeycar/parts/lidar.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/lidar.py
MIT
def get_i_color(self, cam_img): ''' get the horizontal index of the color at the given slice of the image input: cam_image, an RGB numpy array output: index of max color, value of cumulative color at that index, and mask of pixels in range ''' # take a horizontal slice of...
get the horizontal index of the color at the given slice of the image input: cam_image, an RGB numpy array output: index of max color, value of cumulative color at that index, and mask of pixels in range
get_i_color
python
autorope/donkeycar
donkeycar/parts/line_follower.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/line_follower.py
MIT
def run(self, cam_img): ''' main runloop of the CV controller input: cam_image, an RGB numpy array output: steering, throttle, and the image. If overlay_image is True, then the output image includes and overlay that shows how the algorithm is working; otherwise t...
main runloop of the CV controller input: cam_image, an RGB numpy array output: steering, throttle, and the image. If overlay_image is True, then the output image includes and overlay that shows how the algorithm is working; otherwise the image is just passed-thr...
run
python
autorope/donkeycar
donkeycar/parts/line_follower.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/line_follower.py
MIT
def overlay_display(self, cam_img, mask, max_yellow, confidense): ''' composite mask on top the original image. show some values we are using for control ''' mask_exp = np.stack((mask, ) * 3, axis=-1) iSlice = self.scan_y img = np.copy(cam_img) img[iSlice...
composite mask on top the original image. show some values we are using for control
overlay_display
python
autorope/donkeycar
donkeycar/parts/line_follower.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/line_follower.py
MIT
def run(self): ''' poll socket for input. returns None when nothing was recieved otherwize returns packet data ''' try: z = self.socket.recv(flags=zmq.NOBLOCK) except zmq.Again as e: if self.return_last: return self.last ...
poll socket for input. returns None when nothing was recieved otherwize returns packet data
run
python
autorope/donkeycar
donkeycar/parts/network.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/network.py
MIT
def run(self, x, y, closest_pt): """ :param x: is current horizontal position :param y: is current vertical position :param closest_pt: is current cte/closest_pt :return: translated x, y and new index of closest point in path. """ if is_number_type(x) and is_numbe...
:param x: is current horizontal position :param y: is current vertical position :param closest_pt: is current cte/closest_pt :return: translated x, y and new index of closest point in path.
run
python
autorope/donkeycar
donkeycar/parts/path.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/path.py
MIT
def reset_origin(self): """ Reset the origin with the next value that comes in """ self.ox = None self.oy = None self.reset = True
Reset the origin with the next value that comes in
reset_origin
python
autorope/donkeycar
donkeycar/parts/path.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/path.py
MIT
def nearest_waypoints(self, path, x, y, look_ahead=1, look_behind=1, from_pt=0, num_pts=None): """ Get the path elements around the closest element to the given (x,y) :param path: list of (x,y) points :param x: horizontal coordinate of point to check :param y: vertical coordinate...
Get the path elements around the closest element to the given (x,y) :param path: list of (x,y) points :param x: horizontal coordinate of point to check :param y: vertical coordinate of point to check :param from_pt: index start start search within path :param num_pts: ma...
nearest_waypoints
python
autorope/donkeycar
donkeycar/parts/path.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/path.py
MIT
def nearest_track(self, path, x, y, look_ahead=1, look_behind=1, from_pt=0, num_pts=None): """ Get the line segment around the closest point to the given (x,y) :param path: list of (x,y) points :param x: horizontal coordinate of point to check :param y: vertical coordinate of poi...
Get the line segment around the closest point to the given (x,y) :param path: list of (x,y) points :param x: horizontal coordinate of point to check :param y: vertical coordinate of point to check :param from_pt: index start start search within path :param num_pts: maxim...
nearest_track
python
autorope/donkeycar
donkeycar/parts/path.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/path.py
MIT
def run(self, path, x, y, from_pt=None): """ Run cross track error algorithm :return: cross-track-error and index of nearest point on the path """ cte = 0. i = from_pt a, b, i = self.nearest_track(path, x, y, look_ahead=self....
Run cross track error algorithm :return: cross-track-error and index of nearest point on the path
run
python
autorope/donkeycar
donkeycar/parts/path.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/path.py
MIT
def run(self, ticks, throttle): """ inputs => total ticks since start inputs => throttle, used to determine positive or negative vel return => total dist (m), current vel (m/s), delta dist (m) """ new_ticks = ticks - self.prev_ticks self.prev_ticks = ticks ...
inputs => total ticks since start inputs => throttle, used to determine positive or negative vel return => total dist (m), current vel (m/s), delta dist (m)
run
python
autorope/donkeycar
donkeycar/parts/pigpio_enc.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/pigpio_enc.py
MIT
def output_pin_by_id(pin_id: str, frequency_hz: int = 60) -> OutputPin: """ Select a ttl output pin given a pin id. :param pin_id: pin specifier string :param frequency_hz: duty cycle frequency in hertz (only necessary for PCA9685) :return: OutputPin """ parts = pin_id.split(".") if part...
Select a ttl output pin given a pin id. :param pin_id: pin specifier string :param frequency_hz: duty cycle frequency in hertz (only necessary for PCA9685) :return: OutputPin
output_pin_by_id
python
autorope/donkeycar
donkeycar/parts/pins.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/pins.py
MIT
def pwm_pin_by_id(pin_id: str, frequency_hz: int = 60) -> PwmPin: """ Select a pwm output pin given a pin id. :param pin_id: pin specifier string :param frequency_hz: duty cycle frequency in hertz :return: PwmPin """ parts = pin_id.split(".") if parts[0] == PinProvider.PCA9685: p...
Select a pwm output pin given a pin id. :param pin_id: pin specifier string :param frequency_hz: duty cycle frequency in hertz :return: PwmPin
pwm_pin_by_id
python
autorope/donkeycar
donkeycar/parts/pins.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/pins.py
MIT
def input_pin_by_id(pin_id: str, pull: int = PinPull.PULL_NONE) -> InputPin: """ Select a ttl input pin given a pin id. """ parts = pin_id.split(".") if parts[0] == PinProvider.PCA9685: raise RuntimeError("PinProvider.PCA9685 does not implement InputPin") if parts[0] == PinProvider.RPI_...
Select a ttl input pin given a pin id.
input_pin_by_id
python
autorope/donkeycar
donkeycar/parts/pins.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/pins.py
MIT
def input_pin( pin_provider: str, pin_number: int, pin_scheme: str = PinScheme.BOARD, pull: int = PinPull.PULL_NONE) -> InputPin: """ construct an InputPin using the given pin provider. Note that PCA9685 can NOT provide an InputPin. :param pin_provider: PinProvider string...
construct an InputPin using the given pin provider. Note that PCA9685 can NOT provide an InputPin. :param pin_provider: PinProvider string :param pin_number: zero based pin number :param pin_scheme: PinScheme string :param pull: PinPull value :return: InputPin :except: RuntimeError if p...
input_pin
python
autorope/donkeycar
donkeycar/parts/pins.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/pins.py
MIT
def output_pin( pin_provider: str, pin_number: int, pin_scheme: str = PinScheme.BOARD, i2c_bus: int = 0, i2c_address: int = 40, frequency_hz: int = 60) -> OutputPin: """ construct an OutputPin using the given pin provider Note that PCA9685 can NOT provide an I...
construct an OutputPin using the given pin provider Note that PCA9685 can NOT provide an InputPin. :param pin_provider: PinProvider string :param pin_number: zero based pin number :param pin_scheme: PinScheme string :param i2c_bus: I2C bus number for I2C devices :param i2c_address: I2C addr...
output_pin
python
autorope/donkeycar
donkeycar/parts/pins.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/pins.py
MIT
def pwm_pin( pin_provider: str, pin_number: int, pin_scheme: str = PinScheme.BOARD, frequency_hz: int = 60, i2c_bus: int = 0, i2c_address: int = 40) -> PwmPin: """ construct a PwmPin using the given pin provider :param pin_provider: PinProvider string :par...
construct a PwmPin using the given pin provider :param pin_provider: PinProvider string :param pin_number: zero based pin number :param pin_scheme: PinScheme string :param i2c_bus: I2C bus number for I2C devices :param i2c_address: I2C address for I2C devices :param frequency_hz: duty cycle...
pwm_pin
python
autorope/donkeycar
donkeycar/parts/pins.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/pins.py
MIT
def gpio_fn(pin_scheme:int, fn:Callable[[], Any]): """ Convenience method to enforce the desired GPIO pin scheme before calling a GPIO function. RPi.GPIO allows only a single scheme to be set at runtime. If the pin scheme is already set to a different scheme, then this will raise a RuntimeError ...
Convenience method to enforce the desired GPIO pin scheme before calling a GPIO function. RPi.GPIO allows only a single scheme to be set at runtime. If the pin scheme is already set to a different scheme, then this will raise a RuntimeError to prevent erroneous pin outputs. :param pin_scheme:i...
gpio_fn
python
autorope/donkeycar
donkeycar/parts/pins.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/pins.py
MIT
def __init__(self, pin_number: int, pin_scheme: str, pull: int = PinPull.PULL_NONE) -> None: """ Input pin ttl HIGH/LOW using RPi.GPIO/Jetson.GPIO :param pin_number: GPIO.BOARD mode point number :param pull: enable a pull up or down resistor on pin. Default is PinPull.PULL_NONE ...
Input pin ttl HIGH/LOW using RPi.GPIO/Jetson.GPIO :param pin_number: GPIO.BOARD mode point number :param pull: enable a pull up or down resistor on pin. Default is PinPull.PULL_NONE
__init__
python
autorope/donkeycar
donkeycar/parts/pins.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/pins.py
MIT
def start(self, on_input=None, edge=PinEdge.RISING) -> None: """ :param on_input: no-arg function to call when an edge is detected, or None to ignore :param edge: type of edge(s) that trigger on_input; default is """ if self.state() != PinState.NOT_STARTED: raise Runt...
:param on_input: no-arg function to call when an edge is detected, or None to ignore :param edge: type of edge(s) that trigger on_input; default is
start
python
autorope/donkeycar
donkeycar/parts/pins.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/pins.py
MIT
def pca9685(busnum: int, address: int, frequency: int = 60): """ pca9685 factory allocates driver for pca9685 at given bus number and i2c address. If we have already created one for that bus/addr pair then use that singleton. If frequency is not the same, then error. :param busnum: I2C bus ...
pca9685 factory allocates driver for pca9685 at given bus number and i2c address. If we have already created one for that bus/addr pair then use that singleton. If frequency is not the same, then error. :param busnum: I2C bus number of PCA9685 :param address: address of PCA9685 on I2C bus ...
pca9685
python
autorope/donkeycar
donkeycar/parts/pins.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/pins.py
MIT
def start(self, state: int = PinState.LOW) -> None: """ Start the pin in output mode. This raises a RuntimeError if the pin is already started. You can check to see if the pin is started by calling state() and checking for PinState.NOT_STARTED :param state: PinState to st...
Start the pin in output mode. This raises a RuntimeError if the pin is already started. You can check to see if the pin is started by calling state() and checking for PinState.NOT_STARTED :param state: PinState to start with :except: RuntimeError if pin is already starte...
start
python
autorope/donkeycar
donkeycar/parts/pins.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/pins.py
MIT
def stop(self) -> None: """ Stop the pin and return it to PinState.NOT_STARTED """ if self.state() != PinState.NOT_STARTED: self.output(PinState.LOW) self._state = PinState.NOT_STARTED
Stop the pin and return it to PinState.NOT_STARTED
stop
python
autorope/donkeycar
donkeycar/parts/pins.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/pins.py
MIT
def output(self, state: int) -> None: """ Write output state to the pin. :param state: PinState.LOW or PinState.HIGH """ if self.state() == PinState.NOT_STARTED: raise RuntimeError(f"Attempt to use pin ({self.pin_number}) that is not started") if state == PinS...
Write output state to the pin. :param state: PinState.LOW or PinState.HIGH
output
python
autorope/donkeycar
donkeycar/parts/pins.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/pins.py
MIT
def start(self, duty: float = 0) -> None: """ Start pin with given duty cycle :param duty: duty cycle in range 0 to 1 :except: RuntimeError if pin is already started. """ if self.state() != PinState.NOT_STARTED: raise RuntimeError(f"Attempt to start pin ({self...
Start pin with given duty cycle :param duty: duty cycle in range 0 to 1 :except: RuntimeError if pin is already started.
start
python
autorope/donkeycar
donkeycar/parts/pins.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/pins.py
MIT
def duty_cycle(self, duty: float) -> None: """ Write a duty cycle to the output pin :param duty: duty cycle in range 0 to 1 :except: RuntimeError if not started """ if self.state() == PinState.NOT_STARTED: raise RuntimeError(f"Attempt to use pin ({self.pin_num...
Write a duty cycle to the output pin :param duty: duty cycle in range 0 to 1 :except: RuntimeError if not started
duty_cycle
python
autorope/donkeycar
donkeycar/parts/pins.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/pins.py
MIT
def __init__(self, pin_number: int, pull: int = PinPull.PULL_NONE, pgpio=None) -> None: """ Input pin ttl HIGH/LOW using PiGPIO library :param pin_number: GPIO.BOARD mode pin number :param pull: enable a pull up or down resistor on pin. Default is PinPull.PULL_NONE :param pgpio:...
Input pin ttl HIGH/LOW using PiGPIO library :param pin_number: GPIO.BOARD mode pin number :param pull: enable a pull up or down resistor on pin. Default is PinPull.PULL_NONE :param pgpio: instance of pgpio to use or None to allocate a new one
__init__
python
autorope/donkeycar
donkeycar/parts/pins.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/pins.py
MIT
def start(self, on_input=None, edge=PinEdge.RISING) -> None: """ Start the input pin and optionally set callback. :param on_input: no-arg function to call when an edge is detected, or None to ignore :param edge: type of edge(s) that trigger on_input; default is PinEdge.RISING """...
Start the input pin and optionally set callback. :param on_input: no-arg function to call when an edge is detected, or None to ignore :param edge: type of edge(s) that trigger on_input; default is PinEdge.RISING
start
python
autorope/donkeycar
donkeycar/parts/pins.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/pins.py
MIT
def input(self) -> int: """ Read the input pins state. :return: PinState.LOW/HIGH OR PinState.NOT_STARTED if not started """ if self.state() != PinState.NOT_STARTED: self._state = self.pgpio.read(self.pin_number) return self._state
Read the input pins state. :return: PinState.LOW/HIGH OR PinState.NOT_STARTED if not started
input
python
autorope/donkeycar
donkeycar/parts/pins.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/pins.py
MIT
def start(self, duty: float = 0) -> None: """ Start pin with given duty cycle. :param duty: duty cycle in range 0 to 1 :except: RuntimeError if pin is already started. """ if self.state() != PinState.NOT_STARTED: raise RuntimeError(f"Attempt to start InputPinP...
Start pin with given duty cycle. :param duty: duty cycle in range 0 to 1 :except: RuntimeError if pin is already started.
start
python
autorope/donkeycar
donkeycar/parts/pins.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/pins.py
MIT
def update(self): """ This will get called on it's own thread. throttle: sign of throttle is use used to determine direction. timestamp: timestamp for update or None to use current time. This is useful for creating deterministic tests. """ while self.ru...
This will get called on it's own thread. throttle: sign of throttle is use used to determine direction. timestamp: timestamp for update or None to use current time. This is useful for creating deterministic tests.
update
python
autorope/donkeycar
donkeycar/parts/pose.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/pose.py
MIT
def read_serial(self): ''' Read the rc controller value from serial port. Map the value into steering and throttle Format ####,#### whereas the 1st number is steering and 2nd is throttle ''' line = str(self.serial.readline().decode()).strip('\n').strip('\r') out...
Read the rc controller value from serial port. Map the value into steering and throttle Format ####,#### whereas the 1st number is steering and 2nd is throttle
read_serial
python
autorope/donkeycar
donkeycar/parts/robohat.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/robohat.py
MIT
def run_threaded(self, img_arr=None, mode=None, recording=None): """ :param img_arr: current camera image :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 :param mode: default user/mode :param recording: default recording mode
run_threaded
python
autorope/donkeycar
donkeycar/parts/robohat.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/robohat.py
MIT
def run(self, data): ''' only publish when data stream changes. ''' if data != self.data and not rospy.is_shutdown(): self.data = data self.pub.publish(data)
only publish when data stream changes.
run
python
autorope/donkeycar
donkeycar/parts/ros.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/ros.py
MIT
def buffered(self) -> int: """ return: the number of buffered characters """ if self.ser is None or not self.ser.is_open: return 0 # ser.in_waiting is always zero on mac, so act like we are buffered if dk_platform.is_mac(): return 1 try: ...
return: the number of buffered characters
buffered
python
autorope/donkeycar
donkeycar/parts/serial_port.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/serial_port.py
MIT
def readBytes(self, count:int=0) -> Tuple[bool, bytes]: """ if there are characters waiting, then read them from the serial port bytes: number of bytes to read return: tuple of bool: True if count bytes were available to read, false if not...
if there are characters waiting, then read them from the serial port bytes: number of bytes to read return: tuple of bool: True if count bytes were available to read, false if not enough bytes were avaiable bytes: string string if...
readBytes
python
autorope/donkeycar
donkeycar/parts/serial_port.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/serial_port.py
MIT
def read(self, count:int=0) -> Tuple[bool, str]: """ if there are characters waiting, then read them from the serial port bytes: number of bytes to read return: tuple of bool: True if count bytes were available to read, false if not enough...
if there are characters waiting, then read them from the serial port bytes: number of bytes to read return: tuple of bool: True if count bytes were available to read, false if not enough bytes were available str: ascii string if c...
read
python
autorope/donkeycar
donkeycar/parts/serial_port.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/serial_port.py
MIT
def readln(self) -> Tuple[bool, str]: """ if there are characters waiting, then read a line from the serial port. This will block until end-of-line can be read. The end-of-line is included in the return value. return: tuple of bool: True if line was read,...
if there are characters waiting, then read a line from the serial port. This will block until end-of-line can be read. The end-of-line is included in the return value. return: tuple of bool: True if line was read, false if not str: line if read (...
readln
python
autorope/donkeycar
donkeycar/parts/serial_port.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/serial_port.py
MIT
def writeBytes(self, value:bytes): """ write byte string to serial port """ if self.ser is not None and self.ser.is_open: try: self.ser.write(value) except (serial.serialutil.SerialException, TypeError): logger.warning("Can't writ...
write byte string to serial port
writeBytes
python
autorope/donkeycar
donkeycar/parts/serial_port.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/serial_port.py
MIT
def clear(self): """ Clear the lines buffer and serial port input buffer """ with self.lock: self.lines = [] self.serial.clear()
Clear the lines buffer and serial port input buffer
clear
python
autorope/donkeycar
donkeycar/parts/serial_port.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/serial_port.py
MIT
def _readline(self) -> str: """ Read a line from the serial port in a threadsafe manner returns line if read and None if no line was read """ if self.lock.acquire(blocking=False): try: # TODO: Serial.in_waiting _always_ returns 0 in Macintosh ...
Read a line from the serial port in a threadsafe manner returns line if read and None if no line was read
_readline
python
autorope/donkeycar
donkeycar/parts/serial_port.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/serial_port.py
MIT
def run(self, x, y, box_size=None, color=None): """ Create an image of a square box at a given coordinates. """ radius = int((box_size or self.box_size)/2) color = color or self.color frame = np.zeros(shape=self.resolution + (3,)) frame[y - radius: y + radius, ...
Create an image of a square box at a given coordinates.
run
python
autorope/donkeycar
donkeycar/parts/simulation.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/simulation.py
MIT
def poll_ticks(self, direction:int): """ read the encoder ticks direction: 1 if forward, -1 if reverse, 0 if stopped. return: updated encoder ticks """ # # If there are characters waiting, # then read from the serial port. # Read all lines and use...
read the encoder ticks direction: 1 if forward, -1 if reverse, 0 if stopped. return: updated encoder ticks
poll_ticks
python
autorope/donkeycar
donkeycar/parts/tachometer.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/tachometer.py
MIT
def get_ticks(self, encoder_index:int=0) -> int: """ Get last polled encoder ticks encoder_index: zero based index of encoder. return: Most recently polled encoder ticks This will return the same value as the most recent call to poll_ticks(). It will not reques...
Get last polled encoder ticks encoder_index: zero based index of encoder. return: Most recently polled encoder ticks This will return the same value as the most recent call to poll_ticks(). It will not request new values from the encoder. It will not block. ...
get_ticks
python
autorope/donkeycar
donkeycar/parts/tachometer.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/tachometer.py
MIT
def _cb(self): """ Callback routine called by GPIO when a tick is detected :pin_number: int the pin number that generated the interrupt. :pin_state: int the state of the pin """ # # we avoid blocking by updating an internal counter, # then if we can get a ...
Callback routine called by GPIO when a tick is detected :pin_number: int the pin number that generated the interrupt. :pin_state: int the state of the pin
_cb
python
autorope/donkeycar
donkeycar/parts/tachometer.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/tachometer.py
MIT
def get_ticks(self, encoder_index:int=0) -> int: """ Get last polled encoder ticks encoder_index: zero based index of encoder. return: Most recently polled encoder ticks This will return the same value as the most recent call to poll_ticks(). It will not reques...
Get last polled encoder ticks encoder_index: zero based index of encoder. return: Most recently polled encoder ticks This will return the same value as the most recent call to poll_ticks(). It will not request new values from the encoder. This will not block. ...
get_ticks
python
autorope/donkeycar
donkeycar/parts/tachometer.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/tachometer.py
MIT
def __init__(self, encoder:AbstractEncoder, ticks_per_revolution:float=1, direction_mode=EncoderMode.FORWARD_ONLY, poll_delay_secs:float=0.01, debug=False): """ Tachometer converts encoder ticks to revolutions a...
Tachometer converts encoder ticks to revolutions and supports modifying direction based on throttle input. Parameters ---------- encoder: AbstractEncoder an instance of an encoder class derived from AbstactEncoder. ticks_per_revolution: int ...
__init__
python
autorope/donkeycar
donkeycar/parts/tachometer.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/tachometer.py
MIT
def poll(self, throttle, timestamp): """ Parameters ---------- throttle : float positive means forward negative means backward zero means stopped timestamp: int, optional the timestamp to apply to the tick reading or Non...
Parameters ---------- throttle : float positive means forward negative means backward zero means stopped timestamp: int, optional the timestamp to apply to the tick reading or None to use the current time
poll
python
autorope/donkeycar
donkeycar/parts/tachometer.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/tachometer.py
MIT
def run_threaded(self, throttle:float=0.0, timestamp:float=None) -> Tuple[float, float]: """ Parameters ---------- throttle : float positive means forward negative means backward zero means stopped timestamp: int, optional the times...
Parameters ---------- throttle : float positive means forward negative means backward zero means stopped timestamp: int, optional the timestamp to apply to the tick reading or None to use the current time Returns ...
run_threaded
python
autorope/donkeycar
donkeycar/parts/tachometer.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/tachometer.py
MIT
def run(self, throttle:float=1.0, timestamp:float=None) -> Tuple[float, float]: """ throttle: sign of throttle is use used to determine direction. timestamp: timestamp for update or None to use current time. This is useful for creating deterministic tests. """ ...
throttle: sign of throttle is use used to determine direction. timestamp: timestamp for update or None to use current time. This is useful for creating deterministic tests.
run
python
autorope/donkeycar
donkeycar/parts/tachometer.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/tachometer.py
MIT
def map_range(self, x, X_min, X_max, Y_min, Y_max): ''' Linear mapping between two ranges of values ''' X_range = X_max - X_min Y_range = Y_max - Y_min XY_ratio = X_range/Y_range return ((x-X_min) / XY_ratio + Y_min)
Linear mapping between two ranges of values
map_range
python
autorope/donkeycar
donkeycar/parts/teensy.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/teensy.py
MIT
def report(self, metrics): """ Basic reporting - gets arbitrary dictionary with values """ curr_time = int(time.time()) # Store sample with time rounded to second try: self._telem_q.put((curr_time, metrics), block=False) except queue.Full: ...
Basic reporting - gets arbitrary dictionary with values
report
python
autorope/donkeycar
donkeycar/parts/telemetry.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/telemetry.py
MIT
def twiddle(evaluator, tol=0.001, params=3, error_cmp=None, initial_guess=None): """ A coordinate descent parameter tuning algorithm. https://github.com/chrisspen/pid_controller/blob/master/pid_controller/pid.py https://en.wikipedia.org/wiki/Coordinate_descent Params: evaluato...
A coordinate descent parameter tuning algorithm. https://github.com/chrisspen/pid_controller/blob/master/pid_controller/pid.py https://en.wikipedia.org/wiki/Coordinate_descent Params: evaluator := callable that will be passed a series of number parameters, which will return ...
twiddle
python
autorope/donkeycar
donkeycar/parts/transform.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/transform.py
MIT
def write_record(self, record=None): """ Can handle various data types including images. """ contents = dict() for key, value in record.items(): if value is None: continue elif key not in self.input_types: continue ...
Can handle various data types including images.
write_record
python
autorope/donkeycar
donkeycar/parts/tub_v2.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/tub_v2.py
MIT
def __init__(self, tub, num_records=20): """ :param tub: tub to operate on :param num_records: number or records to delete """ self._tub = tub self._num_records = num_records self._active_loop = False
:param tub: tub to operate on :param num_records: number or records to delete
__init__
python
autorope/donkeycar
donkeycar/parts/tub_v2.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/tub_v2.py
MIT
def run(self, is_delete): """ Method in the vehicle loop. Delete records when trigger switches from False to True only. :param is_delete: if deletion has been triggered by the caller """ # only run if input is true and debounced if is_delete: if not se...
Method in the vehicle loop. Delete records when trigger switches from False to True only. :param is_delete: if deletion has been triggered by the caller
run
python
autorope/donkeycar
donkeycar/parts/tub_v2.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/tub_v2.py
MIT
def __init__(self, min_speed:float, max_speed:float, throttle_step:float=1/255, min_throttle:float=0) -> None: """ @param min_speed is speed below which vehicle stalls (so slowest stable working speed) @param max_speed is speed at maximum throttle @param throttle_steps is number of steps...
@param min_speed is speed below which vehicle stalls (so slowest stable working speed) @param max_speed is speed at maximum throttle @param throttle_steps is number of steps in working range of throttle (min_throttle to 1.0) @param min_throttle is throttle that corresponds to min_speed;...
__init__
python
autorope/donkeycar
donkeycar/parts/velocity.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/velocity.py
MIT
def run(self, throttle:float, speed:float, target_speed:float) -> float: """ Given current throttle and speed and a target speed, calculate a new throttle to attain target speed @param throttle is current throttle (-1 to 1) @param speed is current speed where reverse speeds are ...
Given current throttle and speed and a target speed, calculate a new throttle to attain target speed @param throttle is current throttle (-1 to 1) @param speed is current speed where reverse speeds are negative @param throttle_steps number of steps between min_throttle and max_...
run
python
autorope/donkeycar
donkeycar/parts/velocity.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/velocity.py
MIT
def get_default_transform(for_video=False, for_inference=False, resize=True): """ Creates a default transform to work with torchvision models Video transform: All pre-trained models expect input images normalized in the same way, i.e. mini-batches of 3-channel RGB videos of shape (3 x T x H x W), ...
Creates a default transform to work with torchvision models Video transform: All pre-trained models expect input images normalized in the same way, i.e. mini-batches of 3-channel RGB videos of shape (3 x T x H x W), where H and W are expected to be 112, and T is a number of video frames in ...
get_default_transform
python
autorope/donkeycar
donkeycar/parts/pytorch/torch_data.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/pytorch/torch_data.py
MIT
def __init__(self, config, records: List[TubRecord], transform=None): """Create a PyTorch Tub Dataset Args: config (object): the configuration information records (List[TubRecord]): a list of tub records transform (function, optional): a transform to apply to the dat...
Create a PyTorch Tub Dataset Args: config (object): the configuration information records (List[TubRecord]): a list of tub records transform (function, optional): a transform to apply to the data
__init__
python
autorope/donkeycar
donkeycar/parts/pytorch/torch_data.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/pytorch/torch_data.py
MIT
def _create_pipeline(self): """ This can be overridden if more complicated pipelines are required """ def y_transform(record: TubRecord): angle: float = record.underlying['user/angle'] throttle: float = record.underlying['user/throttle'] predictions = tor...
This can be overridden if more complicated pipelines are required
_create_pipeline
python
autorope/donkeycar
donkeycar/parts/pytorch/torch_data.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/pytorch/torch_data.py
MIT
def __init__(self, config: Any, tub_paths: List[str], transform=None): """Create a PyTorch Lightning Data Module to contain all data loading logic Args: config (object): the configuration information tub_paths (List[str]): a list of paths to the tubs to use (minimum size of 1). ...
Create a PyTorch Lightning Data Module to contain all data loading logic Args: config (object): the configuration information tub_paths (List[str]): a list of paths to the tubs to use (minimum size of 1). Each tub path corresponds to another training r...
__init__
python
autorope/donkeycar
donkeycar/parts/pytorch/torch_data.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/pytorch/torch_data.py
MIT
def setup(self, stage=None): """Load all the tub data and set up the datasets. Args: stage ([string], optional): setup expects a string arg stage. It is used to separate setup logic for trainer.fit and trainer...
Load all the tub data and set up the datasets. Args: stage ([string], optional): setup expects a string arg stage. It is used to separate setup logic for trainer.fit and trainer.test. Defaults to None.
setup
python
autorope/donkeycar
donkeycar/parts/pytorch/torch_data.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/pytorch/torch_data.py
MIT
def get_model_by_type(model_type, cfg, checkpoint_path=None): ''' given the string model_type and the configuration settings in cfg create a Torch model and return it. ''' if model_type is None: model_type = cfg.DEFAULT_MODEL_TYPE print("\"get_model_by_type\" model Type is: {}".format(mo...
given the string model_type and the configuration settings in cfg create a Torch model and return it.
get_model_by_type
python
autorope/donkeycar
donkeycar/parts/pytorch/torch_utils.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/pytorch/torch_utils.py
MIT
def update(self): ''' Loop to run in separate thread the updates angle, throttle and drive mode. ''' while True: # get latest value from server self.angle, self.throttle, self.mode, self.recording = self.run()
Loop to run in separate thread the updates angle, throttle and drive mode.
update
python
autorope/donkeycar
donkeycar/parts/web_controller/web.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/web_controller/web.py
MIT
def run(self): ''' Posts current car sensor data to webserver and returns angle and throttle recommendations. ''' data = {} response = None while response is None: try: response = self.session.post(self.control_url, ...
Posts current car sensor data to webserver and returns angle and throttle recommendations.
run
python
autorope/donkeycar
donkeycar/parts/web_controller/web.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/web_controller/web.py
MIT
def __init__(self, port=8887, mode='user'): """ Create and publish variables needed on many of the web handlers. """ logger.info('Starting Donkey Server...') this_dir = os.path.dirname(os.path.realpath(__file__)) self.static_file_path = os.path.join(this_dir, 'te...
Create and publish variables needed on many of the web handlers.
__init__
python
autorope/donkeycar
donkeycar/parts/web_controller/web.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/web_controller/web.py
MIT
def run_threaded(self, img_arr=None, num_records=0, mode=None, recording=None): """ :param img_arr: current camera image or None :param num_records: current number of data records :param mode: default user/mode :param recording: default recording mode """ self.img...
:param img_arr: current camera image or None :param num_records: current number of data records :param mode: default user/mode :param recording: default recording mode
run_threaded
python
autorope/donkeycar
donkeycar/parts/web_controller/web.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/web_controller/web.py
MIT
def post(self): ''' Receive post requests as user changes the angle and throttle of the vehicle on a the index webpage ''' data = tornado.escape.json_decode(self.request.body) if data.get('angle') is not None: self.application.angle = data['angle'] if...
Receive post requests as user changes the angle and throttle of the vehicle on a the index webpage
post
python
autorope/donkeycar
donkeycar/parts/web_controller/web.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/web_controller/web.py
MIT
def latch_buttons(buttons, pushes): """ Latch button pushes buttons: the latched values pushes: the update value """ if pushes is not None: # # we got button pushes. # - we latch the pushed buttons so we can process the push # - after it is processed we clear it ...
Latch button pushes buttons: the latched values pushes: the update value
latch_buttons
python
autorope/donkeycar
donkeycar/parts/web_controller/web.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/web_controller/web.py
MIT
def create(cls, aug_type: str, config: Config, prob, always) -> \ albumentations.core.transforms_interface.BasicTransform: """ Augmentation factory. Cropping and trapezoidal mask are transformations which should be applied in training, validation and inference. Multiply, Blur...
Augmentation factory. Cropping and trapezoidal mask are transformations which should be applied in training, validation and inference. Multiply, Blur and similar are augmentations which should be used only in training.
create
python
autorope/donkeycar
donkeycar/pipeline/augmentations.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/pipeline/augmentations.py
MIT
def image_processor(self, img_arr): """ Transforms the image and augments it if in training. We are not calling the normalisation here, because then the normalised images would get cached in the TubRecord, and they are 8 times larger (as they are 64bit floats and not uint8) """ a...
Transforms the image and augments it if in training. We are not calling the normalisation here, because then the normalised images would get cached in the TubRecord, and they are 8 times larger (as they are 64bit floats and not uint8)
image_processor
python
autorope/donkeycar
donkeycar/pipeline/training.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/pipeline/training.py
MIT
def __copy__(self): """ Make shallow copies of config and image and full copies of the rest. :return TubRecord: TubRecord copy """ tubrec = TubRecord(self.config, copy(self.base_path), copy(self.underlying)) tubrec._cache_p...
Make shallow copies of config and image and full copies of the rest. :return TubRecord: TubRecord copy
__copy__
python
autorope/donkeycar
donkeycar/pipeline/types.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/pipeline/types.py
MIT