Windows 10 to Ubuntu 18.01 Simulation Failure

Report crashes, strange behaviour, or apparent bugs
Post Reply
milesm
Posts: 2
Joined: 27 May 2020, 21:52

Windows 10 to Ubuntu 18.01 Simulation Failure

Post by milesm »

Hi,

First, I apologize if this post is in the wrong section of the forum. I am unsure if the issue is a bug in the software distribution or my code (and this is my first forum post).

A bit of backstory... I original built a scene using the current distribution of CoppeliaSim for Windows 10 (4.0.0 Edu). After completing the scene as intended I decided it would be best to connect to Qt via the bluezero interface to further the capabilities of the simulation, and given my prior experience I thought it best to continue working using Ubuntu 18.01. After installing CoppeliaSim (4.0.0 Edu) to Ubuntu 18.01 I attempt to run the exact scene (that runs as intended in Windows 10); however, on simulation start all dynamic content disappears from the scene.

After some searching, I managed to locate a snippet of code in a non-threaded child script that may be causing the issue. In the code below, I use sim.setJointTargetVelocity within sysCall_actuation as a custom way to implement vehicle acceleration during simulation. If I remove the four calls to sim.setJointTargetVelocity the dynamic content performs correctly within Ubuntu. However, with it added the dynamic content disappears. Given that no errors seem to be shown I am at a bit of a loss as to how to fix this issue.

Code: Select all

function sysCall_actuation()

    -- speed change--
    current_time = sim.getSimulationTime()
    
    if (((current_time-original_time)>.1) and (mps_desired < new_speed)) then
        mps_desired = mps_desired + (speed_change / 100)
        original_time = current_time
    end
    
    -- Check the inclination of the eTrailer (this is not an angle, but for small inclinations it is ok)    
    m=sim.getObjectMatrix(chassis,-1)
    inclination=m[9]
    
    -- Retrieve the closest point to the "pathFollower" object on the path to follow:
    pf=sim.getObjectPosition(pathFollower,-1)
    m3=sim.getObjectMatrix(path,-1)
    ppf=sim.multiplyVector(m3,pf) -- ppf is the position of "pathFollower" relative to the path object reference frame
    l=sim.getClosestPositionOnPath(path,ppf)
    pp=sim.getPositionOnPath(path,l) -- pp is the position closest to ppf, that is on the path
    sim.setObjectPosition(pathFollowerTarget,-1,pp) -- set the "pathFollowerTarget" object to the pp position
    v=sim.getObjectPosition(pathFollowerTarget,pathFollower) -- v is the position of "pathFollowerTarget" relative to the "pathFollower" object reference frame
    
    -- Set the target position of the front wheel
    sim.setJointTargetPosition(turntable_rev,v[2])
    
    --calculation for wheel differential ratios
    alpha = sim.getJointPosition(turntable_rev)
    R = wheel_width/math.tan(alpha)
    ratio_inner = (R - (axle_width/2)) / R
    ratio_outer = (R + (axle_width/2)) / R
    mps_inner = mps_desired*ratio_inner
    mps_outer = mps_desired*ratio_outer
    
    --mps_inner = mps_desired
    --mps_outer = mps_desired
    
    -- calculation for etrailer wheel speed
    local etrailer_wheel_circumf = 0.4064*math.pi
    local dps_inner = (mps_inner/etrailer_wheel_circumf)*360
    local dps_outer = (mps_outer/etrailer_wheel_circumf)*360
    sim.setJointTargetVelocity(rear_motor_left,dps_inner*math.pi/180)
    sim.setJointTargetVelocity(rear_motor_right,dps_outer*math.pi/180)
    sim.setJointTargetVelocity(front_wheel_rev_left,dps_inner*math.pi/180)
    sim.setJointTargetVelocity(front_wheel_rev_right,dps_outer*math.pi/180)
    
end
Seeing as the scene performs as intended in Windows I am wondering if there is a bug within the Ubuntu distribution of CoppeliaSim or if I may be missing something in my Ubuntu configuration? Also, would there be a better way to implement vehicle acceleration that may avoid this issue altogether?

Please see the link below for access to my .ttt file (if needed):
https://drive.google.com/file/d/1G6N8-T ... sp=sharing

Also, you can view videos of a failed sim in Ubuntu as well as a successful sim in Windows at the links below:
Ubuntu- https://drive.google.com/file/d/1i9Lr9r ... sp=sharing
WIndows- https://drive.google.com/file/d/1UfEnvY ... sp=sharing

Thanks in advance!

coppelia
Site Admin
Posts: 8596
Joined: 14 Dec 2012, 00:25

Re: Windows 10 to Ubuntu 18.01 Simulation Failure

Post by coppelia »

Hello,

can you tell me if you are using the exact same physics engine in both cases (I guess from your message, yes)?
I noticed that your vehicle is not stable, also on Windows (in your simulation video, you can notice that some joints are slightly coming apart. Also, running with other engines makes things quite worse, e.g. with ODE the vehicle also simply disappears).
I would first try to stabilize things a bit (e.g. by carefully trying to follow the dynamic design considerations, mainly 1, 2, 3, 7 and 8) and see if that makes a difference.
Engines often perform slightly in a different way also, depending on the platform. But at this stage my best guess is that you were lucky to obtain a quite stable vehicle in a first place.
But I like the vehicle and would be delighted to include it if stabilized, in our sample model library!

Cheers

milesm
Posts: 2
Joined: 27 May 2020, 21:52

Re: Windows 10 to Ubuntu 18.01 Simulation Failure

Post by milesm »

Hi,

Thanks for the response!

After your comment I did some closer inspection of the model and found a few minor issues that were causing instability in the scene. Additionally, I added conditions to reduce the amount of calls to sim.setJointTargetVelocity (I.E. to reduce the strain on the physics engine slightly). I am still in the process of fixing the scene, but have already seen some significant stabilization. After I finish stabilizing the scene further I will attempt to run within Ubuntu again, and let you know the result.

In the meantime, I would very gladly help to add the scene to the sample model library! I would like to clean up the scene a bit, and make it more generic before adding it to the library. Additionally, if you would like I feel that I could write a very useful tutorial (using my scene) along the lines of "Building Vehicles in CoppeliaSim" that I feel is somewhat lacking from the current manual. I have pieced together bits of code and model structure from other models in the library to build the scene, along with adding some structure of my own, and feel that the basics of these ideas could be streamlined into a very useful tutorial for users in the future. Feel free to private message me if you are interested!

coppelia
Site Admin
Posts: 8596
Joined: 14 Dec 2012, 00:25

Re: Windows 10 to Ubuntu 18.01 Simulation Failure

Post by coppelia »

That would be really nice, we'll shortly contact you.

Cheers

Post Reply