diff --git a/EgtMachKernel.rc b/EgtMachKernel.rc index b35c7de..0e0bf08 100644 Binary files a/EgtMachKernel.rc and b/EgtMachKernel.rc differ diff --git a/MachMgr.h b/MachMgr.h index 8f4dd54..1e531bf 100644 --- a/MachMgr.h +++ b/MachMgr.h @@ -385,7 +385,8 @@ class MachMgr : public IMachMgr const ToolData* GetMachiningToolData( void) const ; // Machine bool GetHeadAbove( const std::string& sHead) const ; - + double GetAngDeltaMinForHome( void) const ; + private : // Basic void Clear( void) ; diff --git a/MachMgrMachines.cpp b/MachMgrMachines.cpp index 682ab43..d08dffc 100644 --- a/MachMgrMachines.cpp +++ b/MachMgrMachines.cpp @@ -243,6 +243,15 @@ MachMgr::GetHeadAbove( const string& sHead) const return ( ! m_pGeomDB->GetInfo( GetHeadId( sHead), "ABOVE", bAbove) || bAbove) ; } +//---------------------------------------------------------------------------- +double +MachMgr::GetAngDeltaMinForHome( void) const +{ + Machine* pMch = GetCurrMachine() ; + // recupero la minima differenza angolare da posizione precedente per stare vivino a posizione home + return ( ( pMch != nullptr) ? pMch->GetAngDeltaMinForHome() : INFINITO) ; +} + //---------------------------------------------------------------------------- bool MachMgr::GetAxisToken( const string& sAxis, string& sToken) const diff --git a/Machine.cpp b/Machine.cpp index 4fd8626..ac18d19 100644 --- a/Machine.cpp +++ b/Machine.cpp @@ -37,6 +37,7 @@ Machine::Machine( void) m_nTempGroupId = GDB_ID_NULL ; m_dAxisMaxAdjust = EPS_SMALL ; m_dExitMaxAdjust = EPS_SMALL ; + m_dAngDeltaMinForHome = INFINITO ; m_nCalcTabId = GDB_ID_NULL ; m_nCalcHeadId = GDB_ID_NULL ; m_nCalcExitId = GDB_ID_NULL ; diff --git a/Machine.h b/Machine.h index d045941..dc37c27 100644 --- a/Machine.h +++ b/Machine.h @@ -56,6 +56,8 @@ class Machine bool GetAllTablesNames( STRVECTOR& vNames) const ; int GetHeadExitCount( const std::string& sHead) const ; int GetHeadExitPosDirAux( const std::string& sHead, int nExit, Point3d& ptPos, Vector3d& vtDir, Vector3d& vtAux) const ; + double GetAngDeltaMinForHome( void) const + { return m_dAngDeltaMinForHome ; } bool LoadTool( const std::string& sHead, int nExit, const std::string& sTool) ; bool GetLoadedTool( const std::string& sHead, int nExit, std::string& sTool) const ; bool UnloadTool( const std::string& sHead, int nExit) ; @@ -234,6 +236,7 @@ class Machine STRINT_UMAP m_mapGroups ; // dizionario dei gruppi della macchina double m_dAxisMaxAdjust ; // massimo aggiustamento asse da geometria a descrizione cinematica double m_dExitMaxAdjust ; // massimo aggiustamento uscita da geometria a descrizione cinematica + double m_dAngDeltaMinForHome ; // minima differenza angolare da valore precedente per scegliere di stare vicino a home INTVECTOR m_vLinkedRawParts ; // elenco dei grezzi agganciati a gruppi della macchina INTVECTOR m_vLinkedFixtures ; // elenco dei bloccaggi agganciati a gruppi della macchina INTVECTOR m_vLinkedParts ; // elenco dei pezzi agganciati a gruppi della macchina diff --git a/MachineLua.cpp b/MachineLua.cpp index a083f74..4a9943d 100644 --- a/MachineLua.cpp +++ b/MachineLua.cpp @@ -31,6 +31,7 @@ static const string FLD_SPECIAL = "Special" ; static const string FLD_PROCESSOR = "Processor" ; static const string FLD_AXISMAXADJUST = "AxisMaxAdjust" ; static const string FLD_EXITMAXADJUST = "ExitMaxAdjust" ; +static const string FLD_ANGDELTAMINFORHOME = "AngDeltaMinForHome" ; static const string FLD_NAME = "Name" ; static const string FLD_PARENT = "Parent" ; static const string FLD_GEO = "Geo" ; @@ -269,6 +270,9 @@ Machine::LuaEmtGeneral( lua_State* L) // lettura eventuale campo 'ExitMaxAdjust' dalla tabella (default EPS_SMALL) double dExitMaxAdjust = EPS_SMALL ; LuaGetTabFieldParam( L, 1, FLD_EXITMAXADJUST, dExitMaxAdjust) ; + // lettura eventuale campo 'AngDeltaForHome' dalla tabella (default INFINITO) + double dAngDeltaMinForHome = INFINITO ; + LuaGetTabFieldParam( L, 1, FLD_ANGDELTAMINFORHOME, dAngDeltaMinForHome) ; LuaClearStack( L) ; // info @@ -313,6 +317,9 @@ Machine::LuaEmtGeneral( lua_State* L) m_pMchLua->m_dAxisMaxAdjust = dAxisMaxAdjust ; m_pMchLua->m_dExitMaxAdjust = dExitMaxAdjust ; + // imposto minima differenza angolare da posizione precedente per stare vivino a posizione home + m_pMchLua->m_dAngDeltaMinForHome = dAngDeltaMinForHome ; + return 0 ; } diff --git a/Operation.cpp b/Operation.cpp index 2e76f72..e75437c 100644 --- a/Operation.cpp +++ b/Operation.cpp @@ -672,6 +672,13 @@ Operation::CalculateAxesValues( const string& sHint) int nLinAxes = m_pMchMgr->GetCurrLinAxes() ; int nRotAxes = m_pMchMgr->GetCurrRotAxes() ; + // recupero gli angoli home + DBLVECTOR vAxRotHome( nRotAxes, 0.) ; + DBLVECTOR vAxHome ; + m_pMchMgr->GetAllCurrAxesHomePos( vAxHome) ; + for ( int i = 0 ; i < nRotAxes ; ++ i) + vAxRotHome[i] = vAxHome[nLinAxes + i] ; + // Assegno gli angoli iniziali DBLVECTOR vAxRotPrec( nRotAxes, 0.) ; DBLVECTOR vAxVal ; @@ -683,9 +690,7 @@ Operation::CalculateAxesValues( const string& sHint) } // altrimenti uso gli angoli home else { - m_pMchMgr->GetAllCurrAxesHomePos( vAxVal) ; - for ( int i = 0 ; i < nRotAxes ; ++ i) - vAxRotPrec[i] = vAxVal[nLinAxes + i] ; + vAxRotPrec = vAxRotHome ; } // se ci sono suggerimenti validi per gli assi rotanti, li applico if ( ! sHint.empty()) { @@ -710,6 +715,9 @@ Operation::CalculateAxesValues( const string& sHint) // recupero peso primo asse rotante di testa double dRot1W = m_pMchMgr->GetCalcRot1W() ; + // recupero la minima differenza angolare da posizione precedente per stare vivino a posizione home + double dAngDeltaMinForHome = m_pMchMgr->GetAngDeltaMinForHome() ; + // applico eventuali blocchi di assi rotanti m_pMchMgr->ApplyRotAxisBlock() ; @@ -727,12 +735,15 @@ Operation::CalculateAxesValues( const string& sHint) while ( nClPathId != GDB_ID_NULL) { DBLVECTOR vAxRotPrecOri = vAxRotPrec ; int nOutStrC = 0 ; - if ( ! CalculateClPathAxesValues( nClPathId, nLinAxes, nRotAxes, dRot1W, vAxRotPrec, nOutStrC)) { + if ( ! CalculateClPathAxesValues( nClPathId, nLinAxes, nRotAxes, dRot1W, dAngDeltaMinForHome, vAxRotHome, vAxRotPrec, nOutStrC)) { + // se attivata scelta angolo iniziale vicino ad home e extra corsa C, provo a rifarlo disattivando + if ( dAngDeltaMinForHome < ANG_FULL && nOutStrC != 0) + CalculateClPathAxesValues( nClPathId, nLinAxes, nRotAxes, dRot1W, INFINITO, vAxRotHome, vAxRotPrec, nOutStrC) ; // se extracorsa dell'asse C, provo a precaricarlo al contrario if ( nOutStrC != 0) { vAxRotPrec[0] = vAxRotPrecOri[0] + ( nOutStrC > 0 ? - ANG_FULL : ANG_FULL) ; vAxRotPrec[1] = vAxRotPrecOri[1] ; - if ( ! CalculateClPathAxesValues( nClPathId, nLinAxes, nRotAxes, dRot1W, vAxRotPrec, nOutStrC)) + if ( ! CalculateClPathAxesValues( nClPathId, nLinAxes, nRotAxes, dRot1W, INFINITO, vAxRotHome, vAxRotPrec, nOutStrC)) bOk = false ; } else @@ -747,7 +758,7 @@ Operation::CalculateAxesValues( const string& sHint) //---------------------------------------------------------------------------- bool Operation::CalculateClPathAxesValues( int nClPathId, int nLinAxes, int nRotAxes, double dRot1W, - DBLVECTOR& vAxRotPrec, int& nOutStrC) + double dAngDeltaMinForHome, const DBLVECTOR& vAxRotHome, DBLVECTOR& vAxRotPrec, int& nOutStrC) { if ( m_pMchMgr == nullptr || m_pGeomDB == nullptr) return false ; @@ -787,8 +798,11 @@ Operation::CalculateClPathAxesValues( int nClPathId, int nLinAxes, int nRotAxes, // se primo movimento if ( bFirst) { // porto gli angoli ai valori pił vicini ai precedenti con offset di uno o pił giri - for ( size_t i = 0 ; i < vAng1.size() ; ++ i) - m_pMchMgr->GetNearestAngleInStroke( int( i), vAxRotPrec[i], vAng1[i]) ; + for ( int i = 0 ; i < int( vAng1.size()) ; ++ i) { + m_pMchMgr->GetNearestAngleInStroke( i, vAxRotPrec[i], vAng1[i]) ; + if ( abs( vAng1[i] - vAxRotPrec[i]) > dAngDeltaMinForHome) + m_pMchMgr->GetNearestAngleInStroke( i, vAxRotHome[i], vAng1[i]) ; + } // se sol.ne indeterminata (sempre il primo asse libero), assegno il precedente, limitandolo alla corsa if ( nRStat < 0 && vAng1.size() >= 1) { for ( int i = 0 ; i < int( vAng1.size()) ; ++ i) { @@ -805,8 +819,11 @@ Operation::CalculateClPathAxesValues( int nClPathId, int nLinAxes, int nRotAxes, // per movimenti successivi else { // scelgo gli angoli pił vicini, per continuitą non applico offset per stare nelle corse - for ( size_t i = 0 ; i < vAng1.size() ; ++ i) + for ( int i = 0 ; i < int( vAng1.size()) ; ++ i) { vAng1[i] = AngleNearAngle( vAng1[i], vAxRotPrec[i]) ; + if ( abs( vAng1[i] - vAxRotPrec[i]) > dAngDeltaMinForHome) + vAng1[i] = AngleNearAngle( vAng1[i], vAxRotHome[i]) ; + } // se sol.ne indeterminata (sempre il primo asse libero), assegno il precedente if ( nRStat < 0 && vAng1.size() >= 1) { for ( int i = 0 ; i < int( vAng1.size()) ; ++ i) { @@ -826,9 +843,13 @@ Operation::CalculateClPathAxesValues( int nClPathId, int nLinAxes, int nRotAxes, // se primo movimento if ( bFirst) { // porto gli angoli ai valori pił vicini ai precedenti con offset di uno o pił giri - for ( size_t i = 0 ; i < vAng1.size() ; ++ i) { - m_pMchMgr->GetNearestAngleInStroke( int( i), vAxRotPrec[i], vAng1[i]) ; - m_pMchMgr->GetNearestAngleInStroke( int( i), vAxRotPrec[i], vAng2[i]) ; + for ( int i = 0 ; i < int( vAng1.size()) ; ++ i) { + m_pMchMgr->GetNearestAngleInStroke( i, vAxRotPrec[i], vAng1[i]) ; + if ( abs( vAng1[i] - vAxRotPrec[i]) > dAngDeltaMinForHome) + m_pMchMgr->GetNearestAngleInStroke( i, vAxRotHome[i], vAng1[i]) ; + m_pMchMgr->GetNearestAngleInStroke( i, vAxRotPrec[i], vAng2[i]) ; + if ( abs( vAng2[i] - vAxRotPrec[i]) > dAngDeltaMinForHome) + m_pMchMgr->GetNearestAngleInStroke( i, vAxRotHome[i], vAng2[i]) ; } // se sol.ne indeterminata (sempre il primo asse libero), assegno il precedente, limitandolo alla corsa if ( nRStat < 0 && vAng1.size() >= 1) { @@ -846,20 +867,24 @@ Operation::CalculateClPathAxesValues( int nClPathId, int nLinAxes, int nRotAxes, } else { // scelgo gli angoli pił vicini, per continuitą non applico offset per stare nelle corse - for ( size_t i = 0 ; i < vAng1.size() ; ++ i) { + for ( int i = 0 ; i < int( vAng1.size()) ; ++ i) { vAng1[i] = AngleNearAngle( vAng1[i], vAxRotPrec[i]) ; + if ( abs( vAng1[i] - vAxRotPrec[i]) > dAngDeltaMinForHome) + vAng1[i] = AngleNearAngle( vAng1[i], vAxRotHome[i]) ; vAng2[i] = AngleNearAngle( vAng2[i], vAxRotPrec[i]) ; - // se sol.ne indeterminata (sempre il primo asse libero), assegno il precedente - if ( nRStat < 0 && vAng1.size() >= 1) { - for ( int i = 0 ; i < int( vAng1.size()) ; ++ i) { - // ignoro gli assi bloccati - if ( m_pMchMgr->IsKinematicRotAxisBlocked( i)) - continue ; - // assegno il precedente ed esco - vAng1[i] = vAxRotPrec[i] ; - vAng2[i] = vAng1[i] ; - break ; - } + if ( abs( vAng2[i] - vAxRotPrec[i]) > dAngDeltaMinForHome) + vAng2[i] = AngleNearAngle( vAng2[i], vAxRotHome[i]) ; + } + // se sol.ne indeterminata (sempre il primo asse libero), assegno il precedente + if ( nRStat < 0 && vAng1.size() >= 1) { + for ( int i = 0 ; i < int( vAng1.size()) ; ++ i) { + // ignoro gli assi bloccati + if ( m_pMchMgr->IsKinematicRotAxisBlocked( i)) + continue ; + // assegno il precedente ed esco + vAng1[i] = vAxRotPrec[i] ; + vAng2[i] = vAng1[i] ; + break ; } } // verifico che le soluzioni siano nelle corse @@ -873,9 +898,9 @@ Operation::CalculateClPathAxesValues( int nClPathId, int nLinAxes, int nRotAxes, // scelgo la soluzione pił vicina alla precedente double dDelta1 = 0 ; double dDelta2 = 0 ; - for ( size_t i = 0 ; i < vAng1.size() ; ++ i) { + for ( int i = 0 ; i < int( vAng1.size()) ; ++ i) { // ignoro gli assi bloccati - if ( m_pMchMgr->IsKinematicRotAxisBlocked( int( i))) + if ( m_pMchMgr->IsKinematicRotAxisBlocked( i)) continue ; // calcolo i delta asse con eventuale peso bool bFirst = ( i == 0) ; diff --git a/Operation.h b/Operation.h index ea4318e..d4da772 100644 --- a/Operation.h +++ b/Operation.h @@ -85,7 +85,7 @@ class Operation : public IUserObj std::string ExtractHint( const std::string& sNotes) ; bool CalculateAxesValues( const std::string& sHint) ; bool CalculateClPathAxesValues( int nClPathId, int nLinAxes, int nRotAxes, double dRot1W, - DBLVECTOR& vAxRotPrec, int& nOutStrC) ; + double dAngDeltaMinForHome, const DBLVECTOR& vAxRotHome, DBLVECTOR& vAxRotPrec, int& nOutStrC) ; bool AdjustStartEndMovements( bool bVerifyPreviousLink = true) ; bool AdjustOneStartMovement( int nClPathId, int nPrevClPathId, const DBLVECTOR& vAxPrev, bool bMaxZ) ; bool ToolChangeNeeded( const Operation& Op1, const Operation& Op2) ;