From e8099c11e00051ccb754bd2d697b73305fe1fbf7 Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Fri, 27 Feb 2026 11:48:43 +0100 Subject: [PATCH] =?UTF-8?q?EgtMachKernel=20:=20-=20modifiche=20alla=20simu?= =?UTF-8?q?lazione=20per=20eseguire=20la=20verifica=20collisione=20corrett?= =?UTF-8?q?amente=20anche=20alla=20massima=20velocit=C3=A0.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SimulatorMP.cpp | 6 ++++-- SimulatorSP.cpp | 12 +++++++----- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/SimulatorMP.cpp b/SimulatorMP.cpp index 2bcb705..fcacfde 100644 --- a/SimulatorMP.cpp +++ b/SimulatorMP.cpp @@ -48,9 +48,10 @@ using namespace std ; //---------------------------------------------------------------------------- static const double MIN_STEP = 1.0 ; -static const double MAX_STEP = 500.0 ; static const double MID_STEP = 50.0 ; +static const double MAX_STEP = 500.0 ; static const double COLL_STEP = 10. ; +static const double MAX_COLL_STEP = 100. ; static const double SQ_COEFF_ROT_MOVE = 100. ; static const double COEFF_LIM = 0.999 ; static const double SAFEDIST_STD = 5.0 ; @@ -2574,6 +2575,7 @@ SimulatorMP::ExecCmdData( int& nStatus) static const int STEP_RAPID = -2 ; static const int STEP_RAPROT = -3 ; static const int STEP_COLLROT = -4 ; + double dMaxStep = ( NeedCollisionCheck() ? MAX_COLL_STEP : MAX_STEP) ; int nStep = 1 ; for ( int i = 0 ; i < nAxCount ; ++ i) { double dMove = abs( CmdCurr.vAxNaEpSt[i].dEndPos - vPrev[i]) ; @@ -2588,7 +2590,7 @@ SimulatorMP::ExecCmdData( int& nStatus) else // STEP_COLLROT dStep = min( 0.4 * m_dStep, 10.) ; } - dStep = max( dStep, 1.) ; + dStep = Clamp( dStep, MIN_STEP, dMaxStep) ; int nAxStep = int( dMove / dStep) + 1 ; nStep = max( nStep, nAxStep) ; } diff --git a/SimulatorSP.cpp b/SimulatorSP.cpp index f3572fc..28380e8 100644 --- a/SimulatorSP.cpp +++ b/SimulatorSP.cpp @@ -51,9 +51,10 @@ using namespace std ; //---------------------------------------------------------------------------- static const double MIN_STEP = 1.0 ; -static const double MAX_STEP = 500.0 ; static const double MID_STEP = 50.0 ; +static const double MAX_STEP = 500.0 ; static const double COLL_STEP = 10. ; +static const double MAX_COLL_STEP = 100. ; static const double SQ_COEFF_ROT_MOVE = 100. ; static const double COEFF_LIM = 0.999 ; static const double SAFEDIST_STD = 5.0 ; @@ -2561,6 +2562,7 @@ SimulatorSP::MoveAxes( int nMoveType, const SAMVECTOR& vAxNaEpSt) static const int STEP_RAPID = -2 ; static const int STEP_RAPROT = -3 ; static const int STEP_COLLROT = -4 ; + double dMaxStep = ( NeedCollisionCheck() ? MAX_COLL_STEP : MAX_STEP) ; bool bViewAllFrames = true ; int nStep = 1 ; for ( int i = 0 ; i < nAxCount ; ++ i) { @@ -2576,11 +2578,11 @@ SimulatorSP::MoveAxes( int nMoveType, const SAMVECTOR& vAxNaEpSt) bViewAllFrames = ( bIsRobot ? true : false) ; } else { // STEP_COLLROT - dStep = min( 0.4 * m_dStep, 10.) ; + dStep = min( 0.4 * m_dStep, COLL_STEP) ; bViewAllFrames = ( bIsRobot ? true : false) ; } } - dStep = max( dStep, 1.) ; + dStep = Clamp( dStep, MIN_STEP, dMaxStep) ; int nAxStep = int( dMove / dStep) + 1 ; nStep = max( nStep, nAxStep) ; } @@ -2613,7 +2615,7 @@ SimulatorSP::MoveAxes( int nMoveType, const SAMVECTOR& vAxNaEpSt) } } // Aggiorno visualizzazione - if ( bViewAllFrames || ( i % 4) == 0 || i == nStep) + if ( bViewAllFrames || ( i % 8) == 0 || i == nStep) ExeDraw() ; // Verifico collisioni int nCdInd, nObjInd ; @@ -2649,7 +2651,7 @@ SimulatorSP::MoveAxes( int nMoveType, const SAMVECTOR& vAxNaEpSt) // Gestione aggiornamenti... if ( ExeGetEnableUI()) { // Aggiornamento interfaccia - ExeProcessEvents( 0, 4) ; + ExeProcessEvents( 0, 0) ; while ( m_nUiStatus == MCH_UISIM_PAUSE) { ExeProcessEvents( 0, 4) ; }