### Install IR-SIM Package Source: https://github.com/hanruihua/neupan/blob/main/README.md Installs the IR-SIM simulator using pip. This is a prerequisite for running the NeuPAN examples. ```shell pip install ir-sim ``` -------------------------------- ### Run NeuPAN Examples with IR-SIM Source: https://github.com/hanruihua/neupan/blob/main/README.md Executes NeuPAN examples in IR-SIM using the `run_exp.py` script. These commands demonstrate navigation performance for different scenarios (e.g., `non_obs`, `dyna_non_obs`, `polygon_robot`, `dyna_obs`, `corridor`) and robot types (`acker`, `diff`), with optional visualization (`-v`). ```python run_exp.py -e non_obs -d acker ``` ```python run_exp.py -e dyna_non_obs -d acker ``` ```python run_exp.py -e polygon_robot -d diff ``` ```python run_exp.py -e dyna_obs -d diff -v ``` ```python run_exp.py -e corridor -d acker ``` ```python run_exp.py -e corridor -d diff ``` -------------------------------- ### Neupan Project Configuration Parameters Source: https://github.com/hanruihua/neupan/blob/main/example/model/acker_robot_default/results.txt Defines the core configuration settings for the Neupan project, including data characteristics, training hyperparameters, and frequency for validation and saving. These parameters are crucial for reproducibility and understanding the training setup. ```text data_size: 100000, data_range: [-25, -25, 25, 25], batch_size: 256, epoch: 5000, valid_freq: 250, save_freq: 500, lr: 5e-5, lr_decay: 0.5, decay_freq: 1500 ``` -------------------------------- ### Initialize NeuPAN Planner from YAML Configuration Source: https://context7.com/hanruihua/neupan/llms.txt Loads and initializes the NeuPAN planner using parameters specified in a YAML configuration file or programmatically. ```APIDOC ## Initialize NeuPAN Planner ### Description Loads and initializes the NeuPAN planner with robot parameters, path planning settings, and optimization weights from a YAML file or programmatically. ### Method Python Function Call ### Endpoint N/A (Python Library) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```python from neupan import neupan import numpy as np # Initialize planner from YAML configuration # planner = neupan.init_from_yaml('planner.yaml') # Alternatively, initialize programmatically planner = neupan( receding=10, step_time=0.1, ref_speed=4.0, device='cpu', robot_kwargs={ 'kinematics': 'diff', 'max_speed': [8.0, 1.0], 'max_acce': [8.0, 3.0], 'length': 1.6, 'width': 2.0 }, ipath_kwargs={ 'waypoints': [[0, 0, 0], [10, 10, 0]], 'curve_style': 'line' }, pan_kwargs={ 'iter_num': 2, 'dune_max_num': 100, 'nrmp_max_num': 10, 'dune_checkpoint': 'model/diff_robot_default/model_5000.pth' } ) ``` ### Response #### Success Response (Initialization) - **planner** (object) - An initialized NeuPAN planner object. #### Response Example ```python # Planner object is returned and ready for use print(type(planner)) # Output: ``` ``` -------------------------------- ### Setting Initial Path in NeuPAN (Python) Source: https://github.com/hanruihua/neupan/blob/main/README.md This Python code illustrates how to update the initial path for the NeuPAN algorithm in real-time. This is crucial for integrating NeuPAN with global planners like A*. ```python from neupan.neupan import NeuPAN # Assume 'neuPAN_instance' is an initialized NeuPAN object # neuPAN_instance = NeuPAN(...) # Assume 'new_initial_path' is a list of waypoints or a trajectory object # new_initial_path = [...] # neuPAN_instance.set_initial_path(new_initial_path) # The actual function call is: # https://github.com/hanruihua/NeuPAN/blob/main/neupan/neupan.py#L286C9-L286C25 ``` -------------------------------- ### Initialize NeuPAN Planner from YAML or Programmatically (Python) Source: https://context7.com/hanruihua/neupan/llms.txt Initializes the NeuPAN planner using either a YAML configuration file or programmatic arguments. The configuration specifies robot parameters, path planning settings, and optimization weights. The function returns a planner object ready for use. Dependencies include 'neupan' and 'numpy'. ```python from neupan import neupan import numpy as np # Initialize planner from YAML configuration planner = neupan.init_from_yaml('planner.yaml') # Example YAML structure: # receding: 10 # MPC receding horizon steps # step_time: 0.1 # Time step in seconds # ref_speed: 4.0 # Reference speed m/s # device: 'cpu' # 'cpu' or 'cuda' # robot: # kinematics: 'diff' # 'diff' or 'acker' # max_speed: [8, 1] # [linear, angular/steering] # max_acce: [8, 3] # Maximum accelerations # length: 1.6 # Robot length (m) # width: 2.0 # Robot width (m) # ipath: # waypoints: [[0, 0, 0], [10, 10, 0]] # [x, y, theta] # curve_style: 'dubins' # 'dubins', 'reeds', or 'line' # min_radius: 3.0 # Minimum turning radius # pan: # iter_num: 2 # Iterations per step # dune_max_num: 100 # Max points for DUNE # nrmp_max_num: 10 # Max points for NRMP # dune_checkpoint: 'model/diff_robot_default/model_5000.pth' # adjust: # q_s: 1.0 # State cost weight # p_u: 1.0 # Speed cost weight # eta: 10.0 # Safety distance weight # d_max: 1.0 # Maximum safety distance (m) # d_min: 0.1 # Minimum safety distance (m) # Alternatively, initialize programmatically planner = neupan( receding=10, step_time=0.1, ref_speed=4.0, device='cpu', robot_kwargs={ 'kinematics': 'diff', 'max_speed': [8.0, 1.0], 'max_acce': [8.0, 3.0], 'length': 1.6, 'width': 2.0 }, ipath_kwargs={ 'waypoints': [[0, 0, 0], [10, 10, 0]], 'curve_style': 'line' }, pan_kwargs={ 'iter_num': 2, 'dune_max_num': 100, 'nrmp_max_num': 10, 'dune_checkpoint': 'model/diff_robot_default/model_5000.pth' } ) ``` -------------------------------- ### Complete Navigation Loop with IR-SIM and NeuPAN Source: https://context7.com/hanruihua/neupan/llms.txt Demonstrates an end-to-end navigation loop using the NeuPAN planner integrated with the IR-SIM simulation environment. It shows how to initialize the simulator and planner, process sensor data (LiDAR), compute control actions, visualize results, and handle navigation termination conditions. ```python import irsim from neupan import neupan import numpy as np # Initialize simulation environment env = irsim.make('env.yaml', display=True) # Initialize NeuPAN planner planner = neupan.init_from_yaml('planner.yaml') # Navigation loop max_steps = 1000 for step in range(max_steps): # Get current robot state [x, y, theta, ...] from simulator robot_state = env.get_robot_state()[0:3] # Get LiDAR scan from simulator lidar_scan = env.get_lidar_scan() # Convert LiDAR to obstacle points points = planner.scan_to_point(robot_state, lidar_scan) # Compute control action action, info = planner(robot_state, points) # Check termination conditions if info['stop']: print(f"Stopped: collision risk, min_dist={planner.min_distance:.3f}") break if info['arrive']: print(f"Success: reached target at step {step}") break # Visualization env.draw_points(planner.dune_points, s=25, c='g', refresh=True) env.draw_points(planner.nrmp_points, s=13, c='r', refresh=True) env.draw_trajectory(planner.opt_trajectory, 'r', refresh=True) env.draw_trajectory(planner.ref_trajectory, 'b', refresh=True) if step == 0: env.draw_trajectory(planner.initial_path, traj_type='-k') # Execute action and render env.step(action) env.render() # Check environment termination if env.done(): break # Cleanup env.end(display_time=3, ani_name='navigation_result') # For multiple runs, reset between episodes planner.reset() env.reset() ``` -------------------------------- ### ROS Integration for Initial Path Refresh (ROS/Python) Source: https://github.com/hanruihua/neupan/blob/main/README.md This ROS-specific configuration demonstrates how to refresh the initial path for NeuPAN using the `/initial_path` topic. Setting `refresh_initial_path` to True allows real-time updates from global planners. ```python # In neupan_ros configuration (e.g., a YAML file or launch file): # parameters: # refresh_initial_path: True # initial_path_topic: /initial_path # This implies that the neupan_ros node will subscribe to '/initial_path' # and use the received data to update the NeuPAN algorithm's initial trajectory # when 'refresh_initial_path' is enabled. ``` -------------------------------- ### Online Parameter Adjustment for NeuPAN with PyTorch Source: https://context7.com/hanruihua/neupan/llms.txt Explains how to perform online learning-based adjustment (LON) of NeuPAN planner parameters using PyTorch. It shows the initialization of trainable parameters (q_s, p_u, eta, d_max, d_min) and setting up an Adam optimizer to fine-tune these parameters for optimized navigation performance in specific environments. ```python import torch from neupan import neupan import irsim # Initialize with trainable parameters env = irsim.make(display=True) planner = neupan.init_from_yaml('planner.yaml') # Get adjust parameters as trainable tensors q_s = planner.adjust_parameters[0] p_u = planner.adjust_parameters[1] eta = planner.adjust_parameters[2] d_max = planner.adjust_parameters[3] d_min = planner.adjust_parameters[4] # Setup optimizer optimizer = torch.optim.Adam([p_u, eta, d_max], lr=5e-3) ``` -------------------------------- ### Configure Rectangular Robot and Training for NeuPAN Planner Source: https://context7.com/hanruihua/neupan/llms.txt Defines parameters for a rectangular robot and sets up the training configuration for the NeuPAN planner. This includes specifying robot kinematics, dimensions, speed limits, and training parameters like data size, batch size, learning rate, and saving frequencies. These configurations are used to initialize the planner. ```python robot_kwargs_rect = { 'kinematics': 'diff', 'length': 2.0, # Instead of vertices 'width': 1.8, 'max_speed': [8.0, 1.0], 'max_acce': [8.0, 3.0], 'name': 'custom_diff_robot' } # Training configuration train_kwargs = { 'direct_train': True, # Train without user confirmation 'model_name': 'custom_acker_robot', 'data_size': 100000, # Training samples 'data_range': [-25, -25, 25, 25], # [x_min, y_min, x_max, y_max] 'batch_size': 256, 'epoch': 5000, # Training epochs 'valid_freq': 100, # Validation frequency 'save_freq': 500, # Model save frequency 'lr': 5e-5, # Learning rate 'lr_decay': 0.5, # Learning rate decay 'decay_freq': 1500, # Decay frequency 'save_loss': False # Save loss history } # Initialize planner with training config planner = neupan( receding=10, step_time=0.1, ref_speed=4.0, robot_kwargs=robot_kwargs, ipath_kwargs={'waypoints': [[0, 0, 0], [10, 10, 0]]}, pan_kwargs={ 'iter_num': 2, 'dune_max_num': 100, 'nrmp_max_num': 10, 'dune_checkpoint': None # Will trigger training }, train_kwargs=train_kwargs ) # Or train explicitly planner.train_dune() # Output: Model saved to ./model/custom_acker_robot/model_5000.pth # Training typically takes 1-2 hours on CPU # Use trained model in new planner instance new_planner = neupan.init_from_yaml('config.yaml') # config.yaml should specify: dune_checkpoint: 'model/custom_acker_robot/model_5000.pth' ``` -------------------------------- ### Neupan Project Configuration and Robot Matrices (Python/PyTorch) Source: https://github.com/hanruihua/neupan/blob/main/example/model/polygon_robot/results.txt Defines configuration parameters for the Neupan project and initializes robot matrices using PyTorch tensors. These parameters control training aspects like data size, batch size, epochs, and learning rate. The robot matrices `robot_G` and `robot_h` are essential for the robot's kinematic or dynamic model. ```python data_size: 100000, data_range: [-25, -25, 25, 25], batch_size: 256, epoch: 5000, valid_freq: 100, save_freq: 500, lr: 5e-05, lr_decay: 0.5, decay_freq: 1500, robot_G: tensor([[ 0.0000, -1.6000], [ 2.0000, -1.0000], [ 0.0000, 3.6000], [-2.0000, -1.0000]]), robot_h: tensor([[1.6000], [2.6000], [3.6000], [2.6000]]) ``` -------------------------------- ### Neupan Project Configuration Parameters Source: https://github.com/hanruihua/neupan/blob/main/example/model/diff_robot_default/results.txt Defines the initial configuration parameters for the Neupan project, including data size, range, batch size, and training epochs. It also includes robot-specific matrices 'G' and 'h'. ```python data_size: 100000, data_range: [-25, -25, 25, 25], batch_size: 256, epoch: 5000, valid_freq: 250, save_freq: 500, lr: 5e-5, lr_decay: 0.5, decay_freq: 1500, robot_G: tensor([[ 0.0000, -1.6000], [ 2.0000, -0.0000], [ 0.0000, 1.6000], [-2.0000, -0.0000]]), robot_h: tensor([[1.6000], [1.6000], [1.6000], [1.6000]]) ``` -------------------------------- ### NeuPAN Training Loop with PyTorch Source: https://context7.com/hanruihua/neupan/llms.txt This Python code snippet demonstrates the training loop for the NeuPAN planner using PyTorch. It iterates through epochs and steps, computes various loss components including state, speed, and distance loss, performs backpropagation, and updates the optimizer. The loop interacts with a simulated environment, rendering states and resetting for the next episode. It includes convergence criteria based on average loss. ```python num_epochs = 150 for epoch in range(num_epochs): total_loss = 0.0 optimizer.zero_grad() for step in range(400): # Max steps per episode robot_state = env.get_robot_state()[0:3] lidar_scan = env.get_lidar_scan() points = planner.scan_to_point(robot_state, lidar_scan) action, info = planner(robot_state, points) # Compute loss from optimization results states = info['state_tensor'] vel = info['vel_tensor'] distance = info['distance_tensor'] ref_state = info['ref_state_tensor'] ref_speed = info['ref_speed_tensor'] state_loss = torch.nn.MSELoss()(states, ref_state) speed_loss = torch.nn.MSELoss()(vel[0, :], ref_speed) # Distance loss for safety if planner.min_distance <= planner.collision_threshold: distance_loss = 50 - torch.sum(distance) else: distance_loss = torch.tensor(0.0, requires_grad=True) loss = state_loss + speed_loss + 10 * distance_loss total_loss += loss.item() loss.backward() optimizer.step() env.step(action) env.render() if info['arrive'] or info['stop']: break avg_loss = total_loss / (step + 1) print(f'Epoch {epoch}: Loss={avg_loss:.3f}, ') f'p_u={p_u.item():.3f}, eta={eta.item():.3f}, d_max={d_max.item():.3f}') env.reset() planner.reset() if avg_loss < 0.05: print("Converged!") break # Trained parameters are automatically used in planner ``` -------------------------------- ### Converting 3D Lidar to 2D Scan (ROS) Source: https://github.com/hanruihua/neupan/blob/main/README.md This snippet references the ROS package `pointcloud_to_laserscan`, which is used to convert 3D point cloud data from sensors like 3D lidar into a 2D laser scan format that NeuPAN can process. This enables the use of 3D lidar data for obstacle avoidance. ```shell # To use pointcloud_to_laserscan: # 1. Install the package: sudo apt-get install ros--pointcloud-to-laserscan # 2. Run the node: # rosrun pointcloud_to_laserscan pointcloud_to_laserscan input:=/pointcloud_in output:=/scan cloud_projected_angle_range:=3.14159265359 # Note: Replace '/pointcloud_in' and '/scan' with your actual topic names. ``` -------------------------------- ### Neupan Training Log: Epoch 2000 Losses (PyTorch) Source: https://github.com/hanruihua/neupan/blob/main/example/model/acker_robot_default/results.txt Presents the training and validation losses for the Neupan project at Epoch 2000. It includes Mu Loss, Distance Loss, Fa Loss, and Fb Loss, illustrating the model's convergence characteristics at this stage. ```python Epoch 2000/5000 learning rate 2.5e-05 --------------------------------- Losses: Mu Loss: 3.38e-06 | Validate Mu Loss: 5.24e-06 Distance Loss: 4.17e-05 | Validate Distance Loss: 6.76e-05 Fa Loss: 3.20e-05 | Validate Fa Loss: 6.41e-05 Fb Loss: 3.26e-04 | Validate Fb Loss: 3.39e-04 ``` -------------------------------- ### Neupan Training Log: Epoch 1000 Losses (PyTorch) Source: https://github.com/hanruihua/neupan/blob/main/example/model/acker_robot_default/results.txt Presents the training and validation losses for the Neupan project at Epoch 1000. It includes Mu Loss, Distance Loss, Fa Loss, and Fb Loss, illustrating the model's performance after a significant number of training epochs. ```python Epoch 1000/5000 learning rate 5e-05 --------------------------------- Losses: Mu Loss: 8.45e-06 | Validate Mu Loss: 1.17e-05 Distance Loss: 4.05e-04 | Validate Distance Loss: 4.06e-04 Fa Loss: 8.55e-05 | Validate Fa Loss: 1.19e-04 Fb Loss: 1.61e-03 | Validate Fb Loss: 1.29e-03 ``` -------------------------------- ### Generate Control Actions from Robot State and Obstacle Points (Python) Source: https://context7.com/hanruihua/neupan/llms.txt Computes optimal control actions (velocity commands) for robot navigation. It takes the current robot state (position and orientation) and a point cloud of obstacles as input. The function returns the control action and an information dictionary indicating status like collision risk, arrival, or stop. ```python # Get robot state [x, y, theta] and obstacle points robot_state = np.array([[5.0], [5.0], [0.0]]) # Shape: (3, 1) obstacle_points = np.array([ [6.0, 7.0, 8.0, 6.5], # x coordinates [5.0, 5.5, 6.0, 4.5] # y coordinates ]) # Shape: (2, N) where N is number of points # Generate control action action, info = planner.forward(robot_state, obstacle_points) # Or equivalently using callable interface: action, info = planner(robot_state, obstacle_points) # action: numpy array shape (2, 1) # For differential drive: [linear_velocity, angular_velocity] # For Ackermann: [linear_velocity, steering_angle] # Example action: [[0.8], [0.15]] # 0.8 m/s forward, 0.15 rad/s turn # info dictionary contains: # - 'stop': bool - Emergency stop due to collision risk # - 'arrive': bool - Target reached # - 'collision': bool - Collision detected # - 'state_tensor': torch.Tensor - Optimized trajectory states # - 'vel_tensor': torch.Tensor - Optimized velocity sequence # - 'distance_tensor': torch.Tensor - Safety distances # - 'opt_state_list': list - MPC receding horizon trajectory # - 'ref_state_list': list - Reference trajectory points if info['stop']: print(f"Emergency stop! Min distance: {planner.min_distance}") elif info['arrive']: print("Successfully arrived at target") else: # Apply action to robot print(f"Command: {action[0, 0]:.2f} m/s, {action[1, 0]:.2f} rad/s") ``` -------------------------------- ### Generate Control Actions Source: https://context7.com/hanruihua/neupan/llms.txt Computes optimal control actions (velocities) for robot navigation based on the current robot state and a point cloud of obstacles. ```APIDOC ## Generate Control Actions ### Description Computes optimal control actions by processing the current robot state and obstacle point cloud, returning velocity commands for robot navigation. ### Method Python Function Call (`forward` or `__call__`) ### Endpoint N/A (Python Library) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```python # Get robot state [x, y, theta] and obstacle points robot_state = np.array([[5.0], [5.0], [0.0]]) # Shape: (3, 1) obstacle_points = np.array([ [6.0, 7.0, 8.0, 6.5], [5.0, 5.5, 6.0, 4.5] ]) # Shape: (2, N) # Generate control action action, info = planner.forward(robot_state, obstacle_points) # Or equivalently using callable interface: # action, info = planner(robot_state, obstacle_points) # Example action: [[0.8], [0.15]] print(f"Command: {action[0, 0]:.2f} m/s, {action[1, 0]:.2f} rad/s") ``` ### Response #### Success Response (200) - **action** (numpy.ndarray) - Control action commands. For differential drive: [linear_velocity, angular_velocity]. For Ackermann: [linear_velocity, steering_angle]. Shape: (2, 1). - **info** (dict) - Dictionary containing execution information: - **stop** (bool) - True if an emergency stop is triggered due to collision risk. - **arrive** (bool) - True if the target destination has been reached. - **collision** (bool) - True if a collision is detected. - **state_tensor** (torch.Tensor) - Optimized trajectory states. - **vel_tensor** (torch.Tensor) - Optimized velocity sequence. - **distance_tensor** (torch.Tensor) - Calculated safety distances. - **opt_state_list** (list) - List of optimized states for the MPC receding horizon. - **ref_state_list** (list) - List of reference trajectory points. #### Response Example ```json { "action": [[0.8], [0.15]], "info": { "stop": false, "arrive": false, "collision": false, "state_tensor": "", "vel_tensor": "", "distance_tensor": "", "opt_state_list": "", "ref_state_list": "" } } ``` ``` -------------------------------- ### Update Path and Reference Speed in Python Source: https://context7.com/hanruihua/neupan/llms.txt Dynamically updates the navigation waypoints and reference speed of the planner during runtime for adaptive path planning. This allows the robot to adjust its path based on new goals or waypoints, and modify its speed for smoother or more efficient navigation. The planner needs to be initialized before these updates can be fully utilized. ```python # Update from goal position start = np.array([[0], [0], [0]]) # Current position [x, y, theta] goal = np.array([[20], [15], [1.57]]) # Target position planner.update_initial_path_from_goal(start, goal) # Update from multiple waypoints waypoints = [ np.array([[0], [0], [0]]), np.array([[10], [5], [0.5]]), np.array([[20], [10], [1.0]]), np.array([[30], [15], [1.57]]) ] planner.update_initial_path_from_waypoints(waypoints) # Set custom path (list of [x, y, theta, gear] vectors) # gear: 1 for forward, -1 for reverse custom_path = [ np.array([[0], [0], [0], [1]]), np.array([[5], [2], [0.3], [1]]), np.array([[10], [5], [0.6], [1]]) ] planner.set_initial_path(custom_path) # Change reference speed (affects path following behavior) planner.set_reference_speed(3.5) # Set to 3.5 m/s # Initialize path from current state (required before first use) initial_state = np.array([[0], [0], [0]]) planner.set_initial_path_from_state(initial_state) # Access current path information initial_path = planner.initial_path # List of waypoint arrays current_waypoints = planner.waypoints # Original waypoints opt_trajectory = planner.opt_trajectory # MPC optimized trajectory ref_trajectory = planner.ref_trajectory # Reference trajectory ``` -------------------------------- ### Neupan Training Log: Epoch 0 Losses (PyTorch) Source: https://github.com/hanruihua/neupan/blob/main/example/model/acker_robot_default/results.txt Logs the training and validation losses for the Neupan project at Epoch 0. It details the Mu Loss, Distance Loss, Fa Loss, and Fb Loss, providing an initial baseline for model performance. ```python Epoch 0/5000 learning rate 5e-05 --------------------------------- Losses: Mu Loss: 3.10e-02 | Validate Mu Loss: 2.39e-02 Distance Loss: 2.07e+02 | Validate Distance Loss: 1.23e+02 Fa Loss: 3.79e-01 | Validate Fa Loss: 2.47e-01 Fb Loss: 1.60e+02 | Validate Fb Loss: 1.05e+02 ``` -------------------------------- ### Neupan Training Log: Epoch 2500 Losses (PyTorch) Source: https://github.com/hanruihua/neupan/blob/main/example/model/acker_robot_default/results.txt Presents the training and validation losses for the Neupan project at Epoch 2500. It includes Mu Loss, Distance Loss, Fa Loss, and Fb Loss, reflecting the model's state midway through the training process. ```python Epoch 2500/5000 learning rate 2.5e-05 --------------------------------- Losses: Mu Loss: 2.66e-06 | Validate Mu Loss: 3.93e-06 Distance Loss: 1.32e-05 | Validate Distance Loss: 3.28e-05 Fa Loss: 2.20e-05 | Validate Fa Loss: 5.42e-05 Fb Loss: 1.19e-04 | Validate Fb Loss: 2.69e-04 ``` -------------------------------- ### Neupan Robot Kinematic Parameters (PyTorch) Source: https://github.com/hanruihua/neupan/blob/main/example/model/acker_robot_default/results.txt Specifies the kinematic parameters (G and h matrices) for the robot in the Neupan project, represented as PyTorch tensors. These matrices are fundamental for modeling robot dynamics and control. ```python robot_G: tensor([[ 0.0000, -4.6000], [ 1.6000, -0.0000], [ 0.0000, 4.6000], [-1.6000, -0.0000]]) robot_h: tensor([[3.6800], [6.0800], [3.6800], [1.2800]]) ``` -------------------------------- ### Neupan Training Log: Epoch 1750 Losses (PyTorch) Source: https://github.com/hanruihua/neupan/blob/main/example/model/acker_robot_default/results.txt Logs the training and validation losses for the Neupan project at Epoch 1750. This entry details the Mu Loss, Distance Loss, Fa Loss, and Fb Loss, showing the model's performance with the current learning rate. ```python Epoch 1750/5000 learning rate 2.5e-05 --------------------------------- Losses: Mu Loss: 3.62e-06 | Validate Mu Loss: 5.81e-06 Distance Loss: 6.37e-05 | Validate Distance Loss: 1.74e-04 Fa Loss: 3.31e-05 | Validate Fa Loss: 6.76e-05 Fb Loss: 2.70e-04 | Validate Fb Loss: 8.69e-04 ``` -------------------------------- ### Neupan Training Progress: Epoch 200 Losses (PyTorch) Source: https://github.com/hanruihua/neupan/blob/main/example/model/polygon_robot/results.txt Logs the training and validation losses for the Neupan project at Epoch 200. It illustrates the reduction in Mu Loss, Distance Loss, Fa Loss, and Fb Loss, indicating model convergence. ```python Epoch 200/5000 learning rate 5e-05 --------------------------------- Losses: Mu Loss: 1.29e-04 | Validate Mu Loss: 1.24e-04 Distance Loss: 3.08e-03 | Validate Distance Loss: 2.57e-03 Fa Loss: 5.13e-04 | Validate Fa Loss: 4.91e-04 Fb Loss: 1.47e-02 | Validate Fb Loss: 1.30e-02 ``` -------------------------------- ### Adjust Optimization Parameters in Python Source: https://context7.com/hanruihua/neupan/llms.txt Allows fine-tuning of planner behavior by modifying cost function weights and safety parameters during execution. This enables adjustments to state tracking, speed tracking, collision avoidance, and safety distances. It also provides access to current obstacle points and minimum distances, and includes a reset function for new navigation tasks. ```python # Update optimization weights planner.update_adjust_parameters( q_s=2.0, # State tracking weight (higher = closer path following) p_u=1.5, # Speed tracking weight (higher = maintain reference speed) eta=15.0, # Collision avoidance weight (higher = more conservative) d_max=1.5, # Maximum safety distance (m) d_min=0.15 # Minimum safety distance (m) ) # Access current parameters params = planner.adjust_parameters # params is list: [q_s, p_u, eta, d_max, d_min] print(f"Current q_s: {params[0]}, p_u: {params[1]}, eta: {params[2]}") # Example: Make planner more aggressive planner.update_adjust_parameters(eta=5.0, d_min=0.05) # Example: Make planner more conservative planner.update_adjust_parameters(eta=20.0, d_max=2.0, d_min=0.3) # Access obstacle points being considered dune_points = planner.dune_points # Points in DUNE layer (up to dune_max_num) nrmp_points = planner.nrmp_points # Points in NRMP layer (up to nrmp_max_num) min_dist = planner.min_distance # Minimum distance to obstacles # Reset planner state (when starting new navigation task) planner.reset() # Resets: path index, arrival flag, velocity array, stop/arrive flags ``` -------------------------------- ### Neupan Training Progress: Epoch 900 Losses (PyTorch) Source: https://github.com/hanruihua/neupan/blob/main/example/model/polygon_robot/results.txt Logs the training and validation losses for the Neupan project at Epoch 900. It shows the continuing evolution of the loss metrics. ```python Epoch 900/5000 learning rate 5e-05 --------------------------------- Losses: Mu Loss: 4.23e-06 | Validate Mu Loss: 5.36e-06 Distance Loss: 2.03e-04 | Validate Distance Loss: 9.70e-05 Fa Loss: 3.30e-05 | Validate Fa Loss: 5.08e-05 Fb Loss: 5.83e-04 | Validate Fb Loss: 3.44e-04 ``` -------------------------------- ### Neupan Training Progress: Epoch 0 Losses (PyTorch) Source: https://github.com/hanruihua/neupan/blob/main/example/model/polygon_robot/results.txt Logs the training and validation losses for the Neupan project at Epoch 0. It includes Mu Loss, Distance Loss, Fa Loss, and Fb Loss, indicating the model's initial performance before significant training. ```python Epoch 0/5000 learning rate 5e-05 --------------------------------- Losses: Mu Loss: 4.81e-02 | Validate Mu Loss: 4.95e-02 Distance Loss: 1.08e+02 | Validate Distance Loss: 7.88e+01 Fa Loss: 2.85e-01 | Validate Fa Loss: 2.77e-01 Fb Loss: 1.21e+02 | Validate Fb Loss: 1.18e+02 ``` -------------------------------- ### Neupan Training Log: Epoch 3000 Losses with LR Decay (PyTorch) Source: https://github.com/hanruihua/neupan/blob/main/example/model/acker_robot_default/results.txt Records the training and validation losses for the Neupan project at Epoch 3000, following another learning rate decay. It displays the Mu Loss, Distance Loss, Fa Loss, and Fb Loss with the new learning rate of 1.25e-05. ```python current learning rate: 1.25e-05 Epoch 3000/5000 learning rate 1.25e-05 --------------------------------- Losses: Mu Loss: 2.09e-06 | Validate Mu Loss: 3.53e-06 ``` -------------------------------- ### Neupan Training Log: Epoch 750 Losses (PyTorch) Source: https://github.com/hanruihua/neupan/blob/main/example/model/acker_robot_default/results.txt Logs the training and validation losses for the Neupan project at Epoch 750. This log entry details the Mu Loss, Distance Loss, Fa Loss, and Fb Loss, indicating further progress in model convergence. ```python Epoch 750/5000 learning rate 5e-05 --------------------------------- Losses: Mu Loss: 1.85e-05 | Validate Mu Loss: 2.35e-05 Distance Loss: 3.25e-04 | Validate Distance Loss: 1.07e-03 Fa Loss: 2.30e-04 | Validate Fa Loss: 2.44e-04 Fb Loss: 2.60e-03 | Validate Fb Loss: 2.77e-03 ``` -------------------------------- ### Neupan Training Loss Metrics (Epoch 1000) Source: https://github.com/hanruihua/neupan/blob/main/example/model/diff_robot_default/results.txt Reports the training and validation loss metrics for the Neupan project at Epoch 1000. Losses are nearing very small values, suggesting convergence. ```text Epoch 1000/5000 learning rate 5e-05 --------------------------------- Losses: Mu Loss: 3.51e-06 | Validate Mu Loss: 1.34e-05 Distance Loss: 2.32e-04 | Validate Distance Loss: 2.07e-04 Fa Loss: 2.33e-05 | Validate Fa Loss: 8.67e-05 Fb Loss: 8.85e-04 | Validate Fb Loss: 8.38e-04 ``` -------------------------------- ### Neupan Training Log: Epoch 2250 Losses (PyTorch) Source: https://github.com/hanruihua/neupan/blob/main/example/model/acker_robot_default/results.txt Logs the training and validation losses for the Neupan project at Epoch 2250. This log entry details the Mu Loss, Distance Loss, Fa Loss, and Fb Loss, providing insights into the model's performance. ```python Epoch 2250/5000 learning rate 2.5e-05 --------------------------------- Losses: Mu Loss: 3.04e-06 | Validate Mu Loss: 5.49e-06 Distance Loss: 1.51e-04 | Validate Distance Loss: 1.38e-04 Fa Loss: 2.78e-05 | Validate Fa Loss: 5.96e-05 Fb Loss: 5.07e-04 | Validate Fb Loss: 8.55e-04 ``` -------------------------------- ### Neupan Training Progress: Epoch 400 Losses (PyTorch) Source: https://github.com/hanruihua/neupan/blob/main/example/model/polygon_robot/results.txt Logs the training and validation losses for the Neupan project at Epoch 400. It continues to show a downward trend in losses, indicating effective learning. ```python Epoch 400/5000 learning rate 5e-05 --------------------------------- Losses: Mu Loss: 1.40e-05 | Validate Mu Loss: 1.39e-05 Distance Loss: 2.78e-04 | Validate Distance Loss: 2.14e-04 Fa Loss: 9.10e-05 | Validate Fa Loss: 9.39e-05 Fb Loss: 1.08e-03 | Validate Fb Loss: 9.35e-04 ``` -------------------------------- ### Neupan Training Log: Epoch 1500 Losses with LR Decay (PyTorch) Source: https://github.com/hanruihua/neupan/blob/main/example/model/acker_robot_default/results.txt Records the training and validation losses for the Neupan project at Epoch 1500, after a learning rate decay. It presents the Mu Loss, Distance Loss, Fa Loss, and Fb Loss with the updated learning rate of 2.5e-05. ```python current learning rate: 2.5e-05 Epoch 1500/5000 learning rate 2.5e-05 --------------------------------- Losses: Mu Loss: 4.36e-06 | Validate Mu Loss: 6.40e-06 Distance Loss: 7.56e-05 | Validate Distance Loss: 2.08e-05 Fa Loss: 4.28e-05 | Validate Fa Loss: 7.10e-05 Fb Loss: 4.04e-04 | Validate Fb Loss: 3.24e-04 ``` -------------------------------- ### Neupan Training Log: Epoch 500 Losses (PyTorch) Source: https://github.com/hanruihua/neupan/blob/main/example/model/acker_robot_default/results.txt Logs the training and validation losses for the Neupan project at Epoch 500. It provides a snapshot of the model's performance, including Mu Loss, Distance Loss, Fa Loss, and Fb Loss, at this stage of training. ```python Epoch 500/5000 learning rate 5e-05 --------------------------------- Losses: Mu Loss: 7.26e-03 | Validate Mu Loss: 7.33e-03 Distance Loss: 4.46e+01 | Validate Distance Loss: 4.30e+01 Fa Loss: 1.57e-01 | Validate Fa Loss: 1.55e-01 Fb Loss: 6.42e+01 | Validate Fb Loss: 6.58e+01 ``` -------------------------------- ### Neupan Training Progress: Epoch 700 Losses (PyTorch) Source: https://github.com/hanruihua/neupan/blob/main/example/model/polygon_robot/results.txt Logs the training and validation losses for the Neupan project at Epoch 700. It provides insight into the model's performance after extended training. ```python Epoch 700/5000 learning rate 5e-05 --------------------------------- Losses: Mu Loss: 5.41e-06 | Validate Mu Loss: 6.22e-06 Distance Loss: 2.33e-04 | Validate Distance Loss: 5.52e-04 Fa Loss: 4.05e-05 | Validate Fa Loss: 5.64e-05 Fb Loss: 7.17e-04 | Validate Fb Loss: 1.74e-03 ``` -------------------------------- ### Neupan Training Progress: Epoch 500 Losses (PyTorch) Source: https://github.com/hanruihua/neupan/blob/main/example/model/polygon_robot/results.txt Logs the training and validation losses for the Neupan project at Epoch 500. The losses are nearing very small values, suggesting the model is approaching convergence. ```python Epoch 500/5000 learning rate 5e-05 --------------------------------- Losses: Mu Loss: 8.64e-06 | Validate Mu Loss: 8.90e-06 Distance Loss: 2.38e-04 | Validate Distance Loss: 2.06e-04 Fa Loss: 5.99e-05 | Validate Fa Loss: 6.96e-05 Fb Loss: 8.57e-04 | Validate Fb Loss: 7.98e-04 ``` -------------------------------- ### Neupan Training Progress: Epoch 100 Losses (PyTorch) Source: https://github.com/hanruihua/neupan/blob/main/example/model/polygon_robot/results.txt Logs the training and validation losses for the Neupan project at Epoch 100. This snapshot shows the changes in Mu Loss, Distance Loss, Fa Loss, and Fb Loss after the initial training phase. ```python Epoch 100/5000 learning rate 5e-05 --------------------------------- Losses: Mu Loss: 4.76e-02 | Validate Mu Loss: 5.06e-02 Distance Loss: 7.42e+01 | Validate Distance Loss: 7.09e+01 Fa Loss: 2.79e-01 | Validate Fa Loss: 2.86e-01 Fb Loss: 1.19e+02 | Validate Fb Loss: 1.18e+02 ``` -------------------------------- ### Robot Kinematics Modification in NeuPAN (Python) Source: https://github.com/hanruihua/neupan/blob/main/README.md This snippet demonstrates how to modify kinematic constraints within the NRMP layer of the NeuPAN algorithm to support different robot kinematics beyond differential drive and Ackermann robots. It requires modifying the `robot.py` file. ```python from neupan.robot.robot import Robot # Example of modifying kinematic constraints # This is a conceptual representation and would involve changes within the neupan package # Assume 'robot_config' contains the configuration for a new robot kinematic type # robot_config = {...} # new_robot = Robot(robot_config) # new_robot.update_kinematic_constraints() # The actual modification would involve editing the file: # https://github.com/hanruihua/NeuPAN/blob/main/neupan/robot/robot.py#L188 ``` -------------------------------- ### Neupan Training Progress: Epoch 600 Losses (PyTorch) Source: https://github.com/hanruihua/neupan/blob/main/example/model/polygon_robot/results.txt Logs the training and validation losses for the Neupan project at Epoch 600. This update shows continued refinement of the model's parameters. ```python Epoch 600/5000 learning rate 5e-05 --------------------------------- Losses: Mu Loss: 6.68e-06 | Validate Mu Loss: 7.08e-06 Distance Loss: 2.38e-04 | Validate Distance Loss: 1.11e-04 Fa Loss: 4.86e-05 | Validate Fa Loss: 5.84e-05 Fb Loss: 7.26e-04 | Validate Fb Loss: 4.18e-04 ```