diff --git a/burt_network/lib/src/generated/arm.pb.dart b/burt_network/lib/src/generated/arm.pb.dart index a2dd96b2..c8f736ba 100644 --- a/burt_network/lib/src/generated/arm.pb.dart +++ b/burt_network/lib/src/generated/arm.pb.dart @@ -21,6 +21,8 @@ import 'version.pb.dart' as $2; export 'package:protobuf/protobuf.dart' show GeneratedMessageGenericExtensions; +export 'arm.pbenum.dart'; + class ArmData extends $pb.GeneratedMessage { factory ArmData({ $0.Coordinates? currentPosition, diff --git a/burt_network/lib/src/generated/arm.pbenum.dart b/burt_network/lib/src/generated/arm.pbenum.dart index edec8f7a..bbabbb18 100644 --- a/burt_network/lib/src/generated/arm.pbenum.dart +++ b/burt_network/lib/src/generated/arm.pbenum.dart @@ -5,6 +5,37 @@ // @dart = 3.3 // ignore_for_file: annotate_overrides, camel_case_types, comment_references +// ignore_for_file: constant_identifier_names, library_prefixes +// ignore_for_file: non_constant_identifier_names, prefer_final_fields +// ignore_for_file: unnecessary_import, unnecessary_this, unused_import + +import 'dart:core' as $core; + +import 'package:protobuf/protobuf.dart' as $pb; + +class ArmMotor extends $pb.ProtobufEnum { + static const ArmMotor ARM_MOTOR_UNDEFINED = ArmMotor._(0, _omitEnumNames ? '' : 'ARM_MOTOR_UNDEFINED'); + static const ArmMotor SWIVEL = ArmMotor._(1, _omitEnumNames ? '' : 'SWIVEL'); + static const ArmMotor SHOULDER = ArmMotor._(2, _omitEnumNames ? '' : 'SHOULDER'); + static const ArmMotor ELBOW = ArmMotor._(3, _omitEnumNames ? '' : 'ELBOW'); + static const ArmMotor WRIST = ArmMotor._(4, _omitEnumNames ? '' : 'WRIST'); + + static const $core.List values = [ + ARM_MOTOR_UNDEFINED, + SWIVEL, + SHOULDER, + ELBOW, + WRIST, + ]; + + static final $core.Map<$core.int, ArmMotor> _byValue = $pb.ProtobufEnum.initByValue(values); + static ArmMotor? valueOf($core.int value) => _byValue[value]; + + const ArmMotor._($core.int v, $core.String n) : super(v, n); +} + + +const _omitEnumNames = $core.bool.fromEnvironment('protobuf.omit_enum_names'); // ignore_for_file: constant_identifier_names // ignore_for_file: curly_braces_in_flow_control_structures // ignore_for_file: deprecated_member_use_from_same_package, library_prefixes diff --git a/burt_network/lib/src/generated/arm.pbjson.dart b/burt_network/lib/src/generated/arm.pbjson.dart index 279ff866..da9350ca 100644 --- a/burt_network/lib/src/generated/arm.pbjson.dart +++ b/burt_network/lib/src/generated/arm.pbjson.dart @@ -15,6 +15,23 @@ import 'dart:convert' as $convert; import 'dart:core' as $core; import 'dart:typed_data' as $typed_data; +@$core.Deprecated('Use armMotorDescriptor instead') +const ArmMotor$json = { + '1': 'ArmMotor', + '2': [ + {'1': 'ARM_MOTOR_UNDEFINED', '2': 0}, + {'1': 'SWIVEL', '2': 1}, + {'1': 'SHOULDER', '2': 2}, + {'1': 'ELBOW', '2': 3}, + {'1': 'WRIST', '2': 4}, + ], +}; + +/// Descriptor for `ArmMotor`. Decode as a `google.protobuf.EnumDescriptorProto`. +final $typed_data.Uint8List armMotorDescriptor = $convert.base64Decode( + 'CghBcm1Nb3RvchIXChNBUk1fTU9UT1JfVU5ERUZJTkVEEAASCgoGU1dJVkVMEAESDAoIU0hPVU' + 'xERVIQAhIJCgVFTEJPVxADEgkKBVdSSVNUEAQ='); + @$core.Deprecated('Use armDataDescriptor instead') const ArmData$json = { '1': 'ArmData', diff --git a/subsystems/lib/src/devices/can_bus.dart b/subsystems/lib/src/devices/can_bus.dart new file mode 100644 index 00000000..a6191ea4 --- /dev/null +++ b/subsystems/lib/src/devices/can_bus.dart @@ -0,0 +1,375 @@ +import "dart:async"; +import "dart:io"; + +import "package:burt_network/protobuf.dart"; +import "package:burt_network/service.dart"; +import "package:dart_dbc_generator/dart_dbc_generator.dart"; +import "package:linux_can/linux_can.dart"; +import "package:subsystems/src/generated/rover_messages.dbc.dart"; +import "package:subsystems/src/utils/dbc_conversions.dart"; +import "package:subsystems/subsystems.dart" hide CanSocket; + +/// Utility method to convert a message into a list of DBC messages +List getDBCMessages(Message message) => switch (message) { + final DriveCommand m => m.toDBC(), + final RelaysCommand m => m.toDBC(), + final ArmCommand m => m.toDBC(), + final ScienceCommand _ => [], + _ => [], +}; + +/// A map of CAN IDs to a function to convert them into a protobuf message +final Map data)> canIDToMessage = { + DriveAppliedOutputDataMessage().canId: (data) => + DriveAppliedOutputDataMessage.decode(data).toDriveProto(), + DriveBatteryDataMessage().canId: (data) => + DriveBatteryDataMessage.decode(data).toDriveProto(), + DriveLedDataMessage().canId: (data) => + DriveLedDataMessage.decode(data).toDriveProto(), + DriveSwivelDataMessage().canId: (data) => + DriveSwivelDataMessage.decode(data).toDriveProto(), + DriveMotorDataMessage().canId: (data) => + DriveMotorDataMessage.decode(data).toDriveProto(), + RelayStateDataMessage().canId: (data) => + RelayStateDataMessage.decode(data).toRelayProto(), + RelayBatteryDataMessage().canId: (data) => + RelayBatteryDataMessage.decode(data).toRelayProto(), + ArmMotorMoveDataMessage().canId: (data) => + ArmMotorMoveDataMessage.decode(data).toArmProto(), + ArmMotorStepDataMessage().canId: (data) => + ArmMotorStepDataMessage.decode(data).toArmProto(), + ArmMotorAngleDataMessage().canId: (data) => + ArmMotorAngleDataMessage.decode(data).toArmProto(), +}; + +extension on DeviceBroadcastMessage { + Message toDriveProto() => DriveData(version: version); + + Message toRelayProto() => RelaysData(); + + Message toArmProto() => ArmData(version: version); + + Message toScienceProto() => ScienceData(version: version); + + Message? toProtoMessage() { + if (deviceValue == Device.DRIVE.value) { + return toDriveProto(); + } else if (deviceValue == Device.RELAY.value) { + return toRelayProto(); + } else if (deviceValue == Device.ARM.value) { + return toArmProto(); + } else if (deviceValue == Device.SCIENCE.value) { + return toScienceProto(); + } + return null; + } + + Version get version => Version(major: fwVersionMajor, minor: fwVersionMinor); +} + +/// A service to forward messages between CAN and UDP +/// +/// Simliar to the firmware service, this service will stream incoming +/// messages from the network, and send specific types of messages over +/// the CAN bus as its corresponding DBC message. +/// +/// For safety reasons, this service will send and receive heartbeats +/// over the CAN bus, to ensure every device knows it's connected to the +/// rover, and so the rover can determine every device connected, and their +/// firmware versions. +class CanBus extends Service { + /// The CAN interface to send messages on + static const String canInterface = "can0"; + + /// How often to send a rover heartbeat over the CAN bus + static const Duration heartbeatPeriod = Duration(milliseconds: 100); + + /// The maximum time the program should wait for a device's heartbeat before + /// it's considered disconnected + static const Duration heartbeatTimeout = Duration(milliseconds: 250); + + /// A map of devices and the last time their broadcast message was received + final Map deviceHeartbeats = {}; + + /// A list of all the devices connected to the CAN bus + List get connectedDevices => deviceHeartbeats.keys.toList(); + + /// The CAN device for the CAN bus + CanDevice? device; + + /// The CAN socket for the CAN bus + CanSocket? socket; + Timer? _sendHeartbeatTimer; + Timer? _checkHeartbeatsTimer; + + bool _heartbeatSendSuccessful = false; + + StreamSubscription? _frameSubscription; + + Future? _resetFuture; + + @override + Future init() async { + if (Platform.isWindows) { + return true; + } + + if (!await bringUpCAN(canInterface)) { + return false; + } + try { + device = LinuxCan.instance.devices.singleWhere( + (device) => device.networkInterface.name == canInterface, + ); + } catch (e) { + if (e is StateError) { + logger.error("No CAN interface found named $canInterface"); + return false; + } + rethrow; + } + if (!device!.isUp) { + logger.error( + "$canInterface is not up", + body: "Device state: ${device!.state}", + ); + return false; + } + logger.info( + "Initializing CAN socket for device ${device!.networkInterface.name}", + ); + socket = device!.open(); + _frameSubscription = socket!.receive().listen(_onCanFrame); + _sendHeartbeatTimer = Timer.periodic( + heartbeatPeriod, + (_) => sendHeartbeat(), + ); + _checkHeartbeatsTimer = Timer.periodic( + heartbeatTimeout, + (_) => checkHeartbeats(), + ); + return true; + } + + @override + Future dispose() async { + _sendHeartbeatTimer?.cancel(); + _checkHeartbeatsTimer?.cancel(); + + _heartbeatSendSuccessful = false; + + await socket?.close(); + socket = null; + + device = null; + + await _frameSubscription?.cancel(); + + deviceHeartbeats.clear(); + } + + /// Initializes and brings up the CAN interface named [interfaceName] + /// + /// Returns whether or not the device was successfully brought up. + Future bringUpCAN(String interfaceName) async { + await Process.run("sudo", ["ip", "link", "set", interfaceName, "down"]); + await Process.run("sudo", [ + "ip", + "link", + "set", + interfaceName, + "type", + "can", + "bitrate", + "500000", + "restart-ms", + "100", + ]); + final upResult = await Process.run("sudo", [ + "ip", + "link", + "set", + interfaceName, + "up", + ]); + + if (upResult.exitCode != 0) { + logger.error("Could not set $canInterface up", body: upResult.stderr); + return false; + } + + return true; + } + + /// Whether or not a broadcast message has been received from [device] within + /// the past [heartbeatTimeout] amount of time + bool deviceConnected(Device device) => deviceHeartbeats.containsKey(device); + + /// Sends the [dbcMessages] over the CAN bus only if a broadcast message has been + /// received from [device] and a heartbeat has been successfully sent + /// + /// If [forceSend] is true, it will send the message regardless of connection + /// or heartbeat status + Future _sendDeviceCommand({ + required Device device, + required Iterable dbcMessages, + bool forceSend = false, + }) async { + if ((!deviceConnected(device) || !_heartbeatSendSuccessful) && !forceSend) { + return false; + } + return !(await Future.wait( + dbcMessages.map(sendDBCMessage), + )).contains(false); + } + + /// Sends a wrapped message over the CAN bus, returns + /// whether or not the message was successfully sent + Future sendWrapper(WrappedMessage message) async { + if (message.name == DriveCommand().messageName) { + return sendMessage(DriveCommand.fromBuffer(message.data)); + } else if (message.name == RelaysCommand().messageName) { + return sendMessage(RelaysCommand.fromBuffer(message.data)); + } else if (message.name == ArmCommand().messageName) { + return sendMessage(ArmCommand.fromBuffer(message.data)); + } else if (message.name == ScienceCommand().messageName) { + return sendMessage(ScienceCommand.fromBuffer(message.data)); + } + return false; + } + + /// Sends a message's DBC equivalent over the CAN bus + /// + /// Returns whether or not the message was sent over the bus + Future sendMessage(Message message) { + final device = commandToDevice[message.messageName]; + if (device == null) { + return Future.value(false); + } + + return _sendDeviceCommand( + device: device, + dbcMessages: getDBCMessages(message), + ); + } + + /// Whether or not [message] can be successfully sent over the bus + /// + /// If no broadcast has been received from the device corresponding to [message], + /// it will return false. If there was an error while sending a heartbeat, this + /// will also return false; + bool canSendWrapper(WrappedMessage message) { + if (!_heartbeatSendSuccessful || + !commandToDevice.containsKey(message.name)) { + return false; + } + + return deviceConnected(commandToDevice[message.name]!); + } + + /// Sends a heartbeat message over the CAN bus + Future sendHeartbeat() async { + final heartbeat = RoverHeartbeatMessage(); + return _heartbeatSendSuccessful = await sendDBCMessage(heartbeat); + } + + /// Checks all device's heartbeats and determines if they are still connected + void checkHeartbeats() { + final now = DateTime.timestamp(); + deviceHeartbeats.removeWhere((device, time) { + if (now.difference(time) > heartbeatTimeout) { + logger.warning( + "${device.name} disconnected from CAN bus", + body: "Broadcast message not received after $heartbeatTimeout", + ); + return true; + } + return false; + }); + } + + /// Sends a DBC message over the CAN bus + /// + /// Returns whether or not the message was successfully sent + Future sendDBCMessage(DBCMessage message) async { + if (socket == null || device == null || _resetFuture != null) { + return false; + } + + if (!device!.isUp) { + logger.warning( + "Device is not up while trying to send message", + body: "Restarting CAN interface", + ); + _resetFuture ??= Future(() async { + if (await bringUpCAN(canInterface)) { + // Wait a small amount after bringing up the device, for + // some reason device.isUp returns false for a short period + // of time after + await Future.delayed(const Duration(milliseconds: 100)); + } + }).whenComplete(() => _resetFuture = null); + return false; + } + + if (device!.state == CanState.busOff) { + logger.warning("Cannot send message, bus is off"); + return false; + } + + try { + await socket?.send( + CanFrame.standard(id: message.canId, data: message.encode()), + ); + return true; + } catch (error) { + if (error.toString().contains("No buffer space")) { + logger.debug("Error when sending CAN message", body: error.toString()); + } else { + logger.error("Error when sending CAN message", body: error.toString()); + } + return false; + } + } + + void _handleDeviceBroadcast(DeviceBroadcastMessage broadcast) { + final device = Device.valueOf(broadcast.deviceValue); + if (device == null) { + logger.warning( + "Unknown Device Number", + body: "Received broadcast from device ${broadcast.deviceValue}", + ); + return; + } + if (!deviceHeartbeats.containsKey(device)) { + logger.info("${device.name} connected via CAN bus"); + } + deviceHeartbeats[device] = DateTime.timestamp(); + + final versionProto = broadcast.toProtoMessage(); + if (versionProto != null) { + collection.server.sendMessage(versionProto); + } + } + + void _onCanFrame(CanFrame frame) { + if (frame is! CanDataFrame) return; + + final id = frame.id; + final data = frame.data; + + if (canIDToMessage[id] case final constructor?) { + collection.server.sendMessage(constructor(data)); + return; + } + + if (id != 0 && (id & 0xFF) == DeviceBroadcastMessage().canId) { + _handleDeviceBroadcast(DeviceBroadcastMessage.decode(data)); + return; + } + + logger.warning( + "Received message with unmapped ID: 0x${id.toRadixString(16).padLeft(2, '0')}", + ); + } +} diff --git a/subsystems/lib/src/devices/firmware.dart b/subsystems/lib/src/devices/firmware.dart index ee8acc9b..e7426613 100644 --- a/subsystems/lib/src/devices/firmware.dart +++ b/subsystems/lib/src/devices/firmware.dart @@ -7,14 +7,6 @@ import "package:burt_network/burt_network.dart"; import "serial_utils.dart"; -/// Maps command names to [Device]s. -final nameToDevice = { - ArmCommand().messageName: Device.ARM, - DriveCommand().messageName: Device.DRIVE, - ScienceCommand().messageName: Device.SCIENCE, - RelaysCommand().messageName: Device.RELAY, -}; - /// A service to manage all the connected firmware. /// /// Firmware means any device using the [Firmware-Utilities](https://github.com/BinghamtonRover/Firmware-Utilities) @@ -24,7 +16,7 @@ final nameToDevice = { /// This service relies on the [BurtFirmwareSerial] class defined in `package:burt_network`. That /// class takes care of connecting to, identifying, and streaming from a firmware device. This /// service is responsible for routing incoming UDP messages to the correct firmware device -/// ([_sendToSerial]), and forwarding serial messages to the Dashboard ([RoverSocket.sendWrapper]). +/// ([sendToSerial]), and forwarding serial messages to the Dashboard ([RoverSocket.sendWrapper]). class FirmwareManager extends Service { /// Subscriptions to each of the firmware devices. final List> _subscriptions = []; @@ -35,13 +27,17 @@ class FirmwareManager extends Service { @override Future init() async { devices = await getFirmwareDevices(); - collection.server.messages.listen(_sendToSerial); var result = true; for (final device in devices) { logger.debug("Initializing device: ${device.port}"); result &= await device.init(); if (!device.isReady) continue; - final subscription = device.messages.listen(collection.server.sendWrapper); + final subscription = device.messages.listen((message) { + // Don't send data if the device is also connected via CAN + if (!collection.can.deviceConnected(device.device)) { + collection.server.sendWrapper(message); + } + }); _subscriptions.add(subscription); } return result; @@ -60,12 +56,15 @@ class FirmwareManager extends Service { /// Sends a [WrappedMessage] to the correct Serial device. /// /// The notes on [sendMessage] apply here as well. - void _sendToSerial(WrappedMessage wrapper) { - final device = nameToDevice[wrapper.name]; - if (device == null) return; + /// + /// Returns whether or not the device corresponding to the command is connected. + bool sendToSerial(WrappedMessage wrapper) { + final device = commandToDevice[wrapper.name]; + if (device == null) return false; final serial = devices.firstWhereOrNull((s) => s.device == device); - if (serial == null) return; + if (serial == null) return false; serial.sendBytes(wrapper.data); + return true; } /// Sends a [Message] to the appropriate firmware device. @@ -73,5 +72,7 @@ class FirmwareManager extends Service { /// This does nothing if the appropriate device is not connected. Specifically, this is not an /// error because the Dashboard may be used during testing, when the hardware devices may not be /// assembled, connected, or functional yet. - void sendMessage(Message message) => _sendToSerial(message.wrap()); + /// + /// Returns whether or not the device for the message is connected + bool sendMessage(Message message) => sendToSerial(message.wrap()); } diff --git a/subsystems/lib/src/generated/rover_messages.dbc.dart b/subsystems/lib/src/generated/rover_messages.dbc.dart new file mode 100644 index 00000000..c03fb1cc --- /dev/null +++ b/subsystems/lib/src/generated/rover_messages.dbc.dart @@ -0,0 +1,3105 @@ +// AUTO GENERATED FILE, DO NOT MODIFY + +// ignore_for_file: type=lint +// ignore_for_file: annotate_overrides, camel_case_types, comment_references +// ignore_for_file: constant_identifier_names, library_prefixes +// ignore_for_file: non_constant_identifier_names, prefer_final_fields +// ignore_for_file: unnecessary_import, unnecessary_this, unused_import + +import 'dart:typed_data' as $_typed; + +import 'package:dart_dbc_generator/dart_dbc_generator.dart' as $_dbc; + +class DeviceBroadcastMessage extends $_dbc.DBCMessage { + @override + final String messageName = 'Device_Broadcast'; + + @override + final int messageLength = 2; + + @override + final int canId = 0x0; + + /// Whether or not "Device_Broadcast" is multiplex + static const bool isMultiplex = false; + + /// The multiplexor for "Device_Broadcast" + static const String multiplexor = ''; + + /// Value of signal "Device_Value" + int deviceValue; + + /// Value of signal "FW_Version_Major" + int fwVersionMajor; + + /// Value of signal "FW_Version_Minor" + int fwVersionMinor; + + final $_dbc.DBCSignal _deviceValueSignal = $_dbc.DBCSignal( + name: 'Device_Value', + signalSignedness: $_dbc.DBCSignalSignedness.UNSIGNED, + signalType: $_dbc.DBCSignalType.INTEL, + signalMode: $_dbc.DBCSignalMode.SIGNAL, + start: 0, + length: 5, + // dart format off + mapping: [1, 2, 4, 8, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + mappingIndexes: [0, 1, 2, 3, 4], + // dart format on + factor: 1, + offset: 0, + min: 0, + max: 15, + unit: '', + ); + + final $_dbc.DBCSignal _fwVersionMajorSignal = $_dbc.DBCSignal( + name: 'FW_Version_Major', + signalSignedness: $_dbc.DBCSignalSignedness.UNSIGNED, + signalType: $_dbc.DBCSignalType.INTEL, + signalMode: $_dbc.DBCSignalMode.SIGNAL, + start: 5, + length: 4, + // dart format off + mapping: [0, 0, 0, 0, 0, 1, 2, 4, 8, 0, 0, 0, 0, 0, 0, 0], + mappingIndexes: [5, 6, 7, 8], + // dart format on + factor: 1, + offset: 0, + min: 1, + max: 15, + unit: '', + ); + + final $_dbc.DBCSignal _fwVersionMinorSignal = $_dbc.DBCSignal( + name: 'FW_Version_Minor', + signalSignedness: $_dbc.DBCSignalSignedness.UNSIGNED, + signalType: $_dbc.DBCSignalType.INTEL, + signalMode: $_dbc.DBCSignalMode.SIGNAL, + start: 9, + length: 4, + // dart format off + mapping: [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 4, 8, 0, 0, 0], + mappingIndexes: [9, 10, 11, 12], + // dart format on + factor: 1, + offset: 0, + min: 0, + max: 15, + unit: '', + ); + + @override + List<$_dbc.DBCSignal> get signals => [ + _deviceValueSignal, + _fwVersionMajorSignal, + _fwVersionMinorSignal, + ]; + + DeviceBroadcastMessage({ + this.deviceValue = 0, + this.fwVersionMajor = 1, + this.fwVersionMinor = 0, + }); + + /// Creates a clone of this [DeviceBroadcastMessage] with the non-null values replaced + DeviceBroadcastMessage copyWith({ + int? deviceValue, + int? fwVersionMajor, + int? fwVersionMinor, + }) => DeviceBroadcastMessage( + deviceValue: deviceValue ?? this.deviceValue, + fwVersionMajor: fwVersionMajor ?? this.fwVersionMajor, + fwVersionMinor: fwVersionMinor ?? this.fwVersionMinor, + ); + + factory DeviceBroadcastMessage.decode(List payload) { + final message = DeviceBroadcastMessage(); + final typedBuffer = $_typed.Uint8List.fromList(payload); + final bitField = $_dbc.BitField.from( + typedBuffer.sublist(0, message.messageLength), + ); + + message.deviceValue = (message._deviceValueSignal.decode(bitField) ?? 0) + .toInt(); + message.fwVersionMajor = + (message._fwVersionMajorSignal.decode(bitField) ?? 1).toInt(); + message.fwVersionMinor = + (message._fwVersionMinorSignal.decode(bitField) ?? 0).toInt(); + + return message; + } + + factory DeviceBroadcastMessage.fromJson(Map json) => + DeviceBroadcastMessage( + deviceValue: json['Device_Value'] ?? 0, + fwVersionMajor: json['FW_Version_Major'] ?? 1, + fwVersionMinor: json['FW_Version_Minor'] ?? 0, + ); + + @override + $_typed.Uint8List encode() { + final Map<$_dbc.DBCSignal, num> values = { + _deviceValueSignal: deviceValue, + _fwVersionMajorSignal: fwVersionMajor, + _fwVersionMinorSignal: fwVersionMinor, + }; + + return encodeWithValues(values); + } + + @override + Map toJson() => { + 'Device_Value': deviceValue, + 'FW_Version_Major': fwVersionMajor, + 'FW_Version_Minor': fwVersionMinor, + }; + + @override + String toString() => + 'Device_Broadcast(\n Device_Value=$deviceValue\n FW_Version_Major=$fwVersionMajor\n FW_Version_Minor=$fwVersionMinor\n)'; +} + +class RoverHeartbeatMessage extends $_dbc.DBCMessage { + @override + final String messageName = 'Rover_Heartbeat'; + + @override + final int messageLength = 1; + + @override + final int canId = 0x1; + + /// Whether or not "Rover_Heartbeat" is multiplex + static const bool isMultiplex = false; + + /// The multiplexor for "Rover_Heartbeat" + static const String multiplexor = ''; + + /// Value of signal "Rover_Status" + int roverStatus; + + final $_dbc.DBCSignal _roverStatusSignal = $_dbc.DBCSignal( + name: 'Rover_Status', + signalSignedness: $_dbc.DBCSignalSignedness.UNSIGNED, + signalType: $_dbc.DBCSignalType.INTEL, + signalMode: $_dbc.DBCSignalMode.SIGNAL, + start: 0, + length: 4, + // dart format off + mapping: [1, 2, 4, 8, 0, 0, 0, 0], + mappingIndexes: [0, 1, 2, 3], + // dart format on + factor: 1, + offset: 0, + min: 0, + max: 5, + unit: '', + ); + + @override + List<$_dbc.DBCSignal> get signals => [_roverStatusSignal]; + + RoverHeartbeatMessage({this.roverStatus = 0}); + + /// Creates a clone of this [RoverHeartbeatMessage] with the non-null values replaced + RoverHeartbeatMessage copyWith({int? roverStatus}) => + RoverHeartbeatMessage(roverStatus: roverStatus ?? this.roverStatus); + + factory RoverHeartbeatMessage.decode(List payload) { + final message = RoverHeartbeatMessage(); + final typedBuffer = $_typed.Uint8List.fromList(payload); + final bitField = $_dbc.BitField.from( + typedBuffer.sublist(0, message.messageLength), + ); + + message.roverStatus = (message._roverStatusSignal.decode(bitField) ?? 0) + .toInt(); + + return message; + } + + factory RoverHeartbeatMessage.fromJson(Map json) => + RoverHeartbeatMessage(roverStatus: json['Rover_Status'] ?? 0); + + @override + $_typed.Uint8List encode() { + final Map<$_dbc.DBCSignal, num> values = {_roverStatusSignal: roverStatus}; + + return encodeWithValues(values); + } + + @override + Map toJson() => {'Rover_Status': roverStatus}; + + @override + String toString() => 'Rover_Heartbeat(\n Rover_Status=$roverStatus\n)'; +} + +class DriveSetSpeedsMessage extends $_dbc.DBCMessage { + @override + final String messageName = 'Drive_Set_Speeds'; + + @override + final int messageLength = 7; + + @override + final int canId = 0x101; + + /// Whether or not "Drive_Set_Speeds" is multiplex + static const bool isMultiplex = false; + + /// The multiplexor for "Drive_Set_Speeds" + static const String multiplexor = ''; + + /// Value of signal "Should_Set_Left" + int shouldSetLeft; + + /// Value of signal "Should_Set_Right" + int shouldSetRight; + + /// Value of signal "Should_Set_Throttle" + int shouldSetThrottle; + + /// Value of signal "Left_Speed" + double leftSpeed; + + /// Value of signal "Right_Speed" + double rightSpeed; + + /// Value of signal "Throttle" + double throttle; + + final $_dbc.DBCSignal _shouldSetLeftSignal = $_dbc.DBCSignal( + name: 'Should_Set_Left', + signalSignedness: $_dbc.DBCSignalSignedness.UNSIGNED, + signalType: $_dbc.DBCSignalType.INTEL, + signalMode: $_dbc.DBCSignalMode.SIGNAL, + start: 0, + length: 1, + // dart format off + mapping: [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + mappingIndexes: [0], + // dart format on + factor: 1, + offset: 0, + min: 0, + max: 1, + unit: '', + ); + + final $_dbc.DBCSignal _shouldSetRightSignal = $_dbc.DBCSignal( + name: 'Should_Set_Right', + signalSignedness: $_dbc.DBCSignalSignedness.UNSIGNED, + signalType: $_dbc.DBCSignalType.INTEL, + signalMode: $_dbc.DBCSignalMode.SIGNAL, + start: 1, + length: 1, + // dart format off + mapping: [0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + mappingIndexes: [1], + // dart format on + factor: 1, + offset: 0, + min: 0, + max: 1, + unit: '', + ); + + final $_dbc.DBCSignal _shouldSetThrottleSignal = $_dbc.DBCSignal( + name: 'Should_Set_Throttle', + signalSignedness: $_dbc.DBCSignalSignedness.UNSIGNED, + signalType: $_dbc.DBCSignalType.INTEL, + signalMode: $_dbc.DBCSignalMode.SIGNAL, + start: 2, + length: 1, + // dart format off + mapping: [0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + mappingIndexes: [2], + // dart format on + factor: 1, + offset: 0, + min: 0, + max: 1, + unit: '', + ); + + final $_dbc.DBCSignal _leftSpeedSignal = $_dbc.DBCSignal( + name: 'Left_Speed', + signalSignedness: $_dbc.DBCSignalSignedness.SIGNED, + signalType: $_dbc.DBCSignalType.INTEL, + signalMode: $_dbc.DBCSignalMode.SIGNAL, + start: 3, + length: 16, + // dart format off + mapping: [0, 0, 0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + mappingIndexes: [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18], + // dart format on + factor: 0.00003051850947599719, + offset: 0, + min: -1, + max: 1, + unit: '', + ); + + final $_dbc.DBCSignal _rightSpeedSignal = $_dbc.DBCSignal( + name: 'Right_Speed', + signalSignedness: $_dbc.DBCSignalSignedness.SIGNED, + signalType: $_dbc.DBCSignalType.INTEL, + signalMode: $_dbc.DBCSignalMode.SIGNAL, + start: 19, + length: 16, + // dart format off + mapping: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + mappingIndexes: [19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34], + // dart format on + factor: 0.00003051850947599719, + offset: 0, + min: -1, + max: 1, + unit: '', + ); + + final $_dbc.DBCSignal _throttleSignal = $_dbc.DBCSignal( + name: 'Throttle', + signalSignedness: $_dbc.DBCSignalSignedness.UNSIGNED, + signalType: $_dbc.DBCSignalType.INTEL, + signalMode: $_dbc.DBCSignalMode.SIGNAL, + start: 35, + length: 16, + // dart format off + mapping: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 0, 0, 0, 0, 0], + mappingIndexes: [35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50], + // dart format on + factor: 0.000015259254737998596, + offset: 0, + min: 0, + max: 1, + unit: '', + ); + + @override + List<$_dbc.DBCSignal> get signals => [ + _shouldSetLeftSignal, + _shouldSetRightSignal, + _shouldSetThrottleSignal, + _leftSpeedSignal, + _rightSpeedSignal, + _throttleSignal, + ]; + + DriveSetSpeedsMessage({ + this.shouldSetLeft = 0, + this.shouldSetRight = 0, + this.shouldSetThrottle = 0, + this.leftSpeed = 0, + this.rightSpeed = 0, + this.throttle = 0, + }); + + /// Creates a clone of this [DriveSetSpeedsMessage] with the non-null values replaced + DriveSetSpeedsMessage copyWith({ + int? shouldSetLeft, + int? shouldSetRight, + int? shouldSetThrottle, + double? leftSpeed, + double? rightSpeed, + double? throttle, + }) => DriveSetSpeedsMessage( + shouldSetLeft: shouldSetLeft ?? this.shouldSetLeft, + shouldSetRight: shouldSetRight ?? this.shouldSetRight, + shouldSetThrottle: shouldSetThrottle ?? this.shouldSetThrottle, + leftSpeed: leftSpeed ?? this.leftSpeed, + rightSpeed: rightSpeed ?? this.rightSpeed, + throttle: throttle ?? this.throttle, + ); + + factory DriveSetSpeedsMessage.decode(List payload) { + final message = DriveSetSpeedsMessage(); + final typedBuffer = $_typed.Uint8List.fromList(payload); + final bitField = $_dbc.BitField.from( + typedBuffer.sublist(0, message.messageLength), + ); + + message.shouldSetLeft = (message._shouldSetLeftSignal.decode(bitField) ?? 0) + .toInt(); + message.shouldSetRight = + (message._shouldSetRightSignal.decode(bitField) ?? 0).toInt(); + message.shouldSetThrottle = + (message._shouldSetThrottleSignal.decode(bitField) ?? 0).toInt(); + message.leftSpeed = (message._leftSpeedSignal.decode(bitField) ?? 0) + .toDouble(); + message.rightSpeed = (message._rightSpeedSignal.decode(bitField) ?? 0) + .toDouble(); + message.throttle = (message._throttleSignal.decode(bitField) ?? 0) + .toDouble(); + + return message; + } + + factory DriveSetSpeedsMessage.fromJson(Map json) => + DriveSetSpeedsMessage( + shouldSetLeft: json['Should_Set_Left'] ?? 0, + shouldSetRight: json['Should_Set_Right'] ?? 0, + shouldSetThrottle: json['Should_Set_Throttle'] ?? 0, + leftSpeed: json['Left_Speed'] ?? 0, + rightSpeed: json['Right_Speed'] ?? 0, + throttle: json['Throttle'] ?? 0, + ); + + @override + $_typed.Uint8List encode() { + final Map<$_dbc.DBCSignal, num> values = { + _shouldSetLeftSignal: shouldSetLeft, + _shouldSetRightSignal: shouldSetRight, + _shouldSetThrottleSignal: shouldSetThrottle, + _leftSpeedSignal: leftSpeed, + _rightSpeedSignal: rightSpeed, + _throttleSignal: throttle, + }; + + return encodeWithValues(values); + } + + @override + Map toJson() => { + 'Should_Set_Left': shouldSetLeft, + 'Should_Set_Right': shouldSetRight, + 'Should_Set_Throttle': shouldSetThrottle, + 'Left_Speed': leftSpeed, + 'Right_Speed': rightSpeed, + 'Throttle': throttle, + }; + + @override + String toString() => + 'Drive_Set_Speeds(\n Should_Set_Left=$shouldSetLeft\n Should_Set_Right=$shouldSetRight\n Should_Set_Throttle=$shouldSetThrottle\n Left_Speed=$leftSpeed\n Right_Speed=$rightSpeed\n Throttle=$throttle\n)'; +} + +class DriveSetLedMessage extends $_dbc.DBCMessage { + @override + final String messageName = 'Drive_Set_LED'; + + @override + final int messageLength = 1; + + @override + final int canId = 0x102; + + /// Whether or not "Drive_Set_LED" is multiplex + static const bool isMultiplex = false; + + /// The multiplexor for "Drive_Set_LED" + static const String multiplexor = ''; + + /// Value of signal "Color" + int color; + + /// Value of signal "Blink" + int blink; + + final $_dbc.DBCSignal _colorSignal = $_dbc.DBCSignal( + name: 'Color', + signalSignedness: $_dbc.DBCSignalSignedness.UNSIGNED, + signalType: $_dbc.DBCSignalType.INTEL, + signalMode: $_dbc.DBCSignalMode.SIGNAL, + start: 0, + length: 4, + // dart format off + mapping: [1, 2, 4, 8, 0, 0, 0, 0], + mappingIndexes: [0, 1, 2, 3], + // dart format on + factor: 1, + offset: 0, + min: 0, + max: 8, + unit: '', + ); + + final $_dbc.DBCSignal _blinkSignal = $_dbc.DBCSignal( + name: 'Blink', + signalSignedness: $_dbc.DBCSignalSignedness.UNSIGNED, + signalType: $_dbc.DBCSignalType.INTEL, + signalMode: $_dbc.DBCSignalMode.SIGNAL, + start: 4, + length: 1, + // dart format off + mapping: [0, 0, 0, 0, 1, 0, 0, 0], + mappingIndexes: [4], + // dart format on + factor: 1, + offset: 0, + min: 0, + max: 1, + unit: '', + ); + + @override + List<$_dbc.DBCSignal> get signals => [_colorSignal, _blinkSignal]; + + DriveSetLedMessage({this.color = 0, this.blink = 0}); + + /// Creates a clone of this [DriveSetLedMessage] with the non-null values replaced + DriveSetLedMessage copyWith({int? color, int? blink}) => DriveSetLedMessage( + color: color ?? this.color, + blink: blink ?? this.blink, + ); + + factory DriveSetLedMessage.decode(List payload) { + final message = DriveSetLedMessage(); + final typedBuffer = $_typed.Uint8List.fromList(payload); + final bitField = $_dbc.BitField.from( + typedBuffer.sublist(0, message.messageLength), + ); + + message.color = (message._colorSignal.decode(bitField) ?? 0).toInt(); + message.blink = (message._blinkSignal.decode(bitField) ?? 0).toInt(); + + return message; + } + + factory DriveSetLedMessage.fromJson(Map json) => + DriveSetLedMessage(color: json['Color'] ?? 0, blink: json['Blink'] ?? 0); + + @override + $_typed.Uint8List encode() { + final Map<$_dbc.DBCSignal, num> values = { + _colorSignal: color, + _blinkSignal: blink, + }; + + return encodeWithValues(values); + } + + @override + Map toJson() => {'Color': color, 'Blink': blink}; + + @override + String toString() => 'Drive_Set_LED(\n Color=$color\n Blink=$blink\n)'; +} + +class DriveSetSwivelMessage extends $_dbc.DBCMessage { + @override + final String messageName = 'Drive_Set_Swivel'; + + @override + final int messageLength = 7; + + @override + final int canId = 0x103; + + /// Whether or not "Drive_Set_Swivel" is multiplex + static const bool isMultiplex = false; + + /// The multiplexor for "Drive_Set_Swivel" + static const String multiplexor = ''; + + /// Value of signal "Set_Front_Swivel" + int setFrontSwivel; + + /// Value of signal "Set_Front_Tilt" + int setFrontTilt; + + /// Value of signal "Set_Rear_Swivel" + int setRearSwivel; + + /// Value of signal "Set_Rear_Tilt" + int setRearTilt; + + /// Value of signal "Front_Swivel" + double frontSwivel; + + /// Value of signal "Front_Tilt" + double frontTilt; + + /// Value of signal "Rear_Swivel" + double rearSwivel; + + /// Value of signal "Rear_Tilt" + double rearTilt; + + final $_dbc.DBCSignal _setFrontSwivelSignal = $_dbc.DBCSignal( + name: 'Set_Front_Swivel', + signalSignedness: $_dbc.DBCSignalSignedness.UNSIGNED, + signalType: $_dbc.DBCSignalType.INTEL, + signalMode: $_dbc.DBCSignalMode.SIGNAL, + start: 0, + length: 1, + // dart format off + mapping: [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + mappingIndexes: [0], + // dart format on + factor: 1, + offset: 0, + min: 0, + max: 1, + unit: '', + ); + + final $_dbc.DBCSignal _setFrontTiltSignal = $_dbc.DBCSignal( + name: 'Set_Front_Tilt', + signalSignedness: $_dbc.DBCSignalSignedness.UNSIGNED, + signalType: $_dbc.DBCSignalType.INTEL, + signalMode: $_dbc.DBCSignalMode.SIGNAL, + start: 1, + length: 1, + // dart format off + mapping: [0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + mappingIndexes: [1], + // dart format on + factor: 1, + offset: 0, + min: 0, + max: 1, + unit: '', + ); + + final $_dbc.DBCSignal _setRearSwivelSignal = $_dbc.DBCSignal( + name: 'Set_Rear_Swivel', + signalSignedness: $_dbc.DBCSignalSignedness.UNSIGNED, + signalType: $_dbc.DBCSignalType.INTEL, + signalMode: $_dbc.DBCSignalMode.SIGNAL, + start: 2, + length: 1, + // dart format off + mapping: [0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + mappingIndexes: [2], + // dart format on + factor: 1, + offset: 0, + min: 0, + max: 1, + unit: '', + ); + + final $_dbc.DBCSignal _setRearTiltSignal = $_dbc.DBCSignal( + name: 'Set_Rear_Tilt', + signalSignedness: $_dbc.DBCSignalSignedness.UNSIGNED, + signalType: $_dbc.DBCSignalType.INTEL, + signalMode: $_dbc.DBCSignalMode.SIGNAL, + start: 3, + length: 1, + // dart format off + mapping: [0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + mappingIndexes: [3], + // dart format on + factor: 1, + offset: 0, + min: 0, + max: 1, + unit: '', + ); + + final $_dbc.DBCSignal _frontSwivelSignal = $_dbc.DBCSignal( + name: 'Front_Swivel', + signalSignedness: $_dbc.DBCSignalSignedness.SIGNED, + signalType: $_dbc.DBCSignalType.INTEL, + signalMode: $_dbc.DBCSignalMode.SIGNAL, + start: 4, + length: 12, + // dart format off + mapping: [0, 0, 0, 0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + mappingIndexes: [4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], + // dart format on + factor: 0.04396678065461651, + offset: 0, + min: -90, + max: 90, + unit: '°', + ); + + final $_dbc.DBCSignal _frontTiltSignal = $_dbc.DBCSignal( + name: 'Front_Tilt', + signalSignedness: $_dbc.DBCSignalSignedness.SIGNED, + signalType: $_dbc.DBCSignalType.INTEL, + signalMode: $_dbc.DBCSignalMode.SIGNAL, + start: 16, + length: 12, + // dart format off + mapping: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + mappingIndexes: [16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27], + // dart format on + factor: 0.04396678065461651, + offset: 0, + min: -90, + max: 90, + unit: '°', + ); + + final $_dbc.DBCSignal _rearSwivelSignal = $_dbc.DBCSignal( + name: 'Rear_Swivel', + signalSignedness: $_dbc.DBCSignalSignedness.SIGNED, + signalType: $_dbc.DBCSignalType.INTEL, + signalMode: $_dbc.DBCSignalMode.SIGNAL, + start: 28, + length: 12, + // dart format off + mapping: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + mappingIndexes: [28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39], + // dart format on + factor: 0.04396678065461651, + offset: 0, + min: -90, + max: 90, + unit: '°', + ); + + final $_dbc.DBCSignal _rearTiltSignal = $_dbc.DBCSignal( + name: 'Rear_Tilt', + signalSignedness: $_dbc.DBCSignalSignedness.SIGNED, + signalType: $_dbc.DBCSignalType.INTEL, + signalMode: $_dbc.DBCSignalMode.SIGNAL, + start: 40, + length: 12, + // dart format off + mapping: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 0, 0, 0, 0], + mappingIndexes: [40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51], + // dart format on + factor: 0.04396678065461651, + offset: 0, + min: -90, + max: 90, + unit: '°', + ); + + @override + List<$_dbc.DBCSignal> get signals => [ + _setFrontSwivelSignal, + _setFrontTiltSignal, + _setRearSwivelSignal, + _setRearTiltSignal, + _frontSwivelSignal, + _frontTiltSignal, + _rearSwivelSignal, + _rearTiltSignal, + ]; + + DriveSetSwivelMessage({ + this.setFrontSwivel = 0, + this.setFrontTilt = 0, + this.setRearSwivel = 0, + this.setRearTilt = 0, + this.frontSwivel = 0, + this.frontTilt = 0, + this.rearSwivel = 0, + this.rearTilt = 0, + }); + + /// Creates a clone of this [DriveSetSwivelMessage] with the non-null values replaced + DriveSetSwivelMessage copyWith({ + int? setFrontSwivel, + int? setFrontTilt, + int? setRearSwivel, + int? setRearTilt, + double? frontSwivel, + double? frontTilt, + double? rearSwivel, + double? rearTilt, + }) => DriveSetSwivelMessage( + setFrontSwivel: setFrontSwivel ?? this.setFrontSwivel, + setFrontTilt: setFrontTilt ?? this.setFrontTilt, + setRearSwivel: setRearSwivel ?? this.setRearSwivel, + setRearTilt: setRearTilt ?? this.setRearTilt, + frontSwivel: frontSwivel ?? this.frontSwivel, + frontTilt: frontTilt ?? this.frontTilt, + rearSwivel: rearSwivel ?? this.rearSwivel, + rearTilt: rearTilt ?? this.rearTilt, + ); + + factory DriveSetSwivelMessage.decode(List payload) { + final message = DriveSetSwivelMessage(); + final typedBuffer = $_typed.Uint8List.fromList(payload); + final bitField = $_dbc.BitField.from( + typedBuffer.sublist(0, message.messageLength), + ); + + message.setFrontSwivel = + (message._setFrontSwivelSignal.decode(bitField) ?? 0).toInt(); + message.setFrontTilt = (message._setFrontTiltSignal.decode(bitField) ?? 0) + .toInt(); + message.setRearSwivel = (message._setRearSwivelSignal.decode(bitField) ?? 0) + .toInt(); + message.setRearTilt = (message._setRearTiltSignal.decode(bitField) ?? 0) + .toInt(); + message.frontSwivel = (message._frontSwivelSignal.decode(bitField) ?? 0) + .toDouble(); + message.frontTilt = (message._frontTiltSignal.decode(bitField) ?? 0) + .toDouble(); + message.rearSwivel = (message._rearSwivelSignal.decode(bitField) ?? 0) + .toDouble(); + message.rearTilt = (message._rearTiltSignal.decode(bitField) ?? 0) + .toDouble(); + + return message; + } + + factory DriveSetSwivelMessage.fromJson(Map json) => + DriveSetSwivelMessage( + setFrontSwivel: json['Set_Front_Swivel'] ?? 0, + setFrontTilt: json['Set_Front_Tilt'] ?? 0, + setRearSwivel: json['Set_Rear_Swivel'] ?? 0, + setRearTilt: json['Set_Rear_Tilt'] ?? 0, + frontSwivel: json['Front_Swivel'] ?? 0, + frontTilt: json['Front_Tilt'] ?? 0, + rearSwivel: json['Rear_Swivel'] ?? 0, + rearTilt: json['Rear_Tilt'] ?? 0, + ); + + @override + $_typed.Uint8List encode() { + final Map<$_dbc.DBCSignal, num> values = { + _setFrontSwivelSignal: setFrontSwivel, + _setFrontTiltSignal: setFrontTilt, + _setRearSwivelSignal: setRearSwivel, + _setRearTiltSignal: setRearTilt, + _frontSwivelSignal: frontSwivel, + _frontTiltSignal: frontTilt, + _rearSwivelSignal: rearSwivel, + _rearTiltSignal: rearTilt, + }; + + return encodeWithValues(values); + } + + @override + Map toJson() => { + 'Set_Front_Swivel': setFrontSwivel, + 'Set_Front_Tilt': setFrontTilt, + 'Set_Rear_Swivel': setRearSwivel, + 'Set_Rear_Tilt': setRearTilt, + 'Front_Swivel': frontSwivel, + 'Front_Tilt': frontTilt, + 'Rear_Swivel': rearSwivel, + 'Rear_Tilt': rearTilt, + }; + + @override + String toString() => + 'Drive_Set_Swivel(\n Set_Front_Swivel=$setFrontSwivel\n Set_Front_Tilt=$setFrontTilt\n Set_Rear_Swivel=$setRearSwivel\n Set_Rear_Tilt=$setRearTilt\n Front_Swivel=$frontSwivel\n Front_Tilt=$frontTilt\n Rear_Swivel=$rearSwivel\n Rear_Tilt=$rearTilt\n)'; +} + +class DriveAppliedOutputDataMessage extends $_dbc.DBCMessage { + @override + final String messageName = 'Drive_Applied_Output_Data'; + + @override + final int messageLength = 6; + + @override + final int canId = 0x105; + + /// Whether or not "Drive_Applied_Output_Data" is multiplex + static const bool isMultiplex = false; + + /// The multiplexor for "Drive_Applied_Output_Data" + static const String multiplexor = ''; + + /// Value of signal "Throttle" + double throttle; + + /// Value of signal "Left_Speed" + double leftSpeed; + + /// Value of signal "Right_Speed" + double rightSpeed; + + final $_dbc.DBCSignal _throttleSignal = $_dbc.DBCSignal( + name: 'Throttle', + signalSignedness: $_dbc.DBCSignalSignedness.UNSIGNED, + signalType: $_dbc.DBCSignalType.INTEL, + signalMode: $_dbc.DBCSignalMode.SIGNAL, + start: 0, + length: 16, + // dart format off + mapping: [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + mappingIndexes: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], + // dart format on + factor: 0.000015259254737998596, + offset: 0, + min: 0, + max: 1, + unit: '', + ); + + final $_dbc.DBCSignal _leftSpeedSignal = $_dbc.DBCSignal( + name: 'Left_Speed', + signalSignedness: $_dbc.DBCSignalSignedness.SIGNED, + signalType: $_dbc.DBCSignalType.INTEL, + signalMode: $_dbc.DBCSignalMode.SIGNAL, + start: 16, + length: 16, + // dart format off + mapping: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + mappingIndexes: [16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31], + // dart format on + factor: 0.00003051850947599719, + offset: 0, + min: -1, + max: 1, + unit: '', + ); + + final $_dbc.DBCSignal _rightSpeedSignal = $_dbc.DBCSignal( + name: 'Right_Speed', + signalSignedness: $_dbc.DBCSignalSignedness.SIGNED, + signalType: $_dbc.DBCSignalType.INTEL, + signalMode: $_dbc.DBCSignalMode.SIGNAL, + start: 32, + length: 16, + // dart format off + mapping: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768], + mappingIndexes: [32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47], + // dart format on + factor: 0.00003051850947599719, + offset: 0, + min: -1, + max: 1, + unit: '', + ); + + @override + List<$_dbc.DBCSignal> get signals => [ + _throttleSignal, + _leftSpeedSignal, + _rightSpeedSignal, + ]; + + DriveAppliedOutputDataMessage({ + this.throttle = 0, + this.leftSpeed = 0, + this.rightSpeed = 0, + }); + + /// Creates a clone of this [DriveAppliedOutputDataMessage] with the non-null values replaced + DriveAppliedOutputDataMessage copyWith({ + double? throttle, + double? leftSpeed, + double? rightSpeed, + }) => DriveAppliedOutputDataMessage( + throttle: throttle ?? this.throttle, + leftSpeed: leftSpeed ?? this.leftSpeed, + rightSpeed: rightSpeed ?? this.rightSpeed, + ); + + factory DriveAppliedOutputDataMessage.decode(List payload) { + final message = DriveAppliedOutputDataMessage(); + final typedBuffer = $_typed.Uint8List.fromList(payload); + final bitField = $_dbc.BitField.from( + typedBuffer.sublist(0, message.messageLength), + ); + + message.throttle = (message._throttleSignal.decode(bitField) ?? 0) + .toDouble(); + message.leftSpeed = (message._leftSpeedSignal.decode(bitField) ?? 0) + .toDouble(); + message.rightSpeed = (message._rightSpeedSignal.decode(bitField) ?? 0) + .toDouble(); + + return message; + } + + factory DriveAppliedOutputDataMessage.fromJson(Map json) => + DriveAppliedOutputDataMessage( + throttle: json['Throttle'] ?? 0, + leftSpeed: json['Left_Speed'] ?? 0, + rightSpeed: json['Right_Speed'] ?? 0, + ); + + @override + $_typed.Uint8List encode() { + final Map<$_dbc.DBCSignal, num> values = { + _throttleSignal: throttle, + _leftSpeedSignal: leftSpeed, + _rightSpeedSignal: rightSpeed, + }; + + return encodeWithValues(values); + } + + @override + Map toJson() => { + 'Throttle': throttle, + 'Left_Speed': leftSpeed, + 'Right_Speed': rightSpeed, + }; + + @override + String toString() => + 'Drive_Applied_Output_Data(\n Throttle=$throttle\n Left_Speed=$leftSpeed\n Right_Speed=$rightSpeed\n)'; +} + +class DriveBatteryDataMessage extends $_dbc.DBCMessage { + @override + final String messageName = 'Drive_Battery_Data'; + + @override + final int messageLength = 5; + + @override + final int canId = 0x106; + + /// Whether or not "Drive_Battery_Data" is multiplex + static const bool isMultiplex = false; + + /// The multiplexor for "Drive_Battery_Data" + static const String multiplexor = ''; + + /// Value of signal "Voltage" + double voltage; + + /// Value of signal "Temperature" + double temperature; + + /// Value of signal "Current" + double current; + + final $_dbc.DBCSignal _voltageSignal = $_dbc.DBCSignal( + name: 'Voltage', + signalSignedness: $_dbc.DBCSignalSignedness.UNSIGNED, + signalType: $_dbc.DBCSignalType.INTEL, + signalMode: $_dbc.DBCSignalMode.SIGNAL, + start: 0, + length: 10, + // dart format off + mapping: [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + mappingIndexes: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], + // dart format on + factor: 0.03548387097, + offset: 0, + min: 0, + max: 36.3, + unit: 'V', + ); + + final $_dbc.DBCSignal _temperatureSignal = $_dbc.DBCSignal( + name: 'Temperature', + signalSignedness: $_dbc.DBCSignalSignedness.SIGNED, + signalType: $_dbc.DBCSignalType.INTEL, + signalMode: $_dbc.DBCSignalMode.SIGNAL, + start: 10, + length: 12, + // dart format off + mapping: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + mappingIndexes: [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21], + // dart format on + factor: 0.046409379579872984, + offset: 55, + min: -40, + max: 150, + unit: '°C', + ); + + final $_dbc.DBCSignal _currentSignal = $_dbc.DBCSignal( + name: 'Current', + signalSignedness: $_dbc.DBCSignalSignedness.UNSIGNED, + signalType: $_dbc.DBCSignalType.INTEL, + signalMode: $_dbc.DBCSignalMode.SIGNAL, + start: 22, + length: 16, + // dart format off + mapping: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 0, 0], + mappingIndexes: [22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37], + // dart format on + factor: 0.0004577776421399579, + offset: 0, + min: 0, + max: 30, + unit: 'A', + ); + + @override + List<$_dbc.DBCSignal> get signals => [ + _voltageSignal, + _temperatureSignal, + _currentSignal, + ]; + + DriveBatteryDataMessage({ + this.voltage = 0, + this.temperature = 55, + this.current = 0, + }); + + /// Creates a clone of this [DriveBatteryDataMessage] with the non-null values replaced + DriveBatteryDataMessage copyWith({ + double? voltage, + double? temperature, + double? current, + }) => DriveBatteryDataMessage( + voltage: voltage ?? this.voltage, + temperature: temperature ?? this.temperature, + current: current ?? this.current, + ); + + factory DriveBatteryDataMessage.decode(List payload) { + final message = DriveBatteryDataMessage(); + final typedBuffer = $_typed.Uint8List.fromList(payload); + final bitField = $_dbc.BitField.from( + typedBuffer.sublist(0, message.messageLength), + ); + + message.voltage = (message._voltageSignal.decode(bitField) ?? 0).toDouble(); + message.temperature = (message._temperatureSignal.decode(bitField) ?? 0) + .toDouble(); + message.current = (message._currentSignal.decode(bitField) ?? 0).toDouble(); + + return message; + } + + factory DriveBatteryDataMessage.fromJson(Map json) => + DriveBatteryDataMessage( + voltage: json['Voltage'] ?? 0, + temperature: json['Temperature'] ?? 55, + current: json['Current'] ?? 0, + ); + + @override + $_typed.Uint8List encode() { + final Map<$_dbc.DBCSignal, num> values = { + _voltageSignal: voltage, + _temperatureSignal: temperature, + _currentSignal: current, + }; + + return encodeWithValues(values); + } + + @override + Map toJson() => { + 'Voltage': voltage, + 'Temperature': temperature, + 'Current': current, + }; + + @override + String toString() => + 'Drive_Battery_Data(\n Voltage=$voltage\n Temperature=$temperature\n Current=$current\n)'; +} + +class DriveLedDataMessage extends $_dbc.DBCMessage { + @override + final String messageName = 'Drive_LED_Data'; + + @override + final int messageLength = 1; + + @override + final int canId = 0x107; + + /// Whether or not "Drive_LED_Data" is multiplex + static const bool isMultiplex = false; + + /// The multiplexor for "Drive_LED_Data" + static const String multiplexor = ''; + + /// Value of signal "Color" + int color; + + /// Value of signal "Blink" + int blink; + + final $_dbc.DBCSignal _colorSignal = $_dbc.DBCSignal( + name: 'Color', + signalSignedness: $_dbc.DBCSignalSignedness.UNSIGNED, + signalType: $_dbc.DBCSignalType.INTEL, + signalMode: $_dbc.DBCSignalMode.SIGNAL, + start: 0, + length: 4, + // dart format off + mapping: [1, 2, 4, 8, 0, 0, 0, 0], + mappingIndexes: [0, 1, 2, 3], + // dart format on + factor: 1, + offset: 0, + min: 0, + max: 8, + unit: '', + ); + + final $_dbc.DBCSignal _blinkSignal = $_dbc.DBCSignal( + name: 'Blink', + signalSignedness: $_dbc.DBCSignalSignedness.UNSIGNED, + signalType: $_dbc.DBCSignalType.INTEL, + signalMode: $_dbc.DBCSignalMode.SIGNAL, + start: 4, + length: 1, + // dart format off + mapping: [0, 0, 0, 0, 1, 0, 0, 0], + mappingIndexes: [4], + // dart format on + factor: 1, + offset: 0, + min: 0, + max: 1, + unit: '', + ); + + @override + List<$_dbc.DBCSignal> get signals => [_colorSignal, _blinkSignal]; + + DriveLedDataMessage({this.color = 0, this.blink = 0}); + + /// Creates a clone of this [DriveLedDataMessage] with the non-null values replaced + DriveLedDataMessage copyWith({int? color, int? blink}) => DriveLedDataMessage( + color: color ?? this.color, + blink: blink ?? this.blink, + ); + + factory DriveLedDataMessage.decode(List payload) { + final message = DriveLedDataMessage(); + final typedBuffer = $_typed.Uint8List.fromList(payload); + final bitField = $_dbc.BitField.from( + typedBuffer.sublist(0, message.messageLength), + ); + + message.color = (message._colorSignal.decode(bitField) ?? 0).toInt(); + message.blink = (message._blinkSignal.decode(bitField) ?? 0).toInt(); + + return message; + } + + factory DriveLedDataMessage.fromJson(Map json) => + DriveLedDataMessage(color: json['Color'] ?? 0, blink: json['Blink'] ?? 0); + + @override + $_typed.Uint8List encode() { + final Map<$_dbc.DBCSignal, num> values = { + _colorSignal: color, + _blinkSignal: blink, + }; + + return encodeWithValues(values); + } + + @override + Map toJson() => {'Color': color, 'Blink': blink}; + + @override + String toString() => 'Drive_LED_Data(\n Color=$color\n Blink=$blink\n)'; +} + +class DriveSwivelDataMessage extends $_dbc.DBCMessage { + @override + final String messageName = 'Drive_Swivel_Data'; + + @override + final int messageLength = 6; + + @override + final int canId = 0x108; + + /// Whether or not "Drive_Swivel_Data" is multiplex + static const bool isMultiplex = false; + + /// The multiplexor for "Drive_Swivel_Data" + static const String multiplexor = ''; + + /// Value of signal "Front_Swivel" + double frontSwivel; + + /// Value of signal "Front_Tilt" + double frontTilt; + + /// Value of signal "Rear_Swivel" + double rearSwivel; + + /// Value of signal "Rear_Tilt" + double rearTilt; + + final $_dbc.DBCSignal _frontSwivelSignal = $_dbc.DBCSignal( + name: 'Front_Swivel', + signalSignedness: $_dbc.DBCSignalSignedness.SIGNED, + signalType: $_dbc.DBCSignalType.INTEL, + signalMode: $_dbc.DBCSignalMode.SIGNAL, + start: 0, + length: 12, + // dart format off + mapping: [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + mappingIndexes: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11], + // dart format on + factor: 0.04396678065461651, + offset: 0, + min: -90, + max: 90, + unit: '°', + ); + + final $_dbc.DBCSignal _frontTiltSignal = $_dbc.DBCSignal( + name: 'Front_Tilt', + signalSignedness: $_dbc.DBCSignalSignedness.SIGNED, + signalType: $_dbc.DBCSignalType.INTEL, + signalMode: $_dbc.DBCSignalMode.SIGNAL, + start: 12, + length: 12, + // dart format off + mapping: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + mappingIndexes: [12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23], + // dart format on + factor: 0.04396678065461651, + offset: 0, + min: -90, + max: 90, + unit: '°', + ); + + final $_dbc.DBCSignal _rearSwivelSignal = $_dbc.DBCSignal( + name: 'Rear_Swivel', + signalSignedness: $_dbc.DBCSignalSignedness.SIGNED, + signalType: $_dbc.DBCSignalType.INTEL, + signalMode: $_dbc.DBCSignalMode.SIGNAL, + start: 24, + length: 12, + // dart format off + mapping: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + mappingIndexes: [24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35], + // dart format on + factor: 0.04396678065461651, + offset: 0, + min: -90, + max: 90, + unit: '°', + ); + + final $_dbc.DBCSignal _rearTiltSignal = $_dbc.DBCSignal( + name: 'Rear_Tilt', + signalSignedness: $_dbc.DBCSignalSignedness.SIGNED, + signalType: $_dbc.DBCSignalType.INTEL, + signalMode: $_dbc.DBCSignalMode.SIGNAL, + start: 36, + length: 12, + // dart format off + mapping: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048], + mappingIndexes: [36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47], + // dart format on + factor: 0.04396678065461651, + offset: 0, + min: -90, + max: 90, + unit: '°', + ); + + @override + List<$_dbc.DBCSignal> get signals => [ + _frontSwivelSignal, + _frontTiltSignal, + _rearSwivelSignal, + _rearTiltSignal, + ]; + + DriveSwivelDataMessage({ + this.frontSwivel = 0, + this.frontTilt = 0, + this.rearSwivel = 0, + this.rearTilt = 0, + }); + + /// Creates a clone of this [DriveSwivelDataMessage] with the non-null values replaced + DriveSwivelDataMessage copyWith({ + double? frontSwivel, + double? frontTilt, + double? rearSwivel, + double? rearTilt, + }) => DriveSwivelDataMessage( + frontSwivel: frontSwivel ?? this.frontSwivel, + frontTilt: frontTilt ?? this.frontTilt, + rearSwivel: rearSwivel ?? this.rearSwivel, + rearTilt: rearTilt ?? this.rearTilt, + ); + + factory DriveSwivelDataMessage.decode(List payload) { + final message = DriveSwivelDataMessage(); + final typedBuffer = $_typed.Uint8List.fromList(payload); + final bitField = $_dbc.BitField.from( + typedBuffer.sublist(0, message.messageLength), + ); + + message.frontSwivel = (message._frontSwivelSignal.decode(bitField) ?? 0) + .toDouble(); + message.frontTilt = (message._frontTiltSignal.decode(bitField) ?? 0) + .toDouble(); + message.rearSwivel = (message._rearSwivelSignal.decode(bitField) ?? 0) + .toDouble(); + message.rearTilt = (message._rearTiltSignal.decode(bitField) ?? 0) + .toDouble(); + + return message; + } + + factory DriveSwivelDataMessage.fromJson(Map json) => + DriveSwivelDataMessage( + frontSwivel: json['Front_Swivel'] ?? 0, + frontTilt: json['Front_Tilt'] ?? 0, + rearSwivel: json['Rear_Swivel'] ?? 0, + rearTilt: json['Rear_Tilt'] ?? 0, + ); + + @override + $_typed.Uint8List encode() { + final Map<$_dbc.DBCSignal, num> values = { + _frontSwivelSignal: frontSwivel, + _frontTiltSignal: frontTilt, + _rearSwivelSignal: rearSwivel, + _rearTiltSignal: rearTilt, + }; + + return encodeWithValues(values); + } + + @override + Map toJson() => { + 'Front_Swivel': frontSwivel, + 'Front_Tilt': frontTilt, + 'Rear_Swivel': rearSwivel, + 'Rear_Tilt': rearTilt, + }; + + @override + String toString() => + 'Drive_Swivel_Data(\n Front_Swivel=$frontSwivel\n Front_Tilt=$frontTilt\n Rear_Swivel=$rearSwivel\n Rear_Tilt=$rearTilt\n)'; +} + +class DriveMotorDataMessage extends $_dbc.DBCMessage { + @override + final String messageName = 'Drive_Motor_Data'; + + @override + final int messageLength = 6; + + @override + final int canId = 0x109; + + /// Whether or not "Drive_Motor_Data" is multiplex + static const bool isMultiplex = false; + + /// The multiplexor for "Drive_Motor_Data" + static const String multiplexor = ''; + + /// Value of signal "Motor_Value" + int motorValue; + + /// Value of signal "Speed" + double speed; + + /// Value of signal "Current" + double current; + + /// Value of signal "Temperature" + int temperature; + + /// Value of signal "Error_Code" + int errorCode; + + final $_dbc.DBCSignal _motorValueSignal = $_dbc.DBCSignal( + name: 'Motor_Value', + signalSignedness: $_dbc.DBCSignalSignedness.UNSIGNED, + signalType: $_dbc.DBCSignalType.INTEL, + signalMode: $_dbc.DBCSignalMode.SIGNAL, + start: 0, + length: 3, + // dart format off + mapping: [1, 2, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + mappingIndexes: [0, 1, 2], + // dart format on + factor: 1, + offset: 0, + min: 0, + max: 6, + unit: '', + ); + + final $_dbc.DBCSignal _speedSignal = $_dbc.DBCSignal( + name: 'Speed', + signalSignedness: $_dbc.DBCSignalSignedness.SIGNED, + signalType: $_dbc.DBCSignalType.INTEL, + signalMode: $_dbc.DBCSignalMode.SIGNAL, + start: 3, + length: 16, + // dart format off + mapping: [0, 0, 0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + mappingIndexes: [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18], + // dart format on + factor: 10, + offset: 0, + min: -320000, + max: 320000, + unit: 'RPM', + ); + + final $_dbc.DBCSignal _currentSignal = $_dbc.DBCSignal( + name: 'Current', + signalSignedness: $_dbc.DBCSignalSignedness.SIGNED, + signalType: $_dbc.DBCSignalType.INTEL, + signalMode: $_dbc.DBCSignalMode.SIGNAL, + start: 19, + length: 16, + // dart format off + mapping: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + mappingIndexes: [19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34], + // dart format on + factor: 0.1, + offset: 0, + min: -60, + max: 60, + unit: 'A', + ); + + final $_dbc.DBCSignal _temperatureSignal = $_dbc.DBCSignal( + name: 'Temperature', + signalSignedness: $_dbc.DBCSignalSignedness.SIGNED, + signalType: $_dbc.DBCSignalType.INTEL, + signalMode: $_dbc.DBCSignalMode.SIGNAL, + start: 35, + length: 8, + // dart format off + mapping: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 4, 8, 16, 32, 64, 128, 0, 0, 0, 0, 0], + mappingIndexes: [35, 36, 37, 38, 39, 40, 41, 42], + // dart format on + factor: 1, + offset: 0, + min: -20, + max: 127, + unit: '°C', + ); + + final $_dbc.DBCSignal _errorCodeSignal = $_dbc.DBCSignal( + name: 'Error_Code', + signalSignedness: $_dbc.DBCSignalSignedness.UNSIGNED, + signalType: $_dbc.DBCSignalType.INTEL, + signalMode: $_dbc.DBCSignalMode.SIGNAL, + start: 43, + length: 3, + // dart format off + mapping: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 4, 0, 0], + mappingIndexes: [43, 44, 45], + // dart format on + factor: 1, + offset: 0, + min: 0, + max: 7, + unit: '', + ); + + @override + List<$_dbc.DBCSignal> get signals => [ + _motorValueSignal, + _speedSignal, + _currentSignal, + _temperatureSignal, + _errorCodeSignal, + ]; + + DriveMotorDataMessage({ + this.motorValue = 0, + this.speed = 0, + this.current = 0, + this.temperature = 0, + this.errorCode = 0, + }); + + /// Creates a clone of this [DriveMotorDataMessage] with the non-null values replaced + DriveMotorDataMessage copyWith({ + int? motorValue, + double? speed, + double? current, + int? temperature, + int? errorCode, + }) => DriveMotorDataMessage( + motorValue: motorValue ?? this.motorValue, + speed: speed ?? this.speed, + current: current ?? this.current, + temperature: temperature ?? this.temperature, + errorCode: errorCode ?? this.errorCode, + ); + + factory DriveMotorDataMessage.decode(List payload) { + final message = DriveMotorDataMessage(); + final typedBuffer = $_typed.Uint8List.fromList(payload); + final bitField = $_dbc.BitField.from( + typedBuffer.sublist(0, message.messageLength), + ); + + message.motorValue = (message._motorValueSignal.decode(bitField) ?? 0) + .toInt(); + message.speed = (message._speedSignal.decode(bitField) ?? 0).toDouble(); + message.current = (message._currentSignal.decode(bitField) ?? 0).toDouble(); + message.temperature = (message._temperatureSignal.decode(bitField) ?? 0) + .toInt(); + message.errorCode = (message._errorCodeSignal.decode(bitField) ?? 0) + .toInt(); + + return message; + } + + factory DriveMotorDataMessage.fromJson(Map json) => + DriveMotorDataMessage( + motorValue: json['Motor_Value'] ?? 0, + speed: json['Speed'] ?? 0, + current: json['Current'] ?? 0, + temperature: json['Temperature'] ?? 0, + errorCode: json['Error_Code'] ?? 0, + ); + + @override + $_typed.Uint8List encode() { + final Map<$_dbc.DBCSignal, num> values = { + _motorValueSignal: motorValue, + _speedSignal: speed, + _currentSignal: current, + _temperatureSignal: temperature, + _errorCodeSignal: errorCode, + }; + + return encodeWithValues(values); + } + + @override + Map toJson() => { + 'Motor_Value': motorValue, + 'Speed': speed, + 'Current': current, + 'Temperature': temperature, + 'Error_Code': errorCode, + }; + + @override + String toString() => + 'Drive_Motor_Data(\n Motor_Value=$motorValue\n Speed=$speed\n Current=$current\n Temperature=$temperature\n Error_Code=$errorCode\n)'; +} + +class RelaySetStateMessage extends $_dbc.DBCMessage { + @override + final String messageName = 'Relay_Set_State'; + + @override + final int messageLength = 2; + + @override + final int canId = 0x201; + + /// Whether or not "Relay_Set_State" is multiplex + static const bool isMultiplex = false; + + /// The multiplexor for "Relay_Set_State" + static const String multiplexor = ''; + + /// Value of signal "Front_Left_Motor" + int frontLeftMotor; + + /// Value of signal "Front_Right_Motor" + int frontRightMotor; + + /// Value of signal "Back_Left_Motor" + int backLeftMotor; + + /// Value of signal "Back_Right_Motor" + int backRightMotor; + + /// Value of signal "Arm" + int arm; + + /// Value of signal "Science" + int science; + + /// Value of signal "Drive" + int drive; + + final $_dbc.DBCSignal _frontLeftMotorSignal = $_dbc.DBCSignal( + name: 'Front_Left_Motor', + signalSignedness: $_dbc.DBCSignalSignedness.UNSIGNED, + signalType: $_dbc.DBCSignalType.INTEL, + signalMode: $_dbc.DBCSignalMode.SIGNAL, + start: 0, + length: 2, + // dart format off + mapping: [1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + mappingIndexes: [0, 1], + // dart format on + factor: 1, + offset: 0, + min: 0, + max: 3, + unit: '', + ); + + final $_dbc.DBCSignal _frontRightMotorSignal = $_dbc.DBCSignal( + name: 'Front_Right_Motor', + signalSignedness: $_dbc.DBCSignalSignedness.UNSIGNED, + signalType: $_dbc.DBCSignalType.INTEL, + signalMode: $_dbc.DBCSignalMode.SIGNAL, + start: 2, + length: 2, + // dart format off + mapping: [0, 0, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + mappingIndexes: [2, 3], + // dart format on + factor: 1, + offset: 0, + min: 0, + max: 3, + unit: '', + ); + + final $_dbc.DBCSignal _backLeftMotorSignal = $_dbc.DBCSignal( + name: 'Back_Left_Motor', + signalSignedness: $_dbc.DBCSignalSignedness.UNSIGNED, + signalType: $_dbc.DBCSignalType.INTEL, + signalMode: $_dbc.DBCSignalMode.SIGNAL, + start: 4, + length: 2, + // dart format off + mapping: [0, 0, 0, 0, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + mappingIndexes: [4, 5], + // dart format on + factor: 1, + offset: 0, + min: 0, + max: 3, + unit: '', + ); + + final $_dbc.DBCSignal _backRightMotorSignal = $_dbc.DBCSignal( + name: 'Back_Right_Motor', + signalSignedness: $_dbc.DBCSignalSignedness.UNSIGNED, + signalType: $_dbc.DBCSignalType.INTEL, + signalMode: $_dbc.DBCSignalMode.SIGNAL, + start: 6, + length: 2, + // dart format off + mapping: [0, 0, 0, 0, 0, 0, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0], + mappingIndexes: [6, 7], + // dart format on + factor: 1, + offset: 0, + min: 0, + max: 3, + unit: '', + ); + + final $_dbc.DBCSignal _armSignal = $_dbc.DBCSignal( + name: 'Arm', + signalSignedness: $_dbc.DBCSignalSignedness.UNSIGNED, + signalType: $_dbc.DBCSignalType.INTEL, + signalMode: $_dbc.DBCSignalMode.SIGNAL, + start: 8, + length: 2, + // dart format off + mapping: [0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 0, 0, 0, 0, 0, 0], + mappingIndexes: [8, 9], + // dart format on + factor: 1, + offset: 0, + min: 0, + max: 3, + unit: '', + ); + + final $_dbc.DBCSignal _scienceSignal = $_dbc.DBCSignal( + name: 'Science', + signalSignedness: $_dbc.DBCSignalSignedness.UNSIGNED, + signalType: $_dbc.DBCSignalType.INTEL, + signalMode: $_dbc.DBCSignalMode.SIGNAL, + start: 10, + length: 2, + // dart format off + mapping: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 0, 0, 0, 0], + mappingIndexes: [10, 11], + // dart format on + factor: 1, + offset: 0, + min: 0, + max: 3, + unit: '', + ); + + final $_dbc.DBCSignal _driveSignal = $_dbc.DBCSignal( + name: 'Drive', + signalSignedness: $_dbc.DBCSignalSignedness.UNSIGNED, + signalType: $_dbc.DBCSignalType.INTEL, + signalMode: $_dbc.DBCSignalMode.SIGNAL, + start: 12, + length: 2, + // dart format off + mapping: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 0, 0], + mappingIndexes: [12, 13], + // dart format on + factor: 1, + offset: 0, + min: 0, + max: 3, + unit: '', + ); + + @override + List<$_dbc.DBCSignal> get signals => [ + _frontLeftMotorSignal, + _frontRightMotorSignal, + _backLeftMotorSignal, + _backRightMotorSignal, + _armSignal, + _scienceSignal, + _driveSignal, + ]; + + RelaySetStateMessage({ + this.frontLeftMotor = 0, + this.frontRightMotor = 0, + this.backLeftMotor = 0, + this.backRightMotor = 0, + this.arm = 0, + this.science = 0, + this.drive = 0, + }); + + /// Creates a clone of this [RelaySetStateMessage] with the non-null values replaced + RelaySetStateMessage copyWith({ + int? frontLeftMotor, + int? frontRightMotor, + int? backLeftMotor, + int? backRightMotor, + int? arm, + int? science, + int? drive, + }) => RelaySetStateMessage( + frontLeftMotor: frontLeftMotor ?? this.frontLeftMotor, + frontRightMotor: frontRightMotor ?? this.frontRightMotor, + backLeftMotor: backLeftMotor ?? this.backLeftMotor, + backRightMotor: backRightMotor ?? this.backRightMotor, + arm: arm ?? this.arm, + science: science ?? this.science, + drive: drive ?? this.drive, + ); + + factory RelaySetStateMessage.decode(List payload) { + final message = RelaySetStateMessage(); + final typedBuffer = $_typed.Uint8List.fromList(payload); + final bitField = $_dbc.BitField.from( + typedBuffer.sublist(0, message.messageLength), + ); + + message.frontLeftMotor = + (message._frontLeftMotorSignal.decode(bitField) ?? 0).toInt(); + message.frontRightMotor = + (message._frontRightMotorSignal.decode(bitField) ?? 0).toInt(); + message.backLeftMotor = (message._backLeftMotorSignal.decode(bitField) ?? 0) + .toInt(); + message.backRightMotor = + (message._backRightMotorSignal.decode(bitField) ?? 0).toInt(); + message.arm = (message._armSignal.decode(bitField) ?? 0).toInt(); + message.science = (message._scienceSignal.decode(bitField) ?? 0).toInt(); + message.drive = (message._driveSignal.decode(bitField) ?? 0).toInt(); + + return message; + } + + factory RelaySetStateMessage.fromJson(Map json) => + RelaySetStateMessage( + frontLeftMotor: json['Front_Left_Motor'] ?? 0, + frontRightMotor: json['Front_Right_Motor'] ?? 0, + backLeftMotor: json['Back_Left_Motor'] ?? 0, + backRightMotor: json['Back_Right_Motor'] ?? 0, + arm: json['Arm'] ?? 0, + science: json['Science'] ?? 0, + drive: json['Drive'] ?? 0, + ); + + @override + $_typed.Uint8List encode() { + final Map<$_dbc.DBCSignal, num> values = { + _frontLeftMotorSignal: frontLeftMotor, + _frontRightMotorSignal: frontRightMotor, + _backLeftMotorSignal: backLeftMotor, + _backRightMotorSignal: backRightMotor, + _armSignal: arm, + _scienceSignal: science, + _driveSignal: drive, + }; + + return encodeWithValues(values); + } + + @override + Map toJson() => { + 'Front_Left_Motor': frontLeftMotor, + 'Front_Right_Motor': frontRightMotor, + 'Back_Left_Motor': backLeftMotor, + 'Back_Right_Motor': backRightMotor, + 'Arm': arm, + 'Science': science, + 'Drive': drive, + }; + + @override + String toString() => + 'Relay_Set_State(\n Front_Left_Motor=$frontLeftMotor\n Front_Right_Motor=$frontRightMotor\n Back_Left_Motor=$backLeftMotor\n Back_Right_Motor=$backRightMotor\n Arm=$arm\n Science=$science\n Drive=$drive\n)'; +} + +class RelayStateDataMessage extends $_dbc.DBCMessage { + @override + final String messageName = 'Relay_State_Data'; + + @override + final int messageLength = 1; + + @override + final int canId = 0x205; + + /// Whether or not "Relay_State_Data" is multiplex + static const bool isMultiplex = false; + + /// The multiplexor for "Relay_State_Data" + static const String multiplexor = ''; + + /// Value of signal "Front_Left_Motor" + int frontLeftMotor; + + /// Value of signal "Front_Right_Motor" + int frontRightMotor; + + /// Value of signal "Back_Left_Motor" + int backLeftMotor; + + /// Value of signal "Back_Right_Motor" + int backRightMotor; + + /// Value of signal "Drive" + int drive; + + /// Value of signal "Arm" + int arm; + + /// Value of signal "Science" + int science; + + /// Value of signal "Physical_Override" + int physicalOverride; + + final $_dbc.DBCSignal _frontLeftMotorSignal = $_dbc.DBCSignal( + name: 'Front_Left_Motor', + signalSignedness: $_dbc.DBCSignalSignedness.UNSIGNED, + signalType: $_dbc.DBCSignalType.INTEL, + signalMode: $_dbc.DBCSignalMode.SIGNAL, + start: 0, + length: 1, + // dart format off + mapping: [1, 0, 0, 0, 0, 0, 0, 0], + mappingIndexes: [0], + // dart format on + factor: 1, + offset: 0, + min: 0, + max: 1, + unit: '', + ); + + final $_dbc.DBCSignal _frontRightMotorSignal = $_dbc.DBCSignal( + name: 'Front_Right_Motor', + signalSignedness: $_dbc.DBCSignalSignedness.UNSIGNED, + signalType: $_dbc.DBCSignalType.INTEL, + signalMode: $_dbc.DBCSignalMode.SIGNAL, + start: 1, + length: 1, + // dart format off + mapping: [0, 1, 0, 0, 0, 0, 0, 0], + mappingIndexes: [1], + // dart format on + factor: 1, + offset: 0, + min: 0, + max: 1, + unit: '', + ); + + final $_dbc.DBCSignal _backLeftMotorSignal = $_dbc.DBCSignal( + name: 'Back_Left_Motor', + signalSignedness: $_dbc.DBCSignalSignedness.UNSIGNED, + signalType: $_dbc.DBCSignalType.INTEL, + signalMode: $_dbc.DBCSignalMode.SIGNAL, + start: 2, + length: 1, + // dart format off + mapping: [0, 0, 1, 0, 0, 0, 0, 0], + mappingIndexes: [2], + // dart format on + factor: 1, + offset: 0, + min: 0, + max: 1, + unit: '', + ); + + final $_dbc.DBCSignal _backRightMotorSignal = $_dbc.DBCSignal( + name: 'Back_Right_Motor', + signalSignedness: $_dbc.DBCSignalSignedness.UNSIGNED, + signalType: $_dbc.DBCSignalType.INTEL, + signalMode: $_dbc.DBCSignalMode.SIGNAL, + start: 3, + length: 1, + // dart format off + mapping: [0, 0, 0, 1, 0, 0, 0, 0], + mappingIndexes: [3], + // dart format on + factor: 1, + offset: 0, + min: 0, + max: 1, + unit: '', + ); + + final $_dbc.DBCSignal _driveSignal = $_dbc.DBCSignal( + name: 'Drive', + signalSignedness: $_dbc.DBCSignalSignedness.UNSIGNED, + signalType: $_dbc.DBCSignalType.INTEL, + signalMode: $_dbc.DBCSignalMode.SIGNAL, + start: 4, + length: 1, + // dart format off + mapping: [0, 0, 0, 0, 1, 0, 0, 0], + mappingIndexes: [4], + // dart format on + factor: 1, + offset: 0, + min: 0, + max: 1, + unit: '', + ); + + final $_dbc.DBCSignal _armSignal = $_dbc.DBCSignal( + name: 'Arm', + signalSignedness: $_dbc.DBCSignalSignedness.UNSIGNED, + signalType: $_dbc.DBCSignalType.INTEL, + signalMode: $_dbc.DBCSignalMode.SIGNAL, + start: 5, + length: 1, + // dart format off + mapping: [0, 0, 0, 0, 0, 1, 0, 0], + mappingIndexes: [5], + // dart format on + factor: 1, + offset: 0, + min: 0, + max: 1, + unit: '', + ); + + final $_dbc.DBCSignal _scienceSignal = $_dbc.DBCSignal( + name: 'Science', + signalSignedness: $_dbc.DBCSignalSignedness.UNSIGNED, + signalType: $_dbc.DBCSignalType.INTEL, + signalMode: $_dbc.DBCSignalMode.SIGNAL, + start: 6, + length: 1, + // dart format off + mapping: [0, 0, 0, 0, 0, 0, 1, 0], + mappingIndexes: [6], + // dart format on + factor: 1, + offset: 0, + min: 0, + max: 1, + unit: '', + ); + + final $_dbc.DBCSignal _physicalOverrideSignal = $_dbc.DBCSignal( + name: 'Physical_Override', + signalSignedness: $_dbc.DBCSignalSignedness.UNSIGNED, + signalType: $_dbc.DBCSignalType.INTEL, + signalMode: $_dbc.DBCSignalMode.SIGNAL, + start: 7, + length: 1, + // dart format off + mapping: [0, 0, 0, 0, 0, 0, 0, 1], + mappingIndexes: [7], + // dart format on + factor: 1, + offset: 0, + min: 0, + max: 1, + unit: '', + ); + + @override + List<$_dbc.DBCSignal> get signals => [ + _frontLeftMotorSignal, + _frontRightMotorSignal, + _backLeftMotorSignal, + _backRightMotorSignal, + _driveSignal, + _armSignal, + _scienceSignal, + _physicalOverrideSignal, + ]; + + RelayStateDataMessage({ + this.frontLeftMotor = 0, + this.frontRightMotor = 0, + this.backLeftMotor = 0, + this.backRightMotor = 0, + this.drive = 0, + this.arm = 0, + this.science = 0, + this.physicalOverride = 0, + }); + + /// Creates a clone of this [RelayStateDataMessage] with the non-null values replaced + RelayStateDataMessage copyWith({ + int? frontLeftMotor, + int? frontRightMotor, + int? backLeftMotor, + int? backRightMotor, + int? drive, + int? arm, + int? science, + int? physicalOverride, + }) => RelayStateDataMessage( + frontLeftMotor: frontLeftMotor ?? this.frontLeftMotor, + frontRightMotor: frontRightMotor ?? this.frontRightMotor, + backLeftMotor: backLeftMotor ?? this.backLeftMotor, + backRightMotor: backRightMotor ?? this.backRightMotor, + drive: drive ?? this.drive, + arm: arm ?? this.arm, + science: science ?? this.science, + physicalOverride: physicalOverride ?? this.physicalOverride, + ); + + factory RelayStateDataMessage.decode(List payload) { + final message = RelayStateDataMessage(); + final typedBuffer = $_typed.Uint8List.fromList(payload); + final bitField = $_dbc.BitField.from( + typedBuffer.sublist(0, message.messageLength), + ); + + message.frontLeftMotor = + (message._frontLeftMotorSignal.decode(bitField) ?? 0).toInt(); + message.frontRightMotor = + (message._frontRightMotorSignal.decode(bitField) ?? 0).toInt(); + message.backLeftMotor = (message._backLeftMotorSignal.decode(bitField) ?? 0) + .toInt(); + message.backRightMotor = + (message._backRightMotorSignal.decode(bitField) ?? 0).toInt(); + message.drive = (message._driveSignal.decode(bitField) ?? 0).toInt(); + message.arm = (message._armSignal.decode(bitField) ?? 0).toInt(); + message.science = (message._scienceSignal.decode(bitField) ?? 0).toInt(); + message.physicalOverride = + (message._physicalOverrideSignal.decode(bitField) ?? 0).toInt(); + + return message; + } + + factory RelayStateDataMessage.fromJson(Map json) => + RelayStateDataMessage( + frontLeftMotor: json['Front_Left_Motor'] ?? 0, + frontRightMotor: json['Front_Right_Motor'] ?? 0, + backLeftMotor: json['Back_Left_Motor'] ?? 0, + backRightMotor: json['Back_Right_Motor'] ?? 0, + drive: json['Drive'] ?? 0, + arm: json['Arm'] ?? 0, + science: json['Science'] ?? 0, + physicalOverride: json['Physical_Override'] ?? 0, + ); + + @override + $_typed.Uint8List encode() { + final Map<$_dbc.DBCSignal, num> values = { + _frontLeftMotorSignal: frontLeftMotor, + _frontRightMotorSignal: frontRightMotor, + _backLeftMotorSignal: backLeftMotor, + _backRightMotorSignal: backRightMotor, + _driveSignal: drive, + _armSignal: arm, + _scienceSignal: science, + _physicalOverrideSignal: physicalOverride, + }; + + return encodeWithValues(values); + } + + @override + Map toJson() => { + 'Front_Left_Motor': frontLeftMotor, + 'Front_Right_Motor': frontRightMotor, + 'Back_Left_Motor': backLeftMotor, + 'Back_Right_Motor': backRightMotor, + 'Drive': drive, + 'Arm': arm, + 'Science': science, + 'Physical_Override': physicalOverride, + }; + + @override + String toString() => + 'Relay_State_Data(\n Front_Left_Motor=$frontLeftMotor\n Front_Right_Motor=$frontRightMotor\n Back_Left_Motor=$backLeftMotor\n Back_Right_Motor=$backRightMotor\n Drive=$drive\n Arm=$arm\n Science=$science\n Physical_Override=$physicalOverride\n)'; +} + +class RelayBatteryDataMessage extends $_dbc.DBCMessage { + @override + final String messageName = 'Relay_Battery_Data'; + + @override + final int messageLength = 2; + + @override + final int canId = 0x206; + + /// Whether or not "Relay_Battery_Data" is multiplex + static const bool isMultiplex = false; + + /// The multiplexor for "Relay_Battery_Data" + static const String multiplexor = ''; + + /// Value of signal "Voltage" + double voltage; + + final $_dbc.DBCSignal _voltageSignal = $_dbc.DBCSignal( + name: 'Voltage', + signalSignedness: $_dbc.DBCSignalSignedness.UNSIGNED, + signalType: $_dbc.DBCSignalType.INTEL, + signalMode: $_dbc.DBCSignalMode.SIGNAL, + start: 0, + length: 10, + // dart format off + mapping: [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 0, 0, 0, 0, 0, 0], + mappingIndexes: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], + // dart format on + factor: 0.03548387097, + offset: 0, + min: 0, + max: 36.3, + unit: 'V', + ); + + @override + List<$_dbc.DBCSignal> get signals => [_voltageSignal]; + + RelayBatteryDataMessage({this.voltage = 0}); + + /// Creates a clone of this [RelayBatteryDataMessage] with the non-null values replaced + RelayBatteryDataMessage copyWith({double? voltage}) => + RelayBatteryDataMessage(voltage: voltage ?? this.voltage); + + factory RelayBatteryDataMessage.decode(List payload) { + final message = RelayBatteryDataMessage(); + final typedBuffer = $_typed.Uint8List.fromList(payload); + final bitField = $_dbc.BitField.from( + typedBuffer.sublist(0, message.messageLength), + ); + + message.voltage = (message._voltageSignal.decode(bitField) ?? 0).toDouble(); + + return message; + } + + factory RelayBatteryDataMessage.fromJson(Map json) => + RelayBatteryDataMessage(voltage: json['Voltage'] ?? 0); + + @override + $_typed.Uint8List encode() { + final Map<$_dbc.DBCSignal, num> values = {_voltageSignal: voltage}; + + return encodeWithValues(values); + } + + @override + Map toJson() => {'Voltage': voltage}; + + @override + String toString() => 'Relay_Battery_Data(\n Voltage=$voltage\n)'; +} + +class ArmSetMotorMessage extends $_dbc.DBCMessage { + @override + final String messageName = 'Arm_Set_Motor'; + + @override + final int messageLength = 8; + + @override + final int canId = 0x301; + + /// Whether or not "Arm_Set_Motor" is multiplex + static const bool isMultiplex = false; + + /// The multiplexor for "Arm_Set_Motor" + static const String multiplexor = ''; + + /// Value of signal "Motor_Value" + int motorValue; + + /// Value of signal "Move_Steps" + int moveSteps; + + /// Value of signal "Move_Radians" + double moveRadians; + + /// Value of signal "Angle" + double angle; + + final $_dbc.DBCSignal _motorValueSignal = $_dbc.DBCSignal( + name: 'Motor_Value', + signalSignedness: $_dbc.DBCSignalSignedness.UNSIGNED, + signalType: $_dbc.DBCSignalType.INTEL, + signalMode: $_dbc.DBCSignalMode.SIGNAL, + start: 0, + length: 3, + // dart format off + mapping: [1, 2, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + mappingIndexes: [0, 1, 2], + // dart format on + factor: 1, + offset: 0, + min: 0, + max: 7, + unit: '', + ); + + final $_dbc.DBCSignal _moveStepsSignal = $_dbc.DBCSignal( + name: 'Move_Steps', + signalSignedness: $_dbc.DBCSignalSignedness.SIGNED, + signalType: $_dbc.DBCSignalType.INTEL, + signalMode: $_dbc.DBCSignalMode.SIGNAL, + start: 3, + length: 24, + // dart format off + mapping: [0, 0, 0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576, 2097152, 4194304, 8388608, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + mappingIndexes: [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26], + // dart format on + factor: 1, + offset: 0, + min: -8388607, + max: 8388607, + unit: '', + ); + + final $_dbc.DBCSignal _moveRadiansSignal = $_dbc.DBCSignal( + name: 'Move_Radians', + signalSignedness: $_dbc.DBCSignalSignedness.SIGNED, + signalType: $_dbc.DBCSignalType.INTEL, + signalMode: $_dbc.DBCSignalMode.SIGNAL, + start: 27, + length: 16, + // dart format off + mapping: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + mappingIndexes: [27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42], + // dart format on + factor: 0.00009587389751884518, + offset: 0, + min: -3.1415, + max: 3.1415, + unit: '', + ); + + final $_dbc.DBCSignal _angleSignal = $_dbc.DBCSignal( + name: 'Angle', + signalSignedness: $_dbc.DBCSignalSignedness.SIGNED, + signalType: $_dbc.DBCSignalType.INTEL, + signalMode: $_dbc.DBCSignalMode.SIGNAL, + start: 43, + length: 16, + // dart format off + mapping: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 0, 0, 0, 0, 0], + mappingIndexes: [43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58], + // dart format on + factor: 0.00009587389751884518, + offset: 0, + min: -3.1415, + max: 3.1415, + unit: '', + ); + + @override + List<$_dbc.DBCSignal> get signals => [ + _motorValueSignal, + _moveStepsSignal, + _moveRadiansSignal, + _angleSignal, + ]; + + ArmSetMotorMessage({ + this.motorValue = 0, + this.moveSteps = 0, + this.moveRadians = 0, + this.angle = 0, + }); + + /// Creates a clone of this [ArmSetMotorMessage] with the non-null values replaced + ArmSetMotorMessage copyWith({ + int? motorValue, + int? moveSteps, + double? moveRadians, + double? angle, + }) => ArmSetMotorMessage( + motorValue: motorValue ?? this.motorValue, + moveSteps: moveSteps ?? this.moveSteps, + moveRadians: moveRadians ?? this.moveRadians, + angle: angle ?? this.angle, + ); + + factory ArmSetMotorMessage.decode(List payload) { + final message = ArmSetMotorMessage(); + final typedBuffer = $_typed.Uint8List.fromList(payload); + final bitField = $_dbc.BitField.from( + typedBuffer.sublist(0, message.messageLength), + ); + + message.motorValue = (message._motorValueSignal.decode(bitField) ?? 0) + .toInt(); + message.moveSteps = (message._moveStepsSignal.decode(bitField) ?? 0) + .toInt(); + message.moveRadians = (message._moveRadiansSignal.decode(bitField) ?? 0) + .toDouble(); + message.angle = (message._angleSignal.decode(bitField) ?? 0).toDouble(); + + return message; + } + + factory ArmSetMotorMessage.fromJson(Map json) => + ArmSetMotorMessage( + motorValue: json['Motor_Value'] ?? 0, + moveSteps: json['Move_Steps'] ?? 0, + moveRadians: json['Move_Radians'] ?? 0, + angle: json['Angle'] ?? 0, + ); + + @override + $_typed.Uint8List encode() { + final Map<$_dbc.DBCSignal, num> values = { + _motorValueSignal: motorValue, + _moveStepsSignal: moveSteps, + _moveRadiansSignal: moveRadians, + _angleSignal: angle, + }; + + return encodeWithValues(values); + } + + @override + Map toJson() => { + 'Motor_Value': motorValue, + 'Move_Steps': moveSteps, + 'Move_Radians': moveRadians, + 'Angle': angle, + }; + + @override + String toString() => + 'Arm_Set_Motor(\n Motor_Value=$motorValue\n Move_Steps=$moveSteps\n Move_Radians=$moveRadians\n Angle=$angle\n)'; +} + +class ArmSetSystemActionMessage extends $_dbc.DBCMessage { + @override + final String messageName = 'Arm_Set_System_Action'; + + @override + final int messageLength = 1; + + @override + final int canId = 0x302; + + /// Whether or not "Arm_Set_System_Action" is multiplex + static const bool isMultiplex = false; + + /// The multiplexor for "Arm_Set_System_Action" + static const String multiplexor = ''; + + /// Value of signal "Stop" + int stop; + + /// Value of signal "Calibrate" + int calibrate; + + /// Value of signal "Jab" + int jab; + + final $_dbc.DBCSignal _stopSignal = $_dbc.DBCSignal( + name: 'Stop', + signalSignedness: $_dbc.DBCSignalSignedness.UNSIGNED, + signalType: $_dbc.DBCSignalType.INTEL, + signalMode: $_dbc.DBCSignalMode.SIGNAL, + start: 0, + length: 1, + // dart format off + mapping: [1, 0, 0, 0, 0, 0, 0, 0], + mappingIndexes: [0], + // dart format on + factor: 1, + offset: 0, + min: 0, + max: 1, + unit: '', + ); + + final $_dbc.DBCSignal _calibrateSignal = $_dbc.DBCSignal( + name: 'Calibrate', + signalSignedness: $_dbc.DBCSignalSignedness.UNSIGNED, + signalType: $_dbc.DBCSignalType.INTEL, + signalMode: $_dbc.DBCSignalMode.SIGNAL, + start: 1, + length: 1, + // dart format off + mapping: [0, 1, 0, 0, 0, 0, 0, 0], + mappingIndexes: [1], + // dart format on + factor: 1, + offset: 0, + min: 0, + max: 1, + unit: '', + ); + + final $_dbc.DBCSignal _jabSignal = $_dbc.DBCSignal( + name: 'Jab', + signalSignedness: $_dbc.DBCSignalSignedness.UNSIGNED, + signalType: $_dbc.DBCSignalType.INTEL, + signalMode: $_dbc.DBCSignalMode.SIGNAL, + start: 2, + length: 1, + // dart format off + mapping: [0, 0, 1, 0, 0, 0, 0, 0], + mappingIndexes: [2], + // dart format on + factor: 1, + offset: 0, + min: 0, + max: 1, + unit: '', + ); + + @override + List<$_dbc.DBCSignal> get signals => [ + _stopSignal, + _calibrateSignal, + _jabSignal, + ]; + + ArmSetSystemActionMessage({this.stop = 0, this.calibrate = 0, this.jab = 0}); + + /// Creates a clone of this [ArmSetSystemActionMessage] with the non-null values replaced + ArmSetSystemActionMessage copyWith({int? stop, int? calibrate, int? jab}) => + ArmSetSystemActionMessage( + stop: stop ?? this.stop, + calibrate: calibrate ?? this.calibrate, + jab: jab ?? this.jab, + ); + + factory ArmSetSystemActionMessage.decode(List payload) { + final message = ArmSetSystemActionMessage(); + final typedBuffer = $_typed.Uint8List.fromList(payload); + final bitField = $_dbc.BitField.from( + typedBuffer.sublist(0, message.messageLength), + ); + + message.stop = (message._stopSignal.decode(bitField) ?? 0).toInt(); + message.calibrate = (message._calibrateSignal.decode(bitField) ?? 0) + .toInt(); + message.jab = (message._jabSignal.decode(bitField) ?? 0).toInt(); + + return message; + } + + factory ArmSetSystemActionMessage.fromJson(Map json) => + ArmSetSystemActionMessage( + stop: json['Stop'] ?? 0, + calibrate: json['Calibrate'] ?? 0, + jab: json['Jab'] ?? 0, + ); + + @override + $_typed.Uint8List encode() { + final Map<$_dbc.DBCSignal, num> values = { + _stopSignal: stop, + _calibrateSignal: calibrate, + _jabSignal: jab, + }; + + return encodeWithValues(values); + } + + @override + Map toJson() => { + 'Stop': stop, + 'Calibrate': calibrate, + 'Jab': jab, + }; + + @override + String toString() => + 'Arm_Set_System_Action(\n Stop=$stop\n Calibrate=$calibrate\n Jab=$jab\n)'; +} + +class ArmMotorMoveDataMessage extends $_dbc.DBCMessage { + @override + final String messageName = 'Arm_Motor_Move_Data'; + + @override + final int messageLength = 2; + + @override + final int canId = 0x305; + + /// Whether or not "Arm_Motor_Move_Data" is multiplex + static const bool isMultiplex = false; + + /// The multiplexor for "Arm_Motor_Move_Data" + static const String multiplexor = ''; + + /// Value of signal "Motor_Value" + int motorValue; + + /// Value of signal "Is_Moving" + int isMoving; + + /// Value of signal "Is_Limit_Switch_Pressed" + int isLimitSwitchPressed; + + /// Value of signal "Motor_Direction" + int motorDirection; + + final $_dbc.DBCSignal _motorValueSignal = $_dbc.DBCSignal( + name: 'Motor_Value', + signalSignedness: $_dbc.DBCSignalSignedness.UNSIGNED, + signalType: $_dbc.DBCSignalType.INTEL, + signalMode: $_dbc.DBCSignalMode.SIGNAL, + start: 0, + length: 3, + // dart format off + mapping: [1, 2, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + mappingIndexes: [0, 1, 2], + // dart format on + factor: 1, + offset: 0, + min: 0, + max: 7, + unit: '', + ); + + final $_dbc.DBCSignal _isMovingSignal = $_dbc.DBCSignal( + name: 'Is_Moving', + signalSignedness: $_dbc.DBCSignalSignedness.UNSIGNED, + signalType: $_dbc.DBCSignalType.INTEL, + signalMode: $_dbc.DBCSignalMode.SIGNAL, + start: 3, + length: 2, + // dart format off + mapping: [0, 0, 0, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + mappingIndexes: [3, 4], + // dart format on + factor: 1, + offset: 0, + min: 0, + max: 3, + unit: '', + ); + + final $_dbc.DBCSignal _isLimitSwitchPressedSignal = $_dbc.DBCSignal( + name: 'Is_Limit_Switch_Pressed', + signalSignedness: $_dbc.DBCSignalSignedness.UNSIGNED, + signalType: $_dbc.DBCSignalType.INTEL, + signalMode: $_dbc.DBCSignalMode.SIGNAL, + start: 5, + length: 2, + // dart format off + mapping: [0, 0, 0, 0, 0, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0], + mappingIndexes: [5, 6], + // dart format on + factor: 1, + offset: 0, + min: 0, + max: 3, + unit: '', + ); + + final $_dbc.DBCSignal _motorDirectionSignal = $_dbc.DBCSignal( + name: 'Motor_Direction', + signalSignedness: $_dbc.DBCSignalSignedness.UNSIGNED, + signalType: $_dbc.DBCSignalType.INTEL, + signalMode: $_dbc.DBCSignalMode.SIGNAL, + start: 7, + length: 4, + // dart format off + mapping: [0, 0, 0, 0, 0, 0, 0, 1, 2, 4, 8, 0, 0, 0, 0, 0], + mappingIndexes: [7, 8, 9, 10], + // dart format on + factor: 1, + offset: 0, + min: 0, + max: 9, + unit: '', + ); + + @override + List<$_dbc.DBCSignal> get signals => [ + _motorValueSignal, + _isMovingSignal, + _isLimitSwitchPressedSignal, + _motorDirectionSignal, + ]; + + ArmMotorMoveDataMessage({ + this.motorValue = 0, + this.isMoving = 0, + this.isLimitSwitchPressed = 0, + this.motorDirection = 0, + }); + + /// Creates a clone of this [ArmMotorMoveDataMessage] with the non-null values replaced + ArmMotorMoveDataMessage copyWith({ + int? motorValue, + int? isMoving, + int? isLimitSwitchPressed, + int? motorDirection, + }) => ArmMotorMoveDataMessage( + motorValue: motorValue ?? this.motorValue, + isMoving: isMoving ?? this.isMoving, + isLimitSwitchPressed: isLimitSwitchPressed ?? this.isLimitSwitchPressed, + motorDirection: motorDirection ?? this.motorDirection, + ); + + factory ArmMotorMoveDataMessage.decode(List payload) { + final message = ArmMotorMoveDataMessage(); + final typedBuffer = $_typed.Uint8List.fromList(payload); + final bitField = $_dbc.BitField.from( + typedBuffer.sublist(0, message.messageLength), + ); + + message.motorValue = (message._motorValueSignal.decode(bitField) ?? 0) + .toInt(); + message.isMoving = (message._isMovingSignal.decode(bitField) ?? 0).toInt(); + message.isLimitSwitchPressed = + (message._isLimitSwitchPressedSignal.decode(bitField) ?? 0).toInt(); + message.motorDirection = + (message._motorDirectionSignal.decode(bitField) ?? 0).toInt(); + + return message; + } + + factory ArmMotorMoveDataMessage.fromJson(Map json) => + ArmMotorMoveDataMessage( + motorValue: json['Motor_Value'] ?? 0, + isMoving: json['Is_Moving'] ?? 0, + isLimitSwitchPressed: json['Is_Limit_Switch_Pressed'] ?? 0, + motorDirection: json['Motor_Direction'] ?? 0, + ); + + @override + $_typed.Uint8List encode() { + final Map<$_dbc.DBCSignal, num> values = { + _motorValueSignal: motorValue, + _isMovingSignal: isMoving, + _isLimitSwitchPressedSignal: isLimitSwitchPressed, + _motorDirectionSignal: motorDirection, + }; + + return encodeWithValues(values); + } + + @override + Map toJson() => { + 'Motor_Value': motorValue, + 'Is_Moving': isMoving, + 'Is_Limit_Switch_Pressed': isLimitSwitchPressed, + 'Motor_Direction': motorDirection, + }; + + @override + String toString() => + 'Arm_Motor_Move_Data(\n Motor_Value=$motorValue\n Is_Moving=$isMoving\n Is_Limit_Switch_Pressed=$isLimitSwitchPressed\n Motor_Direction=$motorDirection\n)'; +} + +class ArmMotorStepDataMessage extends $_dbc.DBCMessage { + @override + final String messageName = 'Arm_Motor_Step_Data'; + + @override + final int messageLength = 8; + + @override + final int canId = 0x306; + + /// Whether or not "Arm_Motor_Step_Data" is multiplex + static const bool isMultiplex = false; + + /// The multiplexor for "Arm_Motor_Step_Data" + static const String multiplexor = ''; + + /// Value of signal "Motor_Value" + int motorValue; + + /// Value of signal "Current_Step" + int currentStep; + + /// Value of signal "Target_Step" + int targetStep; + + final $_dbc.DBCSignal _motorValueSignal = $_dbc.DBCSignal( + name: 'Motor_Value', + signalSignedness: $_dbc.DBCSignalSignedness.UNSIGNED, + signalType: $_dbc.DBCSignalType.INTEL, + signalMode: $_dbc.DBCSignalMode.SIGNAL, + start: 0, + length: 3, + // dart format off + mapping: [1, 2, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + mappingIndexes: [0, 1, 2], + // dart format on + factor: 1, + offset: 0, + min: 0, + max: 7, + unit: '', + ); + + final $_dbc.DBCSignal _currentStepSignal = $_dbc.DBCSignal( + name: 'Current_Step', + signalSignedness: $_dbc.DBCSignalSignedness.SIGNED, + signalType: $_dbc.DBCSignalType.INTEL, + signalMode: $_dbc.DBCSignalMode.SIGNAL, + start: 3, + length: 28, + // dart format off + mapping: [0, 0, 0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576, 2097152, 4194304, 8388608, 16777216, 33554432, 67108864, 134217728, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + mappingIndexes: [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30], + // dart format on + factor: 1, + offset: 0, + min: -134217727, + max: 134217727, + unit: '', + ); + + final $_dbc.DBCSignal _targetStepSignal = $_dbc.DBCSignal( + name: 'Target_Step', + signalSignedness: $_dbc.DBCSignalSignedness.SIGNED, + signalType: $_dbc.DBCSignalType.INTEL, + signalMode: $_dbc.DBCSignalMode.SIGNAL, + start: 31, + length: 28, + // dart format off + mapping: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576, 2097152, 4194304, 8388608, 16777216, 33554432, 67108864, 134217728, 0, 0, 0, 0, 0], + mappingIndexes: [31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58], + // dart format on + factor: 1, + offset: 0, + min: -134217727, + max: 134217727, + unit: '', + ); + + @override + List<$_dbc.DBCSignal> get signals => [ + _motorValueSignal, + _currentStepSignal, + _targetStepSignal, + ]; + + ArmMotorStepDataMessage({ + this.motorValue = 0, + this.currentStep = 0, + this.targetStep = 0, + }); + + /// Creates a clone of this [ArmMotorStepDataMessage] with the non-null values replaced + ArmMotorStepDataMessage copyWith({ + int? motorValue, + int? currentStep, + int? targetStep, + }) => ArmMotorStepDataMessage( + motorValue: motorValue ?? this.motorValue, + currentStep: currentStep ?? this.currentStep, + targetStep: targetStep ?? this.targetStep, + ); + + factory ArmMotorStepDataMessage.decode(List payload) { + final message = ArmMotorStepDataMessage(); + final typedBuffer = $_typed.Uint8List.fromList(payload); + final bitField = $_dbc.BitField.from( + typedBuffer.sublist(0, message.messageLength), + ); + + message.motorValue = (message._motorValueSignal.decode(bitField) ?? 0) + .toInt(); + message.currentStep = (message._currentStepSignal.decode(bitField) ?? 0) + .toInt(); + message.targetStep = (message._targetStepSignal.decode(bitField) ?? 0) + .toInt(); + + return message; + } + + factory ArmMotorStepDataMessage.fromJson(Map json) => + ArmMotorStepDataMessage( + motorValue: json['Motor_Value'] ?? 0, + currentStep: json['Current_Step'] ?? 0, + targetStep: json['Target_Step'] ?? 0, + ); + + @override + $_typed.Uint8List encode() { + final Map<$_dbc.DBCSignal, num> values = { + _motorValueSignal: motorValue, + _currentStepSignal: currentStep, + _targetStepSignal: targetStep, + }; + + return encodeWithValues(values); + } + + @override + Map toJson() => { + 'Motor_Value': motorValue, + 'Current_Step': currentStep, + 'Target_Step': targetStep, + }; + + @override + String toString() => + 'Arm_Motor_Step_Data(\n Motor_Value=$motorValue\n Current_Step=$currentStep\n Target_Step=$targetStep\n)'; +} + +class ArmMotorAngleDataMessage extends $_dbc.DBCMessage { + @override + final String messageName = 'Arm_Motor_Angle_Data'; + + @override + final int messageLength = 5; + + @override + final int canId = 0x307; + + /// Whether or not "Arm_Motor_Angle_Data" is multiplex + static const bool isMultiplex = false; + + /// The multiplexor for "Arm_Motor_Angle_Data" + static const String multiplexor = ''; + + /// Value of signal "Motor_Value" + int motorValue; + + /// Value of signal "Current_Angle" + double currentAngle; + + /// Value of signal "Target_Angle" + double targetAngle; + + final $_dbc.DBCSignal _motorValueSignal = $_dbc.DBCSignal( + name: 'Motor_Value', + signalSignedness: $_dbc.DBCSignalSignedness.UNSIGNED, + signalType: $_dbc.DBCSignalType.INTEL, + signalMode: $_dbc.DBCSignalMode.SIGNAL, + start: 0, + length: 3, + // dart format off + mapping: [1, 2, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + mappingIndexes: [0, 1, 2], + // dart format on + factor: 1, + offset: 0, + min: 0, + max: 7, + unit: '', + ); + + final $_dbc.DBCSignal _currentAngleSignal = $_dbc.DBCSignal( + name: 'Current_Angle', + signalSignedness: $_dbc.DBCSignalSignedness.SIGNED, + signalType: $_dbc.DBCSignalType.INTEL, + signalMode: $_dbc.DBCSignalMode.SIGNAL, + start: 3, + length: 16, + // dart format off + mapping: [0, 0, 0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + mappingIndexes: [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18], + // dart format on + factor: 0.00009587664418469802, + offset: 0, + min: -3.14159, + max: 3.14159, + unit: '', + ); + + final $_dbc.DBCSignal _targetAngleSignal = $_dbc.DBCSignal( + name: 'Target_Angle', + signalSignedness: $_dbc.DBCSignalSignedness.SIGNED, + signalType: $_dbc.DBCSignalType.INTEL, + signalMode: $_dbc.DBCSignalMode.SIGNAL, + start: 19, + length: 16, + // dart format off + mapping: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 0, 0, 0, 0, 0], + mappingIndexes: [19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34], + // dart format on + factor: 0.00009587664418469802, + offset: 0, + min: -3.14159, + max: 3.14159, + unit: '', + ); + + @override + List<$_dbc.DBCSignal> get signals => [ + _motorValueSignal, + _currentAngleSignal, + _targetAngleSignal, + ]; + + ArmMotorAngleDataMessage({ + this.motorValue = 0, + this.currentAngle = 0, + this.targetAngle = 0, + }); + + /// Creates a clone of this [ArmMotorAngleDataMessage] with the non-null values replaced + ArmMotorAngleDataMessage copyWith({ + int? motorValue, + double? currentAngle, + double? targetAngle, + }) => ArmMotorAngleDataMessage( + motorValue: motorValue ?? this.motorValue, + currentAngle: currentAngle ?? this.currentAngle, + targetAngle: targetAngle ?? this.targetAngle, + ); + + factory ArmMotorAngleDataMessage.decode(List payload) { + final message = ArmMotorAngleDataMessage(); + final typedBuffer = $_typed.Uint8List.fromList(payload); + final bitField = $_dbc.BitField.from( + typedBuffer.sublist(0, message.messageLength), + ); + + message.motorValue = (message._motorValueSignal.decode(bitField) ?? 0) + .toInt(); + message.currentAngle = (message._currentAngleSignal.decode(bitField) ?? 0) + .toDouble(); + message.targetAngle = (message._targetAngleSignal.decode(bitField) ?? 0) + .toDouble(); + + return message; + } + + factory ArmMotorAngleDataMessage.fromJson(Map json) => + ArmMotorAngleDataMessage( + motorValue: json['Motor_Value'] ?? 0, + currentAngle: json['Current_Angle'] ?? 0, + targetAngle: json['Target_Angle'] ?? 0, + ); + + @override + $_typed.Uint8List encode() { + final Map<$_dbc.DBCSignal, num> values = { + _motorValueSignal: motorValue, + _currentAngleSignal: currentAngle, + _targetAngleSignal: targetAngle, + }; + + return encodeWithValues(values); + } + + @override + Map toJson() => { + 'Motor_Value': motorValue, + 'Current_Angle': currentAngle, + 'Target_Angle': targetAngle, + }; + + @override + String toString() => + 'Arm_Motor_Angle_Data(\n Motor_Value=$motorValue\n Current_Angle=$currentAngle\n Target_Angle=$targetAngle\n)'; +} diff --git a/subsystems/lib/src/utils/dbc_conversions.dart b/subsystems/lib/src/utils/dbc_conversions.dart new file mode 100644 index 00000000..45ff7e5c --- /dev/null +++ b/subsystems/lib/src/utils/dbc_conversions.dart @@ -0,0 +1,278 @@ +import "package:burt_network/protobuf.dart"; +import "package:dart_dbc_generator/dart_dbc_generator.dart"; +import "package:subsystems/src/generated/rover_messages.dbc.dart"; + +/// Utility extension to convert a boolean to an integer +extension BoolToInt on bool { + /// The booleant's integer value, where 1 represents true, and 0 represents false + int get intValue => this ? 1 : 0; +} + +/// Utility extension to convert a [BoolState] into an integer +extension BoolStateToInt on BoolState { + /// The integer value of the [BoolState], where 1 represents [BoolState.YES], + /// and 0 represents [BoolState.NO]. If the bool state is [BoolState.BOOL_UNDEFINED], + /// it is assumed to be false. + int get intValue => this == BoolState.YES ? 1 : 0; +} + +/// Utility extension to convert a [DriveAppliedOutputDataMessage] into a [DriveData] message +extension DriveAppliedOutputToProto on DriveAppliedOutputDataMessage { + /// The applied output DBC message as a [DriveData] message + DriveData toDriveProto() => DriveData( + throttle: throttle, + left: leftSpeed, + right: rightSpeed, + setLeft: true, + setRight: true, + setThrottle: true, + ); +} + +/// Utility extension to convert a [DriveBatteryDataMessage] into a [DriveData] message +extension DriveBatteryToProto on DriveBatteryDataMessage { + /// The battery DBC message as a [DriveData] message + DriveData toDriveProto() => DriveData( + batteryVoltage: voltage, + batteryTemperature: temperature, + batteryCurrent: current, + ); +} + +/// Utility extension to convert a [DriveLedDataMessage] into a [DriveData] message +extension DriveLedToProto on DriveLedDataMessage { + /// The led DBC message as a [DriveData] message + DriveData toDriveProto() => DriveData(color: ProtoColor.valueOf(color)); +} + +/// Utility extension to convert a [DriveSwivelDataMessage] into a [DriveData] message +extension DriveSwivelToProto on DriveSwivelDataMessage { + /// The swivel DBC message as a [DriveData] message + DriveData toDriveProto() => DriveData( + frontSwivel: frontSwivel, + frontTilt: frontTilt, + rearSwivel: rearSwivel, + rearTilt: rearTilt, + ); +} + +/// Utility extension to convert a [DriveMotorDataMessage] into a [DriveData] message +extension DriveMotorToProto on DriveMotorDataMessage { + /// The drive motor data as a [DriveMotorData] message + DriveMotorData toMotorData() => DriveMotorData( + speed: speed, + current: current, + temperature: temperature, + error: MotorErrorCode.valueOf(errorCode), + ); + + /// The drive motor data as a [DriveData] message + DriveData toDriveProto() { + final data = DriveData(); + final motorData = toMotorData(); + + if (motorValue == DriveMotor.FRONT_LEFT.value) { + data.frontLeftMotor = motorData; + } else if (motorValue == DriveMotor.MIDDLE_LEFT.value) { + data.middleLeftMotor = motorData; + } else if (motorValue == DriveMotor.BACK_LEFT.value) { + data.backLeftMotor = motorData; + } else if (motorValue == DriveMotor.FRONT_RIGHT.value) { + data.frontRightMotor = motorData; + } else if (motorValue == DriveMotor.MIDDLE_RIGHT.value) { + data.middleRightMotor = motorData; + } else if (motorValue == DriveMotor.BACK_RIGHT.value) { + data.backRightMotor = motorData; + } + + return data; + } +} + +/// Utility extension to convert a [DriveCommand] message into its respective [DBCMessage] +extension DriveCommandToDBC on DriveCommand { + /// The drive command as a [DriveSetSpeedsMessage] DBC message + DBCMessage asSetSpeeds() => DriveSetSpeedsMessage( + shouldSetLeft: setLeft.intValue, + shouldSetRight: setRight.intValue, + shouldSetThrottle: setThrottle.intValue, + leftSpeed: left, + rightSpeed: right, + throttle: throttle, + ); + + /// The drive command as a [DriveSetLedMessage] DBC message + DBCMessage asSetLEDS() => + DriveSetLedMessage(color: color.value, blink: blink.intValue); + + /// The drive command as a [DriveSetSwivelMessage] DBC message + DBCMessage asSetSwivels() => DriveSetSwivelMessage( + setFrontSwivel: hasFrontSwivel().intValue, + setFrontTilt: hasFrontTilt().intValue, + setRearSwivel: hasRearSwivel().intValue, + setRearTilt: hasRearTilt().intValue, + frontSwivel: frontSwivel, + frontTilt: frontTilt, + rearSwivel: rearSwivel, + rearTilt: rearTilt, + ); + + /// The drive command as its respective [DBCMessage] messages + List toDBC() => [ + if (setLeft || setRight || setThrottle) asSetSpeeds(), + if (hasColor() || hasBlink()) asSetLEDS(), + if (hasFrontSwivel() || hasFrontTilt() || hasRearSwivel() || hasRearTilt()) + asSetSwivels(), + ]; +} + +/// Utility extension to convert a [RelayStateDataMessage] to a [RelaysData] +extension RelayStateToProto on RelayStateDataMessage { + BoolState _intToBoolState(num value) => + value == 1 ? BoolState.YES : BoolState.NO; + + /// The relay state DBC message as a [RelaysData] message + RelaysData toRelayProto() => RelaysData( + frontLeftMotor: _intToBoolState(frontLeftMotor), + frontRightMotor: _intToBoolState(frontRightMotor), + backLeftMotor: _intToBoolState(backLeftMotor), + backRightMotor: _intToBoolState(backRightMotor), + arm: _intToBoolState(arm), + drive: _intToBoolState(drive), + science: _intToBoolState(science), + ); +} + +/// Utilitiy extension to convert a [RelayBatteryDataMessage] to a [RelaysData] +extension RelayBatteryToProto on RelayBatteryDataMessage { + /// The relay battery DBC message as a [RelaysData] message + RelaysData toRelayProto() => RelaysData(); +} + +/// Utility extension to convert a [RelaysCommand] command into its respective [DBCMessage] +extension RelaysCommandToDBC on RelaysCommand { + /// The relays command as a [RelaySetStateMessage] DBC message + DBCMessage asSetState() => RelaySetStateMessage( + arm: arm.value, + frontLeftMotor: frontLeftMotor.value, + frontRightMotor: frontRightMotor.value, + backLeftMotor: backLeftMotor.value, + backRightMotor: backRightMotor.value, + drive: drive.value, + science: science.value, + ); + + /// The relays command as its respective [DBCMessage] messages + List toDBC() => [asSetState()]; +} + +/// Utility extension to convert an [ArmMotorMoveDataMessage] into a [ArmData] message +extension ArmMotorMoveToProto on ArmMotorMoveDataMessage { + /// The arm motor move data as a [MotorData] message + MotorData toMotorData() => MotorData( + isMoving: BoolState.valueOf(isMoving), + isLimitSwitchPressed: BoolState.valueOf(isLimitSwitchPressed), + direction: MotorDirection.valueOf(motorDirection), + ); + + /// The arm motor move data as an [ArmData] message + ArmData toArmProto() { + final data = ArmData(); + + if (motorValue == ArmMotor.SWIVEL.value) { + data.base = toMotorData(); + } else if (motorValue == ArmMotor.SHOULDER.value) { + data.shoulder = toMotorData(); + } else if (motorValue == ArmMotor.ELBOW.value) { + data.elbow = toMotorData(); + } + + return data; + } +} + +/// Utility extension to convert a [ArmMotorStepDataMessage] into a [DriveData] message +extension ArmMotorStepToProto on ArmMotorStepDataMessage { + /// The motor steps DBC message as a [MotorData] message + MotorData toMotorData() => + MotorData(currentStep: currentStep, targetStep: targetStep); + + /// The motor steps DBC message as a [MotorData] message + ArmData toArmProto() { + final data = ArmData(); + + if (motorValue == ArmMotor.SWIVEL.value) { + data.base = toMotorData(); + } else if (motorValue == ArmMotor.SHOULDER.value) { + data.shoulder = toMotorData(); + } else if (motorValue == ArmMotor.ELBOW.value) { + data.elbow = toMotorData(); + } + + return data; + } +} + +/// Utility extension to convert a [ArmMotorAngleDataMessage] into a [ArmMotor] message +extension ArmMotorAngleToProto on ArmMotorAngleDataMessage { + /// The motor angle DBC message as a [MotorData] message + MotorData toMotorData() => + MotorData(currentAngle: currentAngle, targetAngle: targetAngle); + + /// The motor angle DBC message as an [ArmData] message + ArmData toArmProto() { + final data = ArmData(); + + if (motorValue == ArmMotor.SWIVEL.value) { + data.base = toMotorData(); + } else if (motorValue == ArmMotor.SHOULDER.value) { + data.shoulder = toMotorData(); + } else if (motorValue == ArmMotor.ELBOW.value) { + data.elbow = toMotorData(); + } + + return data; + } +} + +/// Utility extension to convert a [ArmCommand] message into its respective [DBCMessage] equivalents +extension ArmCommandToDBC on ArmCommand { + /// The arm command as a [ArmSetMotorMessage] DBC message + DBCMessage asSetSwivel() => ArmSetMotorMessage( + motorValue: ArmMotor.SWIVEL.value, + angle: swivel.angle, + moveRadians: swivel.moveRadians, + moveSteps: swivel.moveSteps, + ); + + /// The arm command as a [ArmSetMotorMessage] DBC message for the shoulder + DBCMessage asSetShoulder() => ArmSetMotorMessage( + motorValue: ArmMotor.SHOULDER.value, + angle: shoulder.angle, + moveRadians: shoulder.moveRadians, + moveSteps: shoulder.moveSteps, + ); + + /// The arm command as a [ArmSetMotorMessage] DBC message for the elbow + DBCMessage asSetElbow() => ArmSetMotorMessage( + motorValue: ArmMotor.ELBOW.value, + angle: elbow.angle, + moveRadians: elbow.moveRadians, + moveSteps: elbow.moveSteps, + ); + + /// The arm command as a [ArmSetSystemActionMessage] DBC message + DBCMessage asSystemAction() => ArmSetSystemActionMessage( + stop: stop.intValue, + calibrate: calibrate.intValue, + jab: jab.intValue, + ); + + /// The arm command as its respective [DBCMessage] messages + List toDBC() => [ + if (hasSwivel()) asSetSwivel(), + if (hasShoulder()) asSetShoulder(), + if (hasElbow()) asSetElbow(), + if (hasStop() || hasCalibrate() || hasJab()) asSystemAction(), + ]; +} diff --git a/subsystems/lib/subsystems.dart b/subsystems/lib/subsystems.dart index ce023b35..da13a682 100644 --- a/subsystems/lib/subsystems.dart +++ b/subsystems/lib/subsystems.dart @@ -1,6 +1,7 @@ import "dart:async"; import "package:burt_network/burt_network.dart"; +import "package:subsystems/src/devices/can_bus.dart"; import "src/devices/gps.dart"; import "src/devices/imu.dart"; @@ -16,6 +17,14 @@ export "src/can/socket_ffi.dart"; export "src/can/socket_interface.dart"; export "src/can/socket_stub.dart"; +/// Maps command names to [Device]s. +final commandToDevice = { + ArmCommand().messageName: Device.ARM, + DriveCommand().messageName: Device.DRIVE, + ScienceCommand().messageName: Device.SCIENCE, + RelaysCommand().messageName: Device.RELAY, +}; + /// Contains all the resources needed by the subsystems program. class SubsystemsCollection extends Service { /// Whether the subsystems is fully initialized. @@ -33,9 +42,14 @@ class SubsystemsCollection extends Service { /// The IMU reader. final imu = ImuReader(); + /// The CAN bus + final can = CanBus(); + /// Timer for sending the subsystems status Timer? dataSendTimer; + StreamSubscription? _messageSubscription; + @override Future init() async { await server.init(); @@ -45,10 +59,18 @@ class SubsystemsCollection extends Service { const Duration(milliseconds: 250), sendStatus, ); + _messageSubscription = server.messages.listen((message) async { + if (can.canSendWrapper(message)) { + await can.sendWrapper(message); + } else { + firmware.sendToSerial(message); + } + }); try { result &= await firmware.init(); result &= await gps.init(); result &= await imu.init(); + result &= await can.init(); if (result) { logger.info("Subsystems initialized"); } else { @@ -66,10 +88,12 @@ class SubsystemsCollection extends Service { Future dispose() async { logger.info("Shutting down..."); await onDisconnect(); + await _messageSubscription?.cancel(); isReady = false; await firmware.dispose(); await imu.dispose(); await gps.dispose(); + await can.dispose(); await server.dispose(); dataSendTimer?.cancel(); logger.socket = null; @@ -93,9 +117,12 @@ class SubsystemsCollection extends Service { server.sendMessage( SubsystemsData( version: Version(major: 1, minor: 0), - connectedDevices: firmware.devices - .where((e) => e.isReady) - .map((firmware) => firmware.device), + connectedDevices: { + ...can.connectedDevices, + ...firmware.devices + .where((e) => e.isReady) + .map((firmware) => firmware.device), + }, gpsConnected: gps.isConnected ? BoolState.YES : BoolState.NO, imuConnected: imu.isConnected ? BoolState.YES : BoolState.NO, ), diff --git a/subsystems/pubspec.yaml b/subsystems/pubspec.yaml index 463c202f..f37cc2d3 100644 --- a/subsystems/pubspec.yaml +++ b/subsystems/pubspec.yaml @@ -13,7 +13,10 @@ dependencies: burt_network: ^2.7.0 collection: ^1.19.0 csv: ^6.0.0 + dart_dbc_generator: + git: https://github.com/Gold872/dart_dbc_generator.git ffi: ^2.1.3 + linux_can: ^0.2.0 osc: ^1.0.0 dev_dependencies: