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 is_in_range(self, x, y): """ Determine if the given (x,y) point is within the range of the collected waypoint samples """ return (x >= self.x_stats.min) and \ (x <= self.x_stats.max) and \ (y >= self.y_stats.min) and \...
Determine if the given (x,y) point is within the range of the collected waypoint samples
is_in_range
python
autorope/donkeycar
donkeycar/parts/gps.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/gps.py
MIT
def is_in_std(self, x, y, std_multiple=1.0): """ Determine if the given (x, y) point is within a given multiple of the standard deviation of the samples on each axis. """ x_std = self.x_stats.std_deviation * std_multiple y_std = self.y_...
Determine if the given (x, y) point is within a given multiple of the standard deviation of the samples on each axis.
is_in_std
python
autorope/donkeycar
donkeycar/parts/gps.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/gps.py
MIT
def run(self, image_a, image_b): ''' This will take the two images and combine them into a single image One in red, the other in green, and diff in blue channel. ''' if image_a is not None and image_b is not None: width, height, _ = image_a.shape grey_a = ...
This will take the two images and combine them into a single image One in red, the other in green, and diff in blue channel.
run
python
autorope/donkeycar
donkeycar/parts/image.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/image.py
MIT
def __init__(self, config: Config, transformation: str, post_transformation: str = None) -> object: """ Part that constructs a list of image transformers and run them in sequence to produce a transformed image """ transformations = getattr(config, transformation,...
Part that constructs a list of image transformers and run them in sequence to produce a transformed image
__init__
python
autorope/donkeycar
donkeycar/parts/image_transformations.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/image_transformations.py
MIT
def run(self, image): """ Run the list of tranformers on the image and return transformed image. """ for transformer in self.transformations: image = transformer.run(image) return image
Run the list of tranformers on the image and return transformed image.
run
python
autorope/donkeycar
donkeycar/parts/image_transformations.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/image_transformations.py
MIT
def image_transformer(name: str, config): """ Factory for cv image transformation parts. :param name: str, name of the transformation :param config: object, the configuration to apply when constructing the part :return: object, a cv image transformation part """ # # masking transformatio...
Factory for cv image transformation parts. :param name: str, name of the transformation :param config: object, the configuration to apply when constructing the part :return: object, a cv image transformation part
image_transformer
python
autorope/donkeycar
donkeycar/parts/image_transformations.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/image_transformations.py
MIT
def custom_transformer(name:str, config:Config, file_path:str=None, class_name:str=None) -> object: """ Instantiate a custom image transformer. A custome transformer is a class whose constructor takes a Config object to get its config...
Instantiate a custom image transformer. A custome transformer is a class whose constructor takes a Config object to get its configuration and whose run() method gets an image as an argument and returns a transformed image. Like: ``` class CustomImageTransformer: def __init__(self, con...
custom_transformer
python
autorope/donkeycar
donkeycar/parts/image_transformations.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/image_transformations.py
MIT
def img_transform_from_json(transform_config): """ Construct a single Image transform from given dictionary. The dictionary corresponds the the image transform's constructor arguments, so it can be passed to the constructor using object destructuring. """ if not isinstance(transform_config,...
Construct a single Image transform from given dictionary. The dictionary corresponds the the image transform's constructor arguments, so it can be passed to the constructor using object destructuring.
img_transform_from_json
python
autorope/donkeycar
donkeycar/parts/image_transformations.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/image_transformations.py
MIT
def img_transform_list_from_json(transforms_config): """ Parse one or more Image transforms from given list and return an ImgTransformer that applies them with the arguments and in the order given in the file. """ if not isinstance(transforms_config, list): raise TypeError("transfor...
Parse one or more Image transforms from given list and return an ImgTransformer that applies them with the arguments and in the order given in the file.
img_transform_list_from_json
python
autorope/donkeycar
donkeycar/parts/image_transformations.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/image_transformations.py
MIT
def load_img_transform_json(filepath): """ Load a json file that specifies a list with one or more image transforms, their order and their arguments. The list will contain a series of tuples as a two element list. The first element of the tuple is the name of the transform and the second eleme...
Load a json file that specifies a list with one or more image transforms, their order and their arguments. The list will contain a series of tuples as a two element list. The first element of the tuple is the name of the transform and the second element is a dictionary the named arguments for...
load_img_transform_json
python
autorope/donkeycar
donkeycar/parts/image_transformations.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/image_transformations.py
MIT
def saved_model_to_tensor_rt(saved_path: str, tensor_rt_path: str) -> bool: """ Converts TF SavedModel format into TensorRT for cuda. Note, this works also without cuda as all GPU specific magic is handled within TF now. """ logger.info(f'Converting SavedModel {saved_path} to TensorRT' ...
Converts TF SavedModel format into TensorRT for cuda. Note, this works also without cuda as all GPU specific magic is handled within TF now.
saved_model_to_tensor_rt
python
autorope/donkeycar
donkeycar/parts/interpreter.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/interpreter.py
MIT
def predict(self, img_arr: np.ndarray, *other_arr: np.ndarray) \ -> Sequence[Union[float, np.ndarray]]: """ This inference interface just converts the inputs into a dictionary :param img_arr: input image array :param other_arr: second input array :return: ...
This inference interface just converts the inputs into a dictionary :param img_arr: input image array :param other_arr: second input array :return: model output, Iterable over scalar and/or vectors
predict
python
autorope/donkeycar
donkeycar/parts/interpreter.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/interpreter.py
MIT
def run(self, img_arr: np.ndarray, *other_arr: List[float]) \ -> Tuple[Union[float, np.ndarray], ...]: """ 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 ...
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/keras.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/keras.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/keras.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/keras.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/keras.py
https://github.com/autorope/donkeycar/blob/master/donkeycar/parts/keras.py
MIT
def x_transform( self, record: Union[TubRecord, List[TubRecord]], img_processor: Callable[[np.ndarray], np.ndarray]) \ -> Dict[str, Union[float, np.ndarray]]: """ Transforms the record into dictionary for x for training the model to x,y, and applies an ima...
Transforms the record into dictionary for x for training the model to x,y, and applies an image augmentation. Here we assume the model only takes the image as input. All model input layer's names must be matched by dictionary keys.
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, 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 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...
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 __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) -> 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 plot_polar_angle(draw_context, bounds, color, theta, 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 ...
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_angle
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 plot_circle(self, x, y, rad, draw, color, width=1): ''' scale dist so that max_dist is edge of img (mm) and img is PIL Image, draw the circle using the draw ImageDraw object ''' sx = x - rad sy = y - rad ex = x + rad ey = y + rad draw.ellipse(...
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_circle
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, 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 output(self, state: int) -> None: """ Write output state to the pin. :param state: PinState.LOW or PinState.HIGH """ if self.state() != PinState.NOT_STARTED: self.pgpio.write(self.pin_number, state) self._state = state
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 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 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 duty < 0 or duty > 1: raise ValueError("duty_cycle must be in range 0 to 1") if self...
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 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 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 poll_ticks(self, direction:int): """ read the encoder ticks direction: 1 if forward, -1 if reverse, 0 if stopped. return: updated encoder ticks """ with self.lock: self.direction = direction
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. 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