diff --git a/.github/workflows/setup_environment.yml b/.github/workflows/setup_environment.yml index 75c8c94baa..f9a54831d3 100644 --- a/.github/workflows/setup_environment.yml +++ b/.github/workflows/setup_environment.yml @@ -98,6 +98,7 @@ jobs: run: | git config --global core.symlinks true git config --global core.autocrlf input + echo "BUILD_DIR=${{ github.workspace }}/build" >> $GITHUB_ENV - name: Checkout repository uses: actions/checkout@v4 @@ -146,7 +147,7 @@ jobs: if: ${{ inputs.build }} - name: Build - run: buildScripts/github/build.sh + run: "$GITHUB_WORKSPACE/buildScripts/github/build.sh" env: TRIK_QT_VERSION: ${{ inputs.trik_qt_version }} TRIK_PYTHON3_VERSION_MINOR: ${{ inputs.trik_python3_version_minor }} @@ -157,6 +158,8 @@ jobs: EXECUTOR: ${{ inputs.executor }} QMAKE_EXTRA: ${{ inputs.qmake_extra }} NEED_COMPILE_DATABASE: ${{ inputs.lint_clazy }} + BUILD_DIR: ${{ env.BUILD_DIR }} + ROOT_DIR: ${{ github.workspace }} if: ${{ inputs.build }} - name: Save build cache @@ -167,17 +170,18 @@ jobs: if: ${{ inputs.build }} - name: Run tests - run: ${{ inputs.executor }} buildScripts/github/run_tests.sh + run: ${{ inputs.executor }} "$GITHUB_WORKSPACE/buildScripts/github/run_tests.sh" + working-directory: ${{ env.BUILD_DIR }} env: TRIK_PYTHON3_VERSION_MINOR: ${{ inputs.trik_python3_version_minor }} TESTS: ${{ inputs.tests }} if: ${{ inputs.build == true }} - name: Clazy-standalone - uses: MinyazevR/clazy-standalone-action@v0.3.2 + uses: MinyazevR/clazy-standalone-action@f586d952ec72bb7ea5910e9e78903cc4ed4510d7 with: checks: 'level0,level1,level2' - database: './compile_commands.json' + database: 'build' fail-on-warning: true install-stable: true only-diff: true @@ -186,7 +190,8 @@ jobs: - name: Build Installer run: | - buildScripts/github/build_installer.sh + "$GITHUB_WORKSPACE/buildScripts/github/build_installer.sh" + working-directory: ${{ env.BUILD_DIR }} env: TRIK_QT_VERSION: ${{ inputs.trik_qt_version }} TRIK_PYTHON3_VERSION_MINOR: ${{ inputs.trik_python3_version_minor }} @@ -199,6 +204,7 @@ jobs: ssh_key: ${{ secrets.DL_PRIVATE_SSH_KEY }} username: ${{ secrets.DL_USERNAME }} host: ${{ secrets.DL_HOST }} + ROOT_DIR: ${{ github.workspace }} if: ${{ inputs.build_installer }} - name: Evaluate artifact name diff --git a/buildScripts/github/build.sh b/buildScripts/github/build.sh index 89f8631794..dc1323b9de 100755 --- a/buildScripts/github/build.sh +++ b/buildScripts/github/build.sh @@ -38,6 +38,8 @@ CCACHE_DIR="$CCACHE_DIR" \ CONFIG="$CONFIG" \ QMAKE_EXTRA="$QMAKE_EXTRA" \ PROJECT="$PROJECT" \ +BUILD_DIR="$BUILD_DIR" \ +ROOT_DIR="$ROOT_DIR" \ RUNNER_OS="$RUNNER_OS" \ buildScripts/github/build_internal.sh diff --git a/buildScripts/github/build_installer.sh b/buildScripts/github/build_installer.sh index c2d40e6f7e..b7515369c1 100755 --- a/buildScripts/github/build_installer.sh +++ b/buildScripts/github/build_installer.sh @@ -33,10 +33,13 @@ if [[ "$RUNNER_OS" == Linux ]] ; then fi echo Start build installer -$EXECUTOR bash -c "installer/build-trik-studio.sh $QTBIN $QTIFWBIN ." +$EXECUTOR bash -c "$ROOT_DIR/installer/build-trik-studio.sh $QTBIN $QTIFWBIN ." + +pushd "$ROOT_DIR/installer" INSTALLER_NAME=$(find installer -name "trik-studio*installer*" -print -quit | grep . ) if "$NEED_DEPLOY" ; then $EXECUTOR bash -c "rsync -v --rsh='ssh -o StrictHostKeyChecking=no -vvv -i $HOME/.ssh/id_rsa' $INSTALLER_NAME $username@$host:~/dl/ts/fresh/installer/$TSNAME" fi +popd diff --git a/buildScripts/github/build_internal.sh b/buildScripts/github/build_internal.sh index 25ecbc5cf1..a5665d5f7b 100755 --- a/buildScripts/github/build_internal.sh +++ b/buildScripts/github/build_internal.sh @@ -10,9 +10,12 @@ qmake -query ccache -sz { which python3 && python3 -V || true ; } { which python && python -V || true ; } +mkdir -p build && cd build export PYTHON_DIR=$(python3.${TRIK_PYTHON3_VERSION_MINOR}-config --prefix) rm -f .qmake.cache -qmake -Wall PYTHON_VERSION=3.$TRIK_PYTHON3_VERSION_MINOR PYTHON_PATH=/usr CONFIG+=$CONFIG $QMAKE_EXTRA $PROJECT.pro + +pushd "$BUILD_DIR" +qmake -Wall PYTHON_VERSION=3.$TRIK_PYTHON3_VERSION_MINOR PYTHON_PATH=/usr CONFIG+=$CONFIG $QMAKE_EXTRA "$ROOT_DIR/$PROJECT.pro" make -j $(nproc) qmake_all 2>&1 | tee -a build.log ccache -s if [ "$NEED_COMPILE_DATABASE" = "true" ]; then diff --git a/plugins/robots/common/twoDModel/src/engine/model/physics/box2DPhysicsEngine.cpp b/plugins/robots/common/twoDModel/src/engine/model/physics/box2DPhysicsEngine.cpp index f6562e41d5..0f7f4b5aff 100644 --- a/plugins/robots/common/twoDModel/src/engine/model/physics/box2DPhysicsEngine.cpp +++ b/plugins/robots/common/twoDModel/src/engine/model/physics/box2DPhysicsEngine.cpp @@ -78,8 +78,9 @@ qreal Box2DPhysicsEngine::rotation(model::RobotModel &robot) const return 0; } - auto angle = b2Rot_GetAngle(b2Body_GetRotation(mBox2DRobots[&robot]->getBodyId())); - return angleToScene(angle - mPrevAngle); + auto currentAngle = b2Rot_GetAngle(b2Body_GetRotation(mBox2DRobots[&robot]->getBodyId())); + const auto angle = countAngle(mPrevAngle, currentAngle); + return angleToScene(angle); } void Box2DPhysicsEngine::onPressedReleasedSelectedItems(bool active) diff --git a/plugins/robots/common/twoDModel/src/engine/model/physics/box2DPhysicsEngine.h b/plugins/robots/common/twoDModel/src/engine/model/physics/box2DPhysicsEngine.h index 85e58c6b6d..ced415766f 100644 --- a/plugins/robots/common/twoDModel/src/engine/model/physics/box2DPhysicsEngine.h +++ b/plugins/robots/common/twoDModel/src/engine/model/physics/box2DPhysicsEngine.h @@ -77,6 +77,18 @@ class Box2DPhysicsEngine : public PhysicsEngineBase b2WorldId box2DWorldId(); + static inline qreal countAngle(const qreal previousAngle, const qreal currentAngle) { + qreal deltaAngle = currentAngle - previousAngle; + + if (deltaAngle > mathUtils::pi) { + deltaAngle -= 2 * mathUtils::pi; + } else if (deltaAngle < -mathUtils::pi) { + deltaAngle += 2 * mathUtils::pi; + } + + return deltaAngle; + } + public slots: void onItemDragged(graphicsUtils::AbstractItem *item); void onRobotStartPositionChanged(const QPointF &newPos, twoDModel::model::RobotModel *robot); diff --git a/plugins/robots/common/twoDModel/src/engine/model/physics/parts/box2DItem.cpp b/plugins/robots/common/twoDModel/src/engine/model/physics/parts/box2DItem.cpp index 874e138255..ecc30cfe87 100644 --- a/plugins/robots/common/twoDModel/src/engine/model/physics/parts/box2DItem.cpp +++ b/plugins/robots/common/twoDModel/src/engine/model/physics/parts/box2DItem.cpp @@ -114,8 +114,10 @@ b2BodyId Box2DItem::getBodyId() const bool Box2DItem::angleOrPositionChanged() const { - auto angle = b2Rot_GetAngle(b2Body_GetRotation(mBodyId)); + auto currentAngle = b2Rot_GetAngle(b2Body_GetRotation(mBodyId)); auto position = b2Body_GetPosition(mBodyId); + + auto angle = Box2DPhysicsEngine::countAngle(mPreviousRotation, currentAngle); return b2Distance(mPreviousPosition, position) > FLT_EPSILON - || qAbs(mPreviousRotation - angle) > FLT_EPSILON; + || qAbs(angle) > FLT_EPSILON; } diff --git a/plugins/robots/common/twoDModel/src/engine/model/physics/parts/box2DRobot.cpp b/plugins/robots/common/twoDModel/src/engine/model/physics/parts/box2DRobot.cpp index feaed07b8a..a5c428a1c1 100644 --- a/plugins/robots/common/twoDModel/src/engine/model/physics/parts/box2DRobot.cpp +++ b/plugins/robots/common/twoDModel/src/engine/model/physics/parts/box2DRobot.cpp @@ -154,7 +154,7 @@ void Box2DRobot::setRotation(float angle) b2Body_GetJoints(wheelBodyId, joints.data(), 1); auto position = b2Joint_GetLocalFrameB(joints[0]); auto point = b2Body_GetWorldPoint(b2Joint_GetBodyB(joints[0]), position.p); - b2Body_SetTransform(wheelBodyId, point , rotation); + b2Body_SetTransform(wheelBodyId, point, rotation); } reinitSensors();