## 3 Materials and Methods
### Software  
The software system for the haptic feedback platform is designed to provide seamless integration with virtual reality environments, allowing wheelchair users to interact naturally and receive realistic haptic feedback based on their movements and the virtual terrain. The software components are responsible for communication, control, and feedback generation, ensuring a high level of immersion and user experience. The software architecture comprises several key modules, which are summarized in Figure 4. Each module plays a crucial role in the overall functionality of the system. The primary control software is responsible for the real-time operation of the haptic feedback system. It interfaces with both the hardware components and the virtual reality simulation software, ensuring synchronized operation. 1. Initialization: upon launch, the software initializes the servo actuators and sets them to a safe state with high torque and zero velocity, allowing users to enter and exit the platform safely. 2. Main Loop: the main loop of the software continuously reads input data from the encoders and processes these data to determine the wheelchair's position and movement. The main loop steps are as follows: 1. Update information position from motors. 2. Detect if the user is applying any torque to the cylinders (to the motors). 3. Calculate the virtual wheelchair displacement and orientation depending on the velocity detected in step b. 4. Send data (increments and orientation) to the virtual system to update the physics and, consequently, the visual. 5. Read actual pitch, roll, collisions, coefficient of friction, etc., from physics. 6. Calculate the torque needed to simulate the tilt as \[\tau=r*F\] (1) where \[F=m*g*\mu*\cos\alpha.\] (2) \[\tau\] is the resultant torque needed, \[r\] is the radius of the actuated cylinder, \[m\] is the mass (taking into account the user and the wheelchair mass), \[g\] is gravity, \[\mu\] the coefficient of friction, and \[\alpha\] is the data read in step 5. 6. Apply the torque to motors (force feedback). The system uses XML configuration files to manage various parameters, ensuring flexibility and ease of customization. The primary configuration files are as follows:  
1. Configuration.XML: This file contains information about the wheelchair and user settings. Key parameters include: 1. Cylinder radius: specifies the radius of the driving cylinders. 2. Wheel separation: defines the distance between the wheelchair's driving wheels. 3. Wheelchair type: indicates whether the wheelchair is electric or manual. 4. Gravity: sets the gravity constant for simulation. 5. Wheel radius: specifies the radius of the wheelchair's driving wheels. 6. Default ground friction coefficient factor: defines the friction between the wheelchair wheels and the virtual terrain in those areas where the physical model does not have this information. 5. User mass: specifies the combined mass of the user and the wheelchair. 6. Safety parameters: includes maximum motor speed, collision mode, and force application settings. 2. WheelChair VRPN.XML: this file manages the VRPN (Virtual Reality Peripheral Network) [21] settings for communication with the simulation environment: 1. Client device: specifies the type of client device. 2. Client IP: defines the IP address for communication. 3. Client port: specifies the port number for communication. Communication between the control software and the virtual environment is facilitated through a TCP/IP by the SystemBus gateway. This ensures that data are exchanged efficiently. 1. TCP/IP settings: the gateway uses a predefined IP address and port for communication. 2. Data exchange: the software acts as both a server and a client. It sends the wheelchair's position and receives terrain information and collision data from the simulation environment. The feedback processing module is critical for generating realistic haptic feedback based on the virtual environment's conditions. 1.