pykal

Documentation

  • Getting Started
    • Overview
      • Who am I?
      • The Problem
      • The Solution
      • Using the Tutorial
        • Overview
        • Theory to Python
        • Python to ROS
        • ROS to Gazebo
    • Theory to Python
      • Installation
        • Prerequisites
        • Basic Install
      • Control Systems as Dynamical Systems
        • Example: Car Cruise Control
          • System Overview
          • Dynamical System Graph
            • Block 1: Setpoint Generator
              • Simulating Different Scenarios
              • Composing Dynamical Systems
            • Block 2: PID
            • Block 3: Car (Plant)
            • Block 4: KF (Observer)
            • Wrapping the Complete System
          • Experimentation
        • Example: TurtleBot with Noisy Odometry
          • System Overview
          • Block Diagram
            • Discrete-time Dynamical Systems
            • Block 1: Waypoint Generator
            • Block 2: Velocity Command Generator
            • Block 3: TurtleBot (Plant)
            • Block 4: Kalman Filter (Observer)
          • Simulation
            • System Parameters
            • Initial Conditions
            • Simulate
            • Visualize
          • Experimentation
        • Example: Crazyflie Multi-Sensor Fusion
          • System Overview
          • Block Diagram
            • Discrete-time Dynamical Systems
            • Block 1: Setpoint Generator
            • Block 2: Position Controller
            • Block 3: Crazyflie Quadrotor (Plant)
            • Block 4: Multi-Sensor Measurements
              • Sensor 1: Motion Capture System
              • Sensor 2: Barometric Altimeter
              • Sensor 3: IMU (Inertial Measurement Unit)
              • Combined Measurement Vector
            • Block 5: Multi-Sensor Kalman Filter (Observer)
          • Simulation
            • System Parameters
            • Initial Conditions
            • Simulate
            • Visualize
          • Experimentation
      • Algorithms as Dynamical Systems
        • Example: Kalman Filter
          • Definition of Algorithm
            • Notation and Assumptions
            • How it works
          • Algorithm as an \((f,h)\)-representation
            • Example: 1D Constant Velocity Tracking
          • Notes on Usage
            • Jacobian Requirements
            • Tuning Guidance
        • Example: PID Controller
          • Definition of Algorithm
            • Notation and Assumptions
            • How it works
          • Algorithm as an \((f,h)\)-representation
            • Example: First-Order System Tracking
          • Notes on Usage
            • Common Applications
            • Tuning Guidance
            • Implementation Details
      • Modules
        • DynamicalSystem
          • Conceptual Foundation
            • Discrete-Time Dynamical Systems
            • Simplifying Conventions
            • Programmatic Implementation of a Discrete-Time Dynamical System
          • References and Examples
            • Stateless vs Stateful
              • Stateless System (h only)
              • Stateful System
            • Single Step vs Simulation Loops
              • Single Step
              • Simulation loop
            • Parameter Binding
              • Positional vs Keyword Arguments
              • The _smart_call Function
              • Using only **kwargs
              • Parameter Dictionary Sharing
            • Composition
            • Casting Algorithms in an \((f,h)\)-representation
        • DataChange
          • References and Examples
            • Generate Reference Signals
            • Gaussian Noise
              • Moving Average Filter
              • Exponential Smoothing
              • Low-Pass Filter (First-Order)
            • Contact Bounce
              • Debounce
            • Dropouts (Packet Loss)
              • Interpolation (Fill Missing Data)
            • Asynchronous / Multi-Rate Data
              • Kalman Filter Multi-Rate Sensor Fusion
              • Staleness Policy (Asynchronous Sensors)
            • Constant Bias
              • Calibration (Remove Bias and Scale)
            • Drift (Time-Dependent Bias)
            • Quantization (ADC Resolution Limits)
            • Spikes / Outliers
              • Median Filter
              • Outlier Removal (Z-Score)
            • Saturation / Clipping
              • Clipping Recovery
            • Time Delay / Latency
            • Realistic Hardware Pipelines
            • Scenario 1: Noisy IMU Accelerometer
            • Scenario 2: Bouncing Rotary Encoder
            • Scenario 3: Wireless Sensor with Packet Loss
    • Python to ROS
      • Installation
        • Ubuntu 24.04: ROS2 Jazzy Installation
        • Ubuntu 22.04: ROS2 Humble Installation
        • Make ROS2 Sourcing Permanent
      • Dynamical Systems as ROS Nodes
        • TurtleBot State Estimation: From Python to ROS2
        • Conceptual Foundation: From Dynamical Systems to ROS Nodes
          • The ROS Mapping
          • Adding Teleoperation
          • Individual Node Blocks
            • Waypoint Generator
            • Velocity Controller
            • TurtleBot Plant
            • EKF Observer
          • Architecture Comparison: Python Simulation vs ROS Nodes
          • ROS2 System Architecture
          • Setup: Imports and Core Functions
            • Core TurtleBot Functions (from Theory Notebook)
          • Node 1: Waypoint Generator
          • Node 2: Velocity Controller
          • Node 3: TurtleBot Simulator (Plant)
          • Node 4: Extended Kalman Filter Observer
          • Running the Complete ROS2 System
            • Data Collection for Analysis
            • Stopping the System
          • Visualization and Analysis
          • Summary: Python → ROS2 Deployment
        • Architecture 2: Teleoperation Mode
          • Summary: Two ROS Architectures Demonstrated
            • Architecture 1: Autonomous Navigation (Waypoint Tracking)
            • Architecture 2: Teleoperation (Manual Control)
            • Key Insights
          • Visualization: Teleoperation Results
            • Stopping Teleoperation Nodes
            • Data Collection During Teleoperation
          • Running the Keyboard Teleop Tool
          • Setting Up Teleoperation Mode
        • Crazyflie Multi-Sensor Fusion: From Python to ROS2
        • Conceptual Foundation: From Dynamical Systems to ROS Nodes
          • The ROS Mapping
          • Adding Teleoperation
          • Individual Node Blocks
            • Setpoint Generator
            • Position Controller
            • Crazyflie Plant
            • Kalman Filter Observer
          • Architecture Comparison: Python vs ROS2 Multi-Sensor System
          • ROS2 Multi-Sensor System Architecture
          • Setup: Imports and Core Functions
            • Core Crazyflie Functions (from Theory Notebook)
          • Node 1: Setpoint Generator
          • Node 2: Position Controller
          • Node 3: Crazyflie Simulator with Multi-Sensor Output
          • Node 4: Multi-Sensor Kalman Filter
          • Running the Multi-Sensor ROS2 System
            • Data Collection
            • Stopping the System
          • Visualization: Multi-Sensor Fusion Analysis
          • Summary: Multi-Sensor Python → ROS2 Deployment
        • Architecture 2: Teleoperation Mode
          • Summary: Two ROS Architectures with Multi-Sensor Fusion
            • Architecture 1: Autonomous Navigation (Setpoint Tracking)
            • Architecture 2: Teleoperation (Manual Joystick Control)
            • Key Insights
          • Visualization: Teleoperation Results
            • Stopping Teleoperation Nodes
            • Data Collection During Teleoperation
          • Running the Joystick Teleop Tool
          • Setting Up Teleoperation Mode
      • Modules
        • ROSNode
        • Conceptual Foundation
          • Programmatic Implementation
          • References and Examples
          • Part 1: Basic Node Structure
            • Example 1.1: Simple Echo Node
            • Example 1.2: Velocity Scaling Node
          • Part 2: Stateful Callbacks with Closures
            • Example 2.1: Simple Integrator
            • Example 2.2: Proportional Controller
          • Part 3: Multi-Rate Sensor Fusion with Staleness Policies
            • Example 3.1: Multi-Sensor Fusion Node
            • Example 3.2: Staleness Policy Comparison
          • Part 4: Required Topics and Error Handling
            • Example 4.1: Required Topics
            • Example 4.2: Error Callbacks
          • Part 5: Diagnostics and Heartbeat Monitoring
            • Example 5.1: Node Diagnostics
            • Example 5.2: Heartbeat Monitoring
          • Part 6: Running and Managing Nodes
            • Example 6.1: Node Lifecycle
            • Example 6.2: Running Multiple Nodes
          • Part 7: Integration with DynamicalSystem
            • Example 7.1: Kalman Filter as ROS Node
          • Part 8: Complete Example - Car Cruise Control ROS Deployment
            • Node 1: Setpoint Generator (Cruise Control Button)
            • Node 2: PID Controller
            • Node 3: Plant (Car Simulator)
            • Node 4: Kalman Filter Observer
            • Running the Complete Cruise Control ROS System
          • Summary
            • Next Steps
        • ros2py_py2ros
          • References and Examples
            • Time and Header Conversions
              • Time Conversion
              • Header Conversion
            • Basic Geometry Messages
              • Vector3: 3D Points and Directions
              • Quaternion: 3D Rotations
              • Pose: Position + Orientation
              • Twist: Linear + Angular Velocity
            • Stamped Messages (With Time)
              • PoseStamped: Pose + Timestamp
              • TwistStamped: Velocity + Timestamp
              • Vector3Stamped: 3D Vector + Timestamp
            • Complex Robot Messages
              • Odometry: Full Robot State
              • IMU: Inertial Measurement Unit
              • TransformStamped: TF Tree Transforms
            • Sensor Messages
              • LaserScan: 2D Lidar Data
              • JointState: Robot Joint Positions/Velocities
            • Using the Conversion Registries
              • Checking Available Converters
              • Using Registries for Generic Conversion
            • Practical Workflow Examples
              • Example 1: Processing Odometry Stream
              • Example 2: Creating Stamped Messages with Current Time
              • Example 3: Batch Processing Multiple Poses
          • Working with Custom ROS Message Types
            • Why Custom Messages?
            • Message Converter Architecture
            • Creating a Custom Message
              • Step 1: Define Message in Package
              • Step 2: Configure Package
              • Step 3: Build Package
            • Registering Converters with pykal
              • Basic Converter Pattern
              • Example: Multi-Sensor Fusion Message
              • Example: Control Command Message
            • Using Custom Messages with ROSNode
              • Basic Example
              • Complete Example: Sensor Fusion System
            • Advanced Topics
              • Handling Timestamps
              • Variable-Length Arrays
              • Nested Messages
              • Array Messages
            • Best Practices
              • 1. Flatten to 1D Arrays
              • 2. Use .tolist() for ROS Messages
              • 3. Document Expected Array Format
              • 4. Register Early
              • 5. Test Converters Independently
            • Common Pitfalls
              • Pitfall 1: Wrong Array Shape
              • Pitfall 2: Forgetting to Register
              • Pitfall 3: Type Mismatches
              • Pitfall 4: Modifying Converters After Node Creation
            • Complete Custom Message Workflow
              • 1. Create Message Package
              • 2. Create Converter Module
              • 3. Use in ROSNode
          • Summary
      • ROS Tips and Tricks
        • Visualizing ROS Graphs with rqt_graph
          • What is rqt_graph?
          • Installation
          • Usage
            • Basic Usage
            • Visualizing the TurtleBot Software System
            • Visualizing TurtleBot with Gazebo
            • Visualizing Crazyflie Multi-Sensor Fusion
          • Useful rqt_graph Features
            • Filtering Nodes
            • Hiding Debug Topics
            • Refreshing the Graph
            • Layout Options
          • Comparing Architectures
            • Software vs Gazebo vs Hardware
          • Debugging with rqt_graph
            • Common Issues
          • Advanced: Recording Graph Changes
          • Alternative Tools
          • Summary
        • ROS2 Launch Files with pykal
          • Why Launch Files?
          • ROS2 Launch File Basics
          • Launch File Structure for pykal
            • Option 1: Create a Standalone Script
            • Option 2: Use Launch File to Run Script
            • Option 3: Multi-Process Launch (Recommended)
          • Example: TurtleBot Launch System
          • Launching with Gazebo
          • Parameter Files
          • Advanced Launch Features
            • Conditional Launching
            • Node Dependencies
            • Namespace Management
          • Testing Launch Files
          • Best Practices
          • Summary
        • Advanced ROS Features
          • Overview
          • Transform Frames (tf/tf2)
            • Why Transforms Matter
            • Understanding the Transform Tree
            • Using tf2 in Python
            • Publishing Transforms
            • Integrating tf2 with pykal
          • ROS Bags: Recording and Replay
            • Why Use Bags?
            • Recording Bags
            • Playing Back Bags
            • Analyzing Bags in Python
          • Multi-Robot Systems
            • Using Namespaces
            • Multi-Robot Coordination
          • Visualization with RViz2
            • Launch RViz2
            • Common Display Types
          • Quality of Service (QoS)
            • Why QoS Matters
            • QoS Profiles
            • Matching QoS
          • Parameter Server
            • Dynamic Parameters
          • Actions (Long-Running Tasks)
            • When to Use Actions
            • Action Client Example
          • Best Practices
          • Summary
      • Troubleshooting Common Issues
        • ROS2 Node Issues
          • Node Not Publishing
          • Node Not Receiving Messages
        • Message Conversion Errors
          • “No converter registered” Error
          • “Array shape mismatch” Error
        • Gazebo Integration Issues
          • “No /odom topic” After Starting Gazebo
          • Gazebo Crashes with “libGL error”
          • Robot Doesn’t Move in Gazebo
        • Time Synchronization Issues
          • “use_sim_time” Warning
          • Timestamps in Future
        • Callback Rate Issues
          • Callback Running Too Slow
          • Callback Not Running
        • DynamicalSystem Issues
          • “state_name required” Error
          • State Not Updating
        • Parameter Binding Issues
          • “Missing required parameter” Error
          • Unexpected Parameter Ignored
        • Debugging Strategies
          • Enable Verbose Logging
          • Check ROS Topic Communication
          • Visualize ROS Graph
          • Test Components Independently
          • Use Python Debugger
        • Common Error Messages Reference
        • Getting Help
        • Summary
    • ROS to Gazebo
      • Installation
        • Gazebo Harmonic (for ROS2 Jazzy on Ubuntu 24.04)
        • Gazebo Garden (for ROS2 Humble on Ubuntu 22.04)
        • Install Robot-Specific Packages
          • Development Installation
          • Documentation Build Setup
          • Verification
          • Troubleshooting
      • ROS Nodes and Gazebo
        • TurtleBot State Estimation: From Software to Gazebo Simulation
          • Architecture Evolution: Software → Gazebo
          • Conceptual Foundation: From Dynamical Systems to Gazebo
            • Theory: Composition of Dynamical Systems
            • ROS Deployment: Distributed Nodes
            • Gazebo Integration: Same Architecture, Physics Engine
            • Teleoperation with Gazebo
          • What Gazebo Provides
          • Setup: Imports
            • Component Functions (Reuse from ROS Deployment)
          • Step 1: Launch Gazebo with TurtleBot3
          • Step 2: Node Architecture (Without Simulator)
            • Node 1: Waypoint Generator (Unchanged)
            • Node 2: Velocity Controller (Unchanged)
            • Node 3: Kalman Filter (Uses Gazebo’s /odom)
          • Step 3: Run the Integrated System
            • Data Logger (For Analysis)
            • Stop the System
          • Visualization: Gazebo vs Software Simulation
          • Summary: The Complete Pipeline
        • Architecture 2: Teleoperation with Gazebo
          • Summary: Dual Architectures with Gazebo
            • Architecture 1: Autonomous Navigation (Waypoint Tracking)
            • Architecture 2: Teleoperation (Manual Control)
            • Key Insights
            • Stopping Teleoperation Mode
          • Running Keyboard Teleop with Gazebo
          • Setting Up Teleoperation with Gazebo
        • Crazyflie Multi-Sensor Fusion: From Software to Gazebo
          • Architecture Evolution: Software → Gazebo
          • Conceptual Foundation: From Dynamical Systems to Gazebo
            • Theory: Composition of Dynamical Systems
            • ROS Deployment: Distributed Nodes
            • Gazebo Integration: Same Architecture, Physics Engine
            • Teleoperation with Gazebo
          • What Gazebo’s Crazyflie Provides
          • Setup: Imports
            • Component Functions
          • Step 1: Launch Gazebo with Crazyflie
          • Step 2: Node Architecture - Preserved from ROS Deployment
            • Node 1: Setpoint Generator (Unchanged)
            • Node 2: Position Controller (Unchanged)
            • Node 3: Kalman Filter (Multi-Sensor Fusion - Unchanged!)
          • Step 3: Run the Integrated System
            • Data Logger
            • Stop the System
          • Visualization: Architecture Adaptation Analysis
          • Summary: Multi-Sensor Architecture Preservation
          • Summary: Dual Architectures with Multi-Sensor Gazebo
            • Architecture 1: Autonomous Navigation (Setpoint Tracking)
            • Architecture 2: Teleoperation (Manual Joystick Control)
            • Key Insights
            • Stopping Teleoperation Mode
          • Running Joystick Teleop with Gazebo
          • Setting Up Teleoperation with Gazebo
        • Architecture 2: Teleoperation with Gazebo
      • Modules
        • Gazebo Simulation Launcher
          • Overview
          • Learning Objectives
          • Part 1: Basic Usage
            • 1.1 Start Gazebo with TurtleBot3
            • 1.2 Let Simulation Run
            • 1.3 Stop Gazebo
          • Part 2: Configuration Options
            • 2.1 Supported Robots
            • 2.2 Spawn Position and Orientation
            • 2.3 Headless Mode (Faster Simulation)
            • 2.4 Different Worlds
          • Part 3: Lifecycle Management
            • 3.1 The GazeboProcess Object
            • 3.2 Always Use stop_gazebo()
            • 3.3 Error Handling
          • Part 4: Integration with ROS2
            • 4.1 Available ROS2 Topics
            • 4.2 Quick Topic Check
          • Part 5: Common Use Cases
            • 5.1 Use Case: Interactive Development
            • 5.2 Use Case: Automated Testing
            • 5.3 Use Case: Multi-Robot Experiments
          • Part 6: Best Practices
            • 6.1 Development Workflow
            • 6.2 Performance Considerations
            • 6.3 Troubleshooting
          • Summary
            • Key Functions
            • Configuration Options
            • Best Practices
            • Next Steps
      • Gazebo Tips and Tricks
        • Gazebo Simulation Launcher
          • Overview
          • Learning Objectives
          • Part 1: Basic Usage
            • 1.1 Start Gazebo with TurtleBot3
            • 1.2 Let Simulation Run
            • 1.3 Stop Gazebo
          • Part 2: Configuration Options
            • 2.1 Supported Robots
            • 2.2 Spawn Position and Orientation
            • 2.3 Headless Mode (Faster Simulation)
            • 2.4 Different Worlds
          • Part 3: Lifecycle Management
            • 3.1 The GazeboProcess Object
            • 3.2 Always Use stop_gazebo()
            • 3.3 Error Handling
          • Part 4: Integration with ROS2
            • 4.1 Available ROS2 Topics
            • 4.2 Quick Topic Check
          • Part 5: Common Use Cases
            • 5.1 Use Case: Interactive Development
            • 5.2 Use Case: Automated Testing
            • 5.3 Use Case: Multi-Robot Experiments
          • Part 6: Best Practices
            • 6.1 Development Workflow
            • 6.2 Performance Considerations
            • 6.3 Troubleshooting
          • Summary
            • Key Functions
            • Configuration Options
            • Best Practices
            • Next Steps
        • Performance Comparison: Software → Gazebo → Hardware
          • 1. System Definition
          • 2. Software Simulation (Ideal)
          • 3. Gazebo Simulation (Realistic Physics)
          • 4. Hardware Deployment (Real World)
          • 5. Performance Metrics
          • 6. Visualization
          • 7. Key Observations
            • Performance Degradation
            • Why This Matters
            • Tuning Insights
          • 8. Conclusions
      • Troubleshooting Gazebo Issues
        • Gazebo Launcher Issues
          • Gazebo Won’t Start
          • Gazebo Crashes with Graphics Error
          • “Model not found” Error
        • Robot Spawning Issues
          • Robot Not Appearing in Gazebo
          • Robot Spawns Underground
          • Multiple Robots Not Spawning
        • ROS Topics Issues
          • No /odom Topic After Launch
          • /cmd_vel Commands Ignored
          • Sensor Topics Missing
        • Simulation Performance Issues
          • Simulation Running Very Slow
          • High CPU Usage
          • Memory Leaks
        • Time and Synchronization Issues
          • use_sim_time Not Set
          • Timestamps in Future Warning
          • Simulation Time Not Advancing
        • Process Management Issues
          • Gazebo Won’t Stop
          • “Address already in use” Error
          • Multiple Gazebo Instances
        • Headless Mode Issues
          • Headless Mode Still Shows Window
          • Headless Mode Slower Than Expected
        • World and Environment Issues
          • World Not Loading
          • Robot-World Collision Issues
        • Debugging Strategies
          • Enable Verbose Logging
          • Check Gazebo Topics
          • Check ROS2-Gazebo Bridge
          • Test Without pykal Wrapper
          • Monitor System Resources
        • Common Error Messages Reference
        • Getting Help
        • Summary
  • Community
  • Community Library
  • License

