### Full DogLog Integration Example Source: https://doglog.dev/getting-started/usage A comprehensive example demonstrating the integration of DogLog within a RobotContainer. This includes setting options, enabling PDH logging, and making a basic log statement. Ensure all necessary imports are present. ```java package frc.robot; import dev.doglog.DogLog; import dev.doglog.DogLogOptions; import edu.wpi.first.wpilibj.PowerDistribution; import edu.wpi.first.wpilibj2.command.Command; import edu.wpi.first.wpilibj2.command.button.CommandXboxController; import edu.wpi.first.wpilibj2.command.button.Trigger; import frc.robot.Constants.OperatorConstants; import frc.robot.commands.ExampleCommand; import frc.robot.subsystems.ExampleSubsystem; public class RobotContainer { private final ExampleSubsystem m_exampleSubsystem = new ExampleSubsystem(); private final CommandXboxController m_driverController = new CommandXboxController( OperatorConstants.kDriverControllerPort ); public RobotContainer() { DogLog.setOptions(new DogLogOptions().withCaptureDs(true)); DogLog.setPdh(new PowerDistribution()); DogLog.log("ExampleLog", "Hello world!"); configureBindings(); } private void configureBindings() { // ... } } ``` -------------------------------- ### Example Usage: Tunable PID Configuration - Java Source: https://doglog.dev/guides/tunable-values Demonstrates how to instantiate and use the `TunablePid` class to apply tunable PID configurations to a TalonFX motor. This example shows creating tunable values for PID gains for an 'Elevator' motor. ```java TunablePid.create("Elevator", elevatorMotor, new TalonFXConfiguration()); ``` -------------------------------- ### Configure DogLog Options Source: https://doglog.dev/getting-started/usage Customize DogLog's behavior by setting options. This example shows how to enable the capture of driver station data. Import both DogLog and DogLogOptions. This configuration should be done in your Robot or RobotContainer constructor. ```java import dev.doglog.DogLog; import dev.doglog.DogLogOptions; DogLog.setOptions(new DogLogOptions().withCaptureDs(true)); ``` -------------------------------- ### Full Example: Tunable PID Configuration - Java Source: https://doglog.dev/guides/tunable-values Provides a comprehensive example of using tunable values to configure PID gains for a TalonFX motor controller. This class allows for PID adjustments without redeploying code, by creating tunable values for kP, kI, kD, kS, kV, kA, and kG. ```java package frc.robot; import com.ctre.phoenix6.configs.TalonFXConfiguration; import com.ctre.phoenix6.hardware.TalonFX; import dev.doglog.DogLog; public class TunablePid { public static void create(String key, TalonFX motor, TalonFXConfiguration defaultConfig) { DogLog.tunable(key + "/kP", defaultConfig.Slot0.kP, newP -> motor.getConfigurator().apply(defaultConfig.Slot0.withKP(newP)) ); DogLog.tunable(key + "/kI", defaultConfig.Slot0.kI, newI -> motor.getConfigurator().apply(defaultConfig.Slot0.withKI(newI)) ); DogLog.tunable(key + "/kD", defaultConfig.Slot0.kD, newD -> motor.getConfigurator().apply(defaultConfig.Slot0.withKD(newD)) ); DogLog.tunable(key + "/kS", defaultConfig.Slot0.kS, newS -> motor.getConfigurator().apply(defaultConfig.Slot0.withKS(newS)) ); DogLog.tunable(key + "/kV", defaultConfig.Slot0.kV, newV -> motor.getConfigurator().apply(defaultConfig.Slot0.withKV(newV)) ); DogLog.tunable(key + "/kA", defaultConfig.Slot0.kA, newA -> motor.getConfigurator().apply(defaultConfig.Slot0.withKA(newA)) ); DogLog.tunable(key + "/kG", defaultConfig.Slot0.kG, newG -> motor.getConfigurator().apply(defaultConfig.Slot0.withKG(newG)) ); } private TunablePid() {} } ``` -------------------------------- ### Replacing DogLog with CustomLogger in Example Class (Java) Source: https://doglog.dev/guides/extending-the-logger This Java example demonstrates how to replace direct calls to DogLog with the custom CustomLogger. It shows logging individual motor values and then using the custom 'log' method for a more concise logging of motor data. ```java package frc.robot; import com.ctre.phoenix6.hardware.TalonFX; import dev.doglog.DogLog; public class ExampleClass { private final TalonFX motor = new TalonFX(1); public void logData() { DogLog.log("ExampleMotor/StatorCurrent", motor.getStatorCurrent().getValue()); DogLog.log("ExampleMotor/Position", motor.getPosition().getValue()); DogLog.log("ExampleMotor/Velocity", motor.getVelocity().getValue()); CustomLogger.log("ExampleMotor", motor); } } ``` -------------------------------- ### Import DogLog Library Source: https://doglog.dev/getting-started/usage Import the DogLog library from the dev.doglog namespace to begin using its logging functionalities. This is the initial step for all DogLog operations. ```java import dev.doglog.DogLog; ``` -------------------------------- ### DogLog Vendordep URL Source: https://doglog.dev/index Provides the vendordep URL for integrating DogLog into an FRC project using the WPILib VS Code extension or manual setup. This URL is essential for adding DogLog as a dependency to your project. ```plaintext https://doglog.dev/vendordep.json ``` -------------------------------- ### Basic Logging with DogLog Source: https://doglog.dev/getting-started/usage Log values using DogLog.log(). This method can be used in periodic methods or any other part of your robot code to record data. Ensure the DogLog library is imported. ```java DogLog.log("Arm/Position", motor.getPosition().getValue()); ``` -------------------------------- ### Track Command Execution Time with DogLog Helper Source: https://doglog.dev/reference/convenience-features Utilize the `DogLog.time()` helper function to automatically wrap a command's execution with timing logs. This function starts a timer, executes the command, and then stops the timer, logging the total execution duration under a specified key. ```javascript var timedCommand = DogLog.time("MyClass/MyCommand", myClass.myCommand()); ``` -------------------------------- ### Logging with Units in DogLog Source: https://doglog.dev/getting-started/usage Log numerical values with associated units using DogLog.log(). This enhances data visualization in applications like AdvantageScope. Units can be provided as a string, a Unit object, or a Measure object. Make sure to import the Units class. ```java import edu.wpi.first.units.Units; import static edu.wpi.first.units.Units.Meters; DogLog.log("Intake/StatorCurrent", intake.getStatorCurrent().getValueAsDouble(), "amps"); DogLog.log("Elevator/Height", elevatorHeightMeters, Meters); DogLog.log("Shooter/Velocity", shooter.getVelocity().getValue()); ``` -------------------------------- ### Track Execution Time with DogLog Source: https://doglog.dev/reference/convenience-features Measure the execution duration of subsystems, commands, or functions using `DogLog.time()` and `DogLog.timeEnd()`. Start the timer with `DogLog.time(key)` and stop it to log the duration with `DogLog.timeEnd(key)`. This helps in identifying performance bottlenecks. ```javascript // Start the timer DogLog.time("MyClass/MyFunction"); myClass.myFunction(); // Stop the timer and log the recorded duration DogLog.timeEnd("MyClass/MyFunction"); ``` -------------------------------- ### Enable PDH/PDP Data Logging in DogLog Source: https://doglog.dev/getting-started/usage Automatically log data from the Power Distribution Hub (PDH) or Power Distribution Panel (PDP) by providing a PowerDistribution instance to DogLog.setPdh(). This requires logging extras to be enabled. Call DogLog.setPdh(null) to disable this feature. ```java import edu.wpi.first.wpilibj.PowerDistribution; DogLog.setPdh(new PowerDistribution()); ``` -------------------------------- ### Basic Logging with DogLog in Java Source: https://doglog.dev/index Demonstrates the basic usage of DogLog for logging data. It shows how to import the library, optionally configure it with `DogLogOptions`, and log a specific data point. This snippet requires the DogLog library to be added as a dependency. ```java // Import import dev.doglog.DogLog; import dev.doglog.DogLogOptions; // Configure (optional) DogLog.setOptions(new DogLogOptions().withCaptureDs(true)); // Log DogLog.log("Arm/Position", motor.getPosition().getValue()); ``` -------------------------------- ### Configure Log Extras Source: https://doglog.dev/reference/configuring Controls whether 'extra' system statistics, such as PDH currents, CAN bus usage, battery voltage, and radio connection status, are included in logs. By default, extras logging is enabled. ```Java DogLog.setOptions(new DogLogOptions().withLogExtras(false)); ``` -------------------------------- ### Configure NetworkTables Tunable Values (Static Value) Source: https://doglog.dev/reference/configuring Enables or disables the use of NetworkTables for tunable values. Using tunable values over NetworkTables in competitions is generally not recommended. By default, DogLog ignores tunable values from NetworkTables if the robot is connected to the FMS. ```Java DogLog.setOptions(new DogLogOptions().withNtTunables(true)); ``` -------------------------------- ### Configure Log Entry Queue Capacity Source: https://doglog.dev/reference/configuring Sets the maximum number of log entries that can be queued for processing by the log thread. If this limit is exceeded, logs will be dropped. Decreasing the value reduces memory usage but risks dropped logs; increasing it reduces the risk of dropped logs but increases memory usage. The default is 1000 entries. ```Java DogLog.setOptions(new DogLogOptions().withLogEntryQueueCapacity(1000)); ``` -------------------------------- ### Configure Driver Station Capture Source: https://doglog.dev/reference/configuring Enables or disables the inclusion of joystick data and driver station values (e.g., 'enabled', 'autonomous') in logs. Due to WPILib limitations, these values cannot be published over NetworkTables and, once enabled, cannot be disabled. By default, driver station capture is disabled. ```Java DogLog.setOptions(new DogLogOptions().withCaptureDs(true)); ``` -------------------------------- ### Configure NetworkTables Tunable Values (Dynamic Value) Source: https://doglog.dev/reference/configuring Dynamically enables or disables the use of NetworkTables for tunable values using a supplier function. This allows for runtime control over tunable value integration. By default, DogLog ignores tunable values from NetworkTables if the robot is connected to the FMS. ```Java DogLog.setOptions(new DogLogOptions().withNtTunables(() -> true)); ``` -------------------------------- ### Configure Console Output Capture Source: https://doglog.dev/reference/configuring Determines whether console output from '/home/lvuser/FRC_UserProgram.log' is included in logs. Due to WPILib limitations, these values cannot be published over NetworkTables. By default, console capture is enabled. ```Java DogLog.setOptions(new DogLogOptions().withCaptureConsole(false)); ``` -------------------------------- ### Configure PDH/PDP Logging in DogLog Source: https://doglog.dev/reference/configuring Automatically log PDH/PDP data like battery voltage and device currents when `logExtras` is enabled. Provide a PowerDistribution instance to DogLog.setPdh(). Calling DogLog.setPdh(null) disables this logging. By default, PDH logging is not performed. ```java DogLog.setPdh(new PowerDistribution()); ``` -------------------------------- ### Configure NetworkTables Publishing (Dynamic Value) Source: https://doglog.dev/reference/configuring Dynamically enables or disables the publishing of logs to NetworkTables using a supplier function. This allows for runtime control over NetworkTables publishing. By default, it's enabled unless connected to the FMS. ```Java DogLog.setOptions(new DogLogOptions().withNtPublish(() -> true)); ``` -------------------------------- ### Configure NetworkTables Publishing (Static Value) Source: https://doglog.dev/reference/configuring Enables or disables the publishing of logs to NetworkTables. This option can consume significant network bandwidth and should generally be avoided with competition radios. By default, it's enabled unless connected to the FMS. ```Java DogLog.setOptions(new DogLogOptions().withNtPublish(true)); ``` -------------------------------- ### Read Tunable Value - Java Source: https://doglog.dev/guides/tunable-values Demonstrates how to retrieve the current value of a previously created tunable value using its Subscriber object. ```java tunable.get(); ``` -------------------------------- ### Create Tunable Value with Units - Java Source: https://doglog.dev/guides/tunable-values Creates tunable number values with associated units for enhanced display in tools like AdvantageScope. Units can be provided as strings, Unit objects, or Measure objects. The unit is written to both the NetworkTables topic and DataLog metadata. ```java import static edu.wpi.first.units.Units.Inches; import static edu.wpi.first.units.Units.RPM; private final DoubleSubscriber intakeVoltage = DogLog.tunable("Intake/Voltage", 4.5, "V"); private final DoubleSubscriber elevatorHeightOverride = DogLog.tunable("Elevator/HeightOverride", 0.0, Inches); private final DoubleSubscriber shooterVelocity = DogLog.tunable("Shooter/Velocity", RPM.of(2000)); ``` -------------------------------- ### Create Tunable Value with Default - Java Source: https://doglog.dev/guides/tunable-values Creates a tunable double value with a specified NetworkTables key and a default value. This returns a NetworkTables Subscriber for accessing the tunable value. DogLog logs the value to the Robot/Tunable/ table in the DataLog. ```java private final DoubleSubscriber voltage = DogLog.tunable("Intake/Voltage", 4.5); ``` -------------------------------- ### Create Tunable Value with On Change Callback - Java Source: https://doglog.dev/guides/tunable-values Registers a consumer function to be executed whenever a tunable value changes. This allows for immediate reaction to value updates without constant polling. Only one callback can be registered per tunable value. ```java private final DoubleSubscriber voltage = DogLog.tunable("Intake/Voltage", 4, newVoltage -> { motor.setVoltage(newVoltage); }); ``` -------------------------------- ### Log Function Call Timestamps with DogLog Source: https://doglog.dev/reference/convenience-features Log the current timestamp to a specified key using `DogLog.timestamp()`. This is useful for tracking the frequency of function calls, as timestamps are unique and monotonically increasing, allowing for graphical representation of call events. ```javascript DogLog.timestamp("MyClass/MyFunction"); ``` -------------------------------- ### Log a basic fault Source: https://doglog.dev/guides/faults Logs a fault with a simple string message. This is the most basic way to record an error. No external dependencies are required beyond the DogLog library. ```java DogLog.logFault("Camera offline"); ``` -------------------------------- ### Configure NetworkTables Capture Source: https://doglog.dev/reference/configuring Controls whether all NetworkTables values are included in logs. Enabling this significantly increases log size and overhead. By default, NetworkTables capture is disabled. This is configured via `DataLogManager.logNetworkTables()`. ```Java DogLog.setOptions(new DogLogOptions().withCaptureNt(true)); ``` -------------------------------- ### Configure Log Processing Thread Source: https://doglog.dev/reference/configuring Controls whether log entries are processed on a dedicated background thread or directly from the main robot thread. Disabling the log thread (default is enabled) eliminates the queue, processing each log immediately, which can reduce memory usage and potential queue-related warnings but may increase CPU load on the main thread. ```Java DogLog.setOptions(new DogLogOptions().withUseLogThread(false)); ``` -------------------------------- ### Custom DogLog Logger for Motor Values (Java) Source: https://doglog.dev/guides/extending-the-logger This Java code defines a custom logger class that extends DogLog. It adds a static method 'log' to easily log multiple properties of a TalonFX motor, simplifying common logging tasks and reducing code duplication. ```java package frc.robot; import com.ctre.phoenix6.hardware.TalonFX; import dev.doglog.DogLog; public class CustomLogger extends DogLog { public static void log(String key, TalonFX motor) { log(key + "/StatorCurrent", motor.getStatorCurrent().getValue()); log(key + "/Position", motor.getPosition().getValue()); log(key + "/Velocity", motor.getVelocity().getValue()); } } ``` -------------------------------- ### Define RobotFault enum Source: https://doglog.dev/guides/faults Defines an enum type to represent different robot faults. This provides a more structured and type-safe way to manage faults compared to using plain strings. ```java public enum RobotFault { CAMERA_OFFLINE, AUTO_SHOT_TIMEOUT_TRIGGERED, BROWNOUT, } ``` -------------------------------- ### Log fault using enum Source: https://doglog.dev/guides/faults Logs a fault by referencing an enum type. This method utilizes the previously defined `RobotFault` enum for logging, offering better code readability and maintainability. ```java DogLog.logFault(RobotFault.CAMERA_OFFLINE); ``` -------------------------------- ### Log a fault with custom alert urgency Source: https://doglog.dev/guides/faults Logs a fault and customizes the alert urgency using `AlertType`. This allows for differentiated fault reporting. Requires `AlertType` enum definition. ```java DogLog.logFault("Arm not homed", AlertType.kWarning); ``` -------------------------------- ### Enable/Disable DogLog Logging Source: https://doglog.dev/reference/configuring Control whether DogLog logs messages. When disabled, all log calls are ignored, which is useful for performance debugging. The logger is enabled by default. Use DogLog.setEnabled(false) to disable and DogLog.setEnabled(true) to re-enable. ```java DogLog.setEnabled(false); ``` ```java DogLog.setEnabled(true); ``` -------------------------------- ### Disable alerts for a logged fault Source: https://doglog.dev/guides/faults Logs a fault without generating an alert by passing `null` for the alert urgency. Useful for non-critical issues that should still be logged. ```java DogLog.logFault("Command timeout", null); ``` -------------------------------- ### Clear a fault Source: https://doglog.dev/guides/faults Resets the occurrence count of a specific fault to zero. This effectively marks the fault as inactive and will also inactivate its associated alert. ```java DogLog.clearFault("Camera offline"); ``` -------------------------------- ### Decrease fault count Source: https://doglog.dev/guides/faults Decreases the occurrence count of a specific fault by one. This is useful for temporary faults that have been resolved. It does not clear the fault entirely but reduces its active count. ```java DogLog.decreaseFault("Camera offline"); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.