Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations pierreick on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

New integrated AI/Python browser based app - Dystr

GregLocock

Automotive
Apr 10, 2001
23,653

So this basically integrates AI with a Python code generator. The work stream is much like the way I use ChatGPT to write Matlab code, but neater. It is just as stupid as ChatGPT, it writes neat code that initially gives the wrong answer. After a couple of kicks in the solar plexus it spat out the right answer, although we disagree on what the sign of a positive slope is. The values at 0 and (-)39.8 degrees check out.

Code:
Plotting the Required Acceleration to Lift the Front Wheel of a Vehicle

This code calculates and visualizes the relationship between the slope angle of a surface and the acceleration needed for a vehicle (or a similar object) to lift its front wheel off the ground.

Overview of Physics and Equations

The calculations are based on the physics of static equilibrium and dynamics, taking into account the center of gravity (CG) location and gravitational acceleration.

Constants
g = 9.81  # Acceleration due to gravity (m/s^2)
cg_ahead_rear_wheel = 0.5  # Horizontal distance of the CG ahead of the rear wheel (m)
cg_above_level_ground = 0.6  # Vertical distance of the CG above the ground (m)

g is the gravitational acceleration constant.

cg_ahead_rear_wheel and cg_above_level_ground describe the position of the center of gravity relative to the vehicle.


Here's what it wrote (as corrected)

import math
import matplotlib.pyplot as plt
# Constants
g = 9.81  # Acceleration due to gravity (m/s^2)
cg_ahead_rear_wheel = 0.5  # Distance of CG ahead of rear wheel contact patch (m)
cg_above_level_ground = 0.6  # Height of CG above ground level (m)
# Define a function to compute the required acceleration
def required_acceleration(theta_deg):
    theta_rad = math.radians(theta_deg)  # Convert angle to radians
    # Check if CG is directly above the rear contact patch
    if abs(theta_deg - 39.8) < 1e-3:  # Floating-point comparison tolerance
        return 0  # Required acceleration is zero when CG aligns with rear wheel
    # Compute the numerator and denominator of the acceleration equation
    numerator = g * (cg_ahead_rear_wheel * math.cos(theta_rad) + cg_above_level_ground * math.sin(theta_rad))
    denominator = cg_above_level_ground * math.cos(theta_rad) - cg_ahead_rear_wheel * math.sin(theta_rad)
    # Prevent division by zero by checking the denominator
    if abs(denominator) < 1e-3:
        return float('inf') * (1 if numerator >= 0 else -1)  # Return infinity appropriately
    return numerator / denominator
# Generate data for -50 to 50 degrees
angles = list(range(-50, 51))
accelerations = [required_acceleration(angle) for angle in angles]
# Plot the graph
plt.figure(figsize=(10, 6))
plt.plot(angles, accelerations, label='Required Acceleration', color='blue')
plt.xlabel('Slope Angle (Degrees)')
plt.ylabel('Required Acceleration (m/s²)')
plt.ylim(0, 10)  # Limit the Y-axis range
plt.xlim(-50, 10)  # Limit the X-axis range
plt.title('Required Acceleration to Lift the Front Wheel vs. Slope Angle')
plt.legend()
plt.grid(True)
plt.show()

1739847468201.png
 
Last edited:
Replies continue below

Recommended for you

Where's the spring constant of the rear wheel's suspension?
This can apply a significant change in the car body's inclination and elevation.

Clearly, Dystr hasn't been ported to the Waymo cars, otherwise it would know about this. ;)
 

Part and Inventory Search

Sponsor