API Reference

  • API Reference
    • DynamicalSystem
      • DynamicalSystem
        • f
        • h
        • step()
    • Data Corruption and Preparation
      • clean
        • with_calibration()
        • with_clipping_recovery()
        • with_debounce()
        • with_exponential_smoothing()
        • with_interpolation()
        • with_low_pass_filter()
        • with_median_filter()
        • with_moving_average()
        • with_outlier_removal()
        • with_staleness_policy()
      • corrupt
        • with_bias()
        • with_bounce()
        • with_clipping()
        • with_delay()
        • with_drift()
        • with_dropouts()
        • with_gaussian_noise()
        • with_quantization()
        • with_spikes()
      • Corruption Utilities
        • corrupt
          • with_bias()
          • with_bounce()
          • with_clipping()
          • with_delay()
          • with_drift()
          • with_dropouts()
          • with_gaussian_noise()
          • with_quantization()
          • with_spikes()
      • Preparation Utilities
    • Algorithm Library
      • Submodules
        • Estimators
          • Kalman Filter
            • KF
              • f()
              • h()
            • f()
            • h()
          • Unscented Kalman Filter
            • UKF
              • f()
              • h()
            • f()
            • h()
          • Particle Filter
            • PF
            • ParticleFilter
              • effective_sample_size()
              • f()
              • h()
            • f()
            • h()
          • AI-UKF (Augmented Information UKF)
            • AIUKF
              • compute_observability_variance()
              • create_augmented_R()
              • f()
              • h()
            • compute_observability_variance()
            • f()
            • h()
        • Controllers
          • PID Controller
            • PID
              • f()
              • h()
            • f()
            • h()
          • LQR Controller
            • LQR
              • compute_gain()
              • f()
              • h()
            • compute_gain()
            • f()
            • h()
          • MPC Controller
            • MPC
              • f()
              • h()
              • simple_f()
              • simple_h()
              • solve_single_step()
            • f()
            • h()
            • simple_f()
            • simple_h()
            • solve_single_step()
    • Gazebo Simulation
      • GazeboProcess
        • process
        • robot
        • world
        • headless
        • is_running()
        • terminate()
      • quick_start()
      • restart_gazebo()
      • start_gazebo()
      • stop_gazebo()
      • Gazebo Launcher
        • GazeboProcess
          • process
          • robot
          • world
          • headless
          • is_running()
          • terminate()
        • quick_start()
        • restart_gazebo()
        • start_gazebo()
        • stop_gazebo()
    • ROS Integration
      • ROSNode
      • Message Converters
pykal
  • API Reference
  • View page source

API Reference

This section provides detailed API documentation for all pykal modules.

Core Modules

  • DynamicalSystem
    • DynamicalSystem
  • Data Corruption and Preparation
    • clean
    • corrupt
    • Corruption Utilities
    • Preparation Utilities

Algorithm Library

  • Algorithm Library
    • Submodules

Simulation

  • Gazebo Simulation
    • GazeboProcess
    • quick_start()
    • restart_gazebo()
    • start_gazebo()
    • stop_gazebo()
    • Gazebo Launcher

ROS Integration

  • ROS Integration
    • ROSNode
    • Message Converters
Previous Next

© Copyright 2025, Nehal Singh Mangat.

Built with Sphinx using a theme provided by Read the Docs.