From bc7d1936dc5305cbd3ed6bd9f56c40c461cd6817 Mon Sep 17 00:00:00 2001 From: DarioS Date: Mon, 24 May 2021 20:05:40 +0200 Subject: [PATCH 1/2] EgtMachKernel 2.3e3 : - modificata funzione gestione solidi semplici di collisione in simulazione (aggiunto parametro spiazzamento da riferimento) - aggiunta funzione Lua EmtAddCollisionObjEx che estende la quasi omonima con lo spiazzamento indicato sopra - a queste funzioni aggiunta la gestione dei tronchi di cono. --- EgtMachKernel.rc | Bin 11774 -> 11774 bytes MachMgr.h | 4 ++-- MachMgrSimulation.cpp | 4 ++-- Machine.h | 1 + MachineLua.cpp | 34 +++++++++++++++++++++++++++++++++- Simulator.cpp | 23 +++++++++++++++++++---- Simulator.h | 9 +++++---- 7 files changed, 62 insertions(+), 13 deletions(-) diff --git a/EgtMachKernel.rc b/EgtMachKernel.rc index 9114e5944fafff0866963f54817510113608a2c8..951c83213b0efe890b063007f406041c6bdfbe95 100644 GIT binary patch delta 97 zcmewt{V#gMFE&Qw&A-`fnHh~IKa|wnoW?bQ1uSxrY4Qod0+^@}R1`^_2jk{d(jGv4 NK<#LXK~l;gTmUD-Bai?9 delta 97 zcmewt{V#gMFE&P_&A-`fnHh~HKa|wnoW?bQ1uSxrY4Qod0+^@}R1`^_2jk{d(jGv4 NK<#LXK~l;gTmU8!BZvS1 diff --git a/MachMgr.h b/MachMgr.h index 9b117da..5776e73 100644 --- a/MachMgr.h +++ b/MachMgr.h @@ -1,7 +1,7 @@ //---------------------------------------------------------------------------- // EgalTech 2015-2021 //---------------------------------------------------------------------------- -// File : MachMgr.h Data : 17.03.21 Versione : 2.3c1 +// File : MachMgr.h Data : 24.05.21 Versione : 2.3e3 // Contenuto : Dichiarazione della classe MachMgr. // // @@ -441,7 +441,7 @@ class MachMgr : public IMachMgr bool GetOperationNewName( std::string& sName) const ; const ToolData* GetMachiningToolData( void) const ; // Simulation - bool SimAddCollisionObj( int nInd, int nFrameId, int nType, double dPar1, double dPar2, double dPar3) ; + bool SimAddCollisionObj( int nInd, int nFrameId, int nType, const Vector3d& vtMove, double dPar1, double dPar2, double dPar3) ; bool SimExecCollisionCheck( int& nCdInd, int& nObjInd, int nMoveType) ; bool SimOnCollision( int nCdInd, int nObjInd, int& nErr) ; // Machine diff --git a/MachMgrSimulation.cpp b/MachMgrSimulation.cpp index 00b0191..7a5e6f0 100644 --- a/MachMgrSimulation.cpp +++ b/MachMgrSimulation.cpp @@ -150,13 +150,13 @@ MachMgr::SimExit( void) //---------------------------------------------------------------------------- bool -MachMgr::SimAddCollisionObj( int nInd, int nFrameId, int nType, double dPar1, double dPar2, double dPar3) +MachMgr::SimAddCollisionObj( int nInd, int nFrameId, int nType, const Vector3d& vtMove, double dPar1, double dPar2, double dPar3) { // verifico simulatore if ( m_pSimul == nullptr) return false ; // aggiungo un oggetto da verificare per la collisione con il grezzo - return m_pSimul->AddCollisionObj( nInd, nFrameId, nType, dPar1, dPar2, dPar3) ; + return m_pSimul->AddCollisionObj( nInd, nFrameId, nType, vtMove, dPar1, dPar2, dPar3) ; } //---------------------------------------------------------------------------- diff --git a/Machine.h b/Machine.h index 0e7685c..ec80b37 100644 --- a/Machine.h +++ b/Machine.h @@ -332,6 +332,7 @@ class Machine static int LuaEmtSetLastError( lua_State* L) ; static int LuaEmtSetWarning( lua_State* L) ; static int LuaEmtAddCollisionObj( lua_State* L) ; + static int LuaEmtAddCollisionObjEx( lua_State* L) ; static int LuaEmtExecCollisionCheck( lua_State* L) ; static int LuaEmtOnCollision( lua_State* L) ; } ; diff --git a/MachineLua.cpp b/MachineLua.cpp index 2b7ea55..2c902ac 100644 --- a/MachineLua.cpp +++ b/MachineLua.cpp @@ -122,6 +122,8 @@ Machine::LuaInit( const string& sMachineName) m_LuaMgr.RegisterFunction( "EmtSetWarning", Machine::LuaEmtSetWarning) ; // registro la funzione per aggiungere un oggetto da verificare per la collisione in simulazione m_LuaMgr.RegisterFunction( "EmtAddCollisionObj", Machine::LuaEmtAddCollisionObj) ; + // registro la funzione estesa per aggiungere un oggetto da verificare per la collisione in simulazione + m_LuaMgr.RegisterFunction( "EmtAddCollisionObjEx", Machine::LuaEmtAddCollisionObjEx) ; // registro la funzione di esecuzione della verifica di collisione in simulazione m_LuaMgr.RegisterFunction( "EmtExecCollisionCheck", Machine::LuaEmtExecCollisionCheck) ; // registro la funzione di gestione della collisione in simulazione @@ -1202,7 +1204,37 @@ Machine::LuaEmtAddCollisionObj( lua_State* L) if ( m_pMchLua == nullptr) return luaL_error( L, " Unknown Machine") ; // assegno i dati - bool bOk = ( m_pMchLua->m_pMchMgr != nullptr && m_pMchLua->m_pMchMgr->SimAddCollisionObj( nInd, nFrameId, nType, dPar1, dPar2, dPar3)) ; + bool bOk = ( m_pMchLua->m_pMchMgr != nullptr && m_pMchLua->m_pMchMgr->SimAddCollisionObj( nInd, nFrameId, nType, Vector3d(), dPar1, dPar2, dPar3)) ; + // assegno risultato + LuaSetParam( L, bOk) ; + return 1 ; +} + +//---------------------------------------------------------------------------- +int +Machine::LuaEmtAddCollisionObjEx( lua_State* L) +{ + // 7 parametri : nInd, nFrameId, nType, vtMove, dPar1, dPar2, dPar3 + int nInd ; + LuaCheckParam( L, 1, nInd) + int nFrameId ; + LuaCheckParam( L, 2, nFrameId) + int nType ; + LuaCheckParam( L, 3, nType) + Vector3d vtMove ; + LuaCheckParam( L, 4, vtMove) + double dPar1 ; + LuaCheckParam( L, 5, dPar1) + double dPar2 ; + LuaCheckParam( L, 6, dPar2) + double dPar3 ; + LuaCheckParam( L, 7, dPar3) + LuaClearStack( L) ; + // verifico ci sia una macchina attiva + if ( m_pMchLua == nullptr) + return luaL_error( L, " Unknown Machine") ; + // assegno i dati + bool bOk = ( m_pMchLua->m_pMchMgr != nullptr && m_pMchLua->m_pMchMgr->SimAddCollisionObj( nInd, nFrameId, nType, vtMove, dPar1, dPar2, dPar3)) ; // assegno risultato LuaSetParam( L, bOk) ; return 1 ; diff --git a/Simulator.cpp b/Simulator.cpp index ec2e69c..58adec3 100644 --- a/Simulator.cpp +++ b/Simulator.cpp @@ -24,6 +24,7 @@ #include "/EgtDev/Include/EGkCDeBoxClosedSurfTm.h" #include "/EgtDev/Include/EGkCDeCylClosedSurfTm.h" #include "/EgtDev/Include/EGkCDeSpheClosedSurfTm.h" +#include "/EgtDev/Include/EGkCDeConeFrustumClosedSurfTm.h" #include "/EgtDev/Include/EGkVolZmap.h" #include "/EgtDev/Include/EGkStringUtils3d.h" #include "/EgtDev/Include/EXeConst.h" @@ -1231,6 +1232,10 @@ Simulator::ExecCollisionCheck( int& nCdInd, int& nObjInd, int nMoveType) // esecuzione controlli di collisione bool bOk = true ; Frame3d frObj = pGeoFrame->GetFrame() ; + if ( ! m_CollObj[j].vtMove.IsSmall()) + frObj.Translate( m_CollObj[j].vtMove.x * frObj.VersX() + + m_CollObj[j].vtMove.y * frObj.VersY() + + m_CollObj[j].vtMove.z * frObj.VersZ()) ; Frame3d frParent ; m_pGeomDB->GetGlobFrame( m_CollObj[j].nFrameId, frParent) ; frObj.LocToLoc( frParent, frCd) ; if ( m_CollObj[j].nType == MCH_SIM_COB_BOX) { @@ -1252,6 +1257,12 @@ Simulator::ExecCollisionCheck( int& nCdInd, int& nObjInd, int nMoveType) else bOk = ! CDeSpheClosedSurfTm( frObj.Orig(), m_CollObj[j].dPar1, m_dSafeDist, *pSTM) ; } + else if ( m_CollObj[j].nType == MCH_SIM_COB_CONE) { + if ( pVZM != nullptr) + bOk = pVZM->AvoidConeFrustum( frObj, m_CollObj[j].dPar1, m_CollObj[j].dPar2, m_CollObj[j].dPar3, m_dSafeDist) ; + else + bOk = ! CDeConeFrustumClosedSurfTm( frObj, m_CollObj[j].dPar1, m_CollObj[j].dPar2, m_CollObj[j].dPar3, m_dSafeDist, *pSTM) ; + } if ( ! bOk) { nCdInd = i ; nObjInd = j ; @@ -1752,7 +1763,7 @@ Simulator::OnResetMachine( void) //---------------------------------------------------------------------------- bool -Simulator::AddCollisionObj( int nInd, int nFrameId, int nType, double dPar1, double dPar2, double dPar3) +Simulator::AddCollisionObj( int nInd, int nFrameId, int nType, const Vector3d& vtMove, double dPar1, double dPar2, double dPar3) { // verifiche sui parametri if ( nInd <= 0 || nFrameId <= GDB_ID_NULL) @@ -1763,17 +1774,21 @@ Simulator::AddCollisionObj( int nInd, int nFrameId, int nType, double dPar1, dou return false ; break ; case MCH_SIM_COB_CYL : - if ( abs( dPar1) < EPS_SMALL || abs( dPar2) < EPS_SMALL) + if ( dPar1 < EPS_SMALL || abs( dPar2) < EPS_SMALL) return false ; break ; case MCH_SIM_COB_SPHE : - if ( abs( dPar1) < EPS_SMALL) + if ( dPar1 < EPS_SMALL) + return false ; + break ; + case MCH_SIM_COB_CONE : + if ( ( dPar1 < EPS_SMALL && dPar2 < EPS_SMALL) || dPar3 < EPS_SMALL) return false ; break ; default : return false ; } // aggiungo al vettore - m_CollObj.emplace_back( nInd, nFrameId, nType, dPar1, dPar2, dPar3) ; + m_CollObj.emplace_back( nInd, nFrameId, nType, vtMove, dPar1, dPar2, dPar3) ; return true ; } diff --git a/Simulator.h b/Simulator.h index 4faee46..f5e746a 100644 --- a/Simulator.h +++ b/Simulator.h @@ -37,7 +37,7 @@ class Simulator bool GetToolInfo( std::string& sName, double& dSpeed) const ; bool GetOperationInfo( std::string& sName, int& nType) const ; bool GetMoveInfo( int& nGmove, double& dFeed) const ; - bool AddCollisionObj( int nInd, int nFrameId, int nType, double dPar1, double dPar2, double dPar3) ; + bool AddCollisionObj( int nInd, int nFrameId, int nType, const Vector3d& vtMove, double dPar1, double dPar2, double dPar3) ; bool ExecCollisionCheck( int& nCdInd, int& nObjInd, int nMoveType) ; bool OnCollision( int nCdInd, int nObjInd, int& nErr) ; @@ -94,12 +94,13 @@ class Simulator int nInd ; int nFrameId ; int nType ; + Vector3d vtMove ; double dPar1 ; double dPar2 ; double dPar3 ; - CollObj( void) : nInd( 0), nFrameId( -1), nType( 0), dPar1( 0), dPar2( 0), dPar3( 0) {} - CollObj( int nI, int nF, int nT, double dP1, double dP2, double dP3) - : nInd( nI), nFrameId( nF), nType( nT), dPar1( dP1), dPar2( dP2), dPar3( dP3) {} + CollObj( void) : nInd( 0), nFrameId( -1), nType( 0), vtMove(), dPar1( 0), dPar2( 0), dPar3( 0) {} + CollObj( int nI, int nF, int nT, const Vector3d& vtM, double dP1, double dP2, double dP3) + : nInd( nI), nFrameId( nF), nType( nT), vtMove( vtM), dPar1( dP1), dPar2( dP2), dPar3( dP3) {} } ; typedef std::vector< CollObj> COBVECTOR ; From 8c7ee22703fd73f64a6cb8d8d9a73cb74e0af1fd Mon Sep 17 00:00:00 2001 From: DarioS Date: Fri, 28 May 2021 12:26:24 +0200 Subject: [PATCH 2/2] EgtMachKernel 2.3e4 : - aggiunta gestione collegamento tra lavorazioni con risalita poi rotazione poi spostamento poi discesa (con nuovo flag 5 su rapido). --- EgtMachKernel.rc | Bin 11774 -> 11774 bytes MachineStruConst.h | 2 ++ Operation.cpp | 47 +++++++++++++++++++++++++++++++++++++++++---- Operation.h | 3 ++- 4 files changed, 47 insertions(+), 5 deletions(-) diff --git a/EgtMachKernel.rc b/EgtMachKernel.rc index 951c83213b0efe890b063007f406041c6bdfbe95..d86e1ef151e09ea61a8c2c8047668fdc5480416f 100644 GIT binary patch delta 97 zcmewt{V#gMFE&P#&A-`fnHfzcKa|wnoW?bQ1uSxrY4Qod0+^@}R1`^_2jk{d(jGv4 NK<#LXK~l;gTmUI`BbWdH delta 97 zcmewt{V#gMFE&Qw&A-`fnHh~IKa|wnoW?bQ1uSxrY4Qod0+^@}R1`^_2jk{d(jGv4 NK<#LXK~l;gTmUD-Bai?9 diff --git a/MachineStruConst.h b/MachineStruConst.h index d84a63d..69d1223 100644 --- a/MachineStruConst.h +++ b/MachineStruConst.h @@ -104,6 +104,8 @@ const std::string MCH_EXIT = "T" ; const std::string MCH_ZMAXONROT = "ZMAXONROT" ; // Info di testa per una extra risalita in Z const std::string MCH_ZEXTRA = "ZEXTRA" ; +// Info di testa per abilitare rotazione a Zmax +const std::string MCH_ROTATZMAX = "ROTATZMAX" ; // Info di testa per dichiarazione Home Z in basso const std::string MCH_ZHOMEDOWN = "ZHOMEDOWN" ; // Info di testa per dichiarazione Da Sopra diff --git a/Operation.cpp b/Operation.cpp index 8a3e2e5..9423c6f 100644 --- a/Operation.cpp +++ b/Operation.cpp @@ -1758,6 +1758,7 @@ Operation::AdjustStartEndMovements( bool bVerifyPreviousLink) DBLVECTOR vAxVal2 = vAxVal ; vAxVal2[2] = dHomeZ ; DBLVECTOR vAxIni2 = vAxIni ; vAxIni2[2] = dHomeZ ; if ( ! TestCollisionAvoid( vAxVal2, vAxIni2)) { + // se ammessa risalita aggiuntiva double dExtraZ, dMaxAngV ; if ( GetExtraZ( dHomeZ, dExtraZ, dMaxAngV)) { if ( vAxVal2.size() < 5 || ( abs( vAxVal2[4]) < dMaxAngV && abs( vAxIni2[4]) < dMaxAngV)) { @@ -1772,14 +1773,37 @@ Operation::AdjustStartEndMovements( bool bVerifyPreviousLink) else bToZmax = true ; } + // se altrimenti ammessa rotazione a Zmax e richiesta rotazione + else if ( GetRotationAtZmax() && + (( vAxVal2.size() >= 4 && abs( vAxVal2[3] - vAxIni2[3]) > 5) || + ( vAxVal2.size() >= 5 && abs( vAxVal2[4] - vAxIni2[4]) > 5))) { + // verifico se va bene rotazione assi iniziale e poi movimento + DBLVECTOR vAxMid2 = vAxVal2 ; + vAxMid2[3] = vAxIni2[3] ; + if ( vAxVal2.size() >= 5) + vAxMid2[4] = vAxIni2[4] ; + if ( TestCollisionAvoid( vAxVal2, vAxMid2) && + TestCollisionAvoid( vAxMid2, vAxIni2) && + pPrevOp->AddRise( vAxVal2) && + pPrevOp->AddSpecialRise( vAxMid2, true, GDB_ID_NULL, 5)) { + vAxVal = vAxMid2 ; + bMaxZ = true ; + } + else + return false ; + } else return false ; } } else return false ; - // Se richiesta risalita a Zmax - if ( bToZmax || ForcedZmax( vAxVal, vAxIni)) { + // Se già a Zmax + if ( bMaxZ) { + // non devo fare alcunché + } + // se altrimenti richiesta risalita a Zmax + else if ( bToZmax || ForcedZmax( vAxVal, vAxIni)) { // cancello eventuale risalita parziale della lavorazione precedente pPrevOp->RemoveRise() ; // aggiungo risalita a Zmax @@ -2240,7 +2264,7 @@ Operation::AddRise( DBLVECTOR& vAxVal, double dDelta, int nClPathId, bool bZHome //---------------------------------------------------------------------------- bool -Operation::AddSpecialRise( const DBLVECTOR& vAxVal, bool bOk, int nClPathId) +Operation::AddSpecialRise( const DBLVECTOR& vAxVal, bool bOk, int nClPathId, int nFlag) { if ( m_pMchMgr == nullptr || m_pGeomDB == nullptr) return false ; @@ -2286,7 +2310,8 @@ Operation::AddSpecialRise( const DBLVECTOR& vAxVal, bool bOk, int nClPathId) pCam->SetAxes( ( bOk ? CamData::AS_OK : CamData::AS_OUTSTROKE), vAxVal) ; pCam->SetMoveType( 0) ; pCam->SetFeed( 0) ; - pCam->SetFlag( 0) ; + pCam->SetFlag( nFlag) ; + pCam->SetFlag2( 0) ; // associo questo oggetto a quello geometrico m_pGeomDB->SetUserObj( nId, Release( pCam)) ; @@ -2495,6 +2520,20 @@ Operation::GetExtraZ( double dSafeZ, double& dExtraZ, double& dMaxAngV) const return false ; } +//---------------------------------------------------------------------------- +bool +Operation::GetRotationAtZmax( void) const +{ + // Recupero macchina corrente + Machine* pMch = ( m_pMchMgr != nullptr ? m_pMchMgr->GetCurrMachine() : nullptr) ; + if ( pMch == nullptr) + return 0 ; + // Se testa con Info ROTATZMAX la recupero e restituisco abilitazione rotazione a Zmax + int nHeadId = pMch->GetCurrHead() ; + int nVal = 0 ; + return ( m_pGeomDB->GetInfo( nHeadId, MCH_ROTATZMAX, nVal) && nVal != 0) ; +} + //---------------------------------------------------------------------------- bool Operation::ForcedZmax( const DBLVECTOR& vAxStart, const DBLVECTOR& vAxEnd) const diff --git a/Operation.h b/Operation.h index 5ac6267..27f468d 100644 --- a/Operation.h +++ b/Operation.h @@ -107,11 +107,12 @@ class Operation : public IUserObj bool ToolChangeNeeded( const Operation& Op1, const Operation& Op2) const ; bool RemoveClimb( int nClPathId) ; bool AddRise( DBLVECTOR& vAxVal, double dDelta = - 1, int nClPathId = GDB_ID_NULL, bool bZHomeDown = false) ; - bool AddSpecialRise( const DBLVECTOR& vAxVal, bool bOk = true, int nClPathId = GDB_ID_NULL) ; + bool AddSpecialRise( const DBLVECTOR& vAxVal, bool bOk = true, int nClPathId = GDB_ID_NULL, int nFlag = 0) ; bool RemoveRise( int nClPathId = GDB_ID_NULL) ; bool AddHome( void) ; bool CalcDeltaZForHeadRotation( const DBLVECTOR& vAxStart, const DBLVECTOR& vAxEnd, double& dDeltaZ) const ; bool GetExtraZ( double dSafeZ, double& dExtraZ, double& dMaxAngV) const ; + bool GetRotationAtZmax( void) const ; bool ForcedZmax( const DBLVECTOR& vAxStart, const DBLVECTOR& vAxEnd) const ; int GetUserNotesZmax( void) const ; bool GetZHomeDown( void) const ;