It works on Windows and macOS, but the initial speed cannot be set on the
Ubuntu image pulled by Singularity.
my code is:
import pychrono.core as chrono
import pychrono.vehicle as veh
# Basic configuration
veh.SetDataPath(chrono.GetChronoDataPath() + 'vehicle/')
# Use SMC contact method
contact_method = chrono.ChContactMethod_SMC
# Simplified test function
def test_vehicle_speed(init_speed):
initLoc = chrono.ChVectorD(0, 0, 0.2) # Initial position
quaternion = chrono.ChQuaternionD(1, 0, 0, 0) # No slope, horizontal
direction
# Create vehicle instance
car = veh.Sedan()
car.SetContactMethod(contact_method) # Set contact method
car.SetChassisFixed(False) # Ensure the vehicle can move
car.SetInitPosition(chrono.ChCoordsysD(initLoc, quaternion)) # Set
initial position and orientation
car.SetTireType(veh.TireModelType_TMEASY) # Use TMEASY tire model
car.SetTireStepSize(1e-3) # Set tire simulation step size
car.SetInitFwdVel(init_speed) # Set initial speed
# Initialize vehicle
car.Initialize()
# Output check
print(f"Set initial speed: {init_speed} m/s")
actual_speed = car.GetVehicle().GetSpeed()
print(f"Actual speed after initialization: {actual_speed} m/s")
# Run simplified test
test_vehicle_speed(1.0)
output is:
Set initial speed: 1.0 m/s
Actual speed after initialization: 0.0 m/s
This is how I build the ubuntu image (if necessary):
Bootstrap: docker
From: ubuntu:latest
%post
# Update package manager and install dependencies
apt-get update && apt-get install -y wget bzip2
export LC_ALL=C.UTF-8
export LANG=C.UTF-8
# Download and install Anaconda3
wget
https://repo.anaconda.com/archive/Anaconda3-2024.06-1-Linux-x86_64.sh -O
/tmp/anaconda.sh
bash /tmp/anaconda.sh -b -p /opt/anaconda
rm /tmp/anaconda.sh
# Add Anaconda to environment variables
echo 'export PATH=/opt/anaconda/bin:$PATH' >> /etc/profile
echo 'export PATH=/opt/anaconda/bin:$PATH' >> ~/.bashrc
# Initialize conda
/opt/anaconda/bin/conda init bash
# Create Conda environment and install necessary packages
/opt/anaconda/bin/conda config --add channels conda-forge
/opt/anaconda/bin/conda create -n chrono python=3.9 -y
/opt/anaconda/bin/conda install -n chrono -y mkl=2020 numpy=1.24.0
irrlicht=1.8.5 pythonocc-core=7.4.1 gnuplot
/opt/anaconda/bin/conda install -n chrono -y -c
nvidia/label/cuda-11.7.0 cuda-toolkit
/opt/anaconda/bin/conda install -n chrono -y glfw
/opt/anaconda/bin/conda install -n chrono -y
https://anaconda.org/projectchrono/pychrono/8.0.0/download/linux-64/pychrono-8.0.0-py39_4646.tar.bz2
%environment
# Set environment variables
export PATH=/opt/anaconda/bin:$PATH
%runscript
# Default behavior when running the script: activate environment and
start shell
/opt/anaconda/bin/conda activate chrono
exec /bin/bash
--
You received this message because you are subscribed to the Google Groups
"ProjectChrono" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/projectchrono/ec352d9c-7e17-49fa-8cdb-b2c7fd90e689n%40googlegroups.com.