Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions .github/workflows/setup_environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 }}
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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 }}
Expand All @@ -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
Expand Down
2 changes: 2 additions & 0 deletions buildScripts/github/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 4 additions & 1 deletion buildScripts/github/build_installer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 4 additions & 1 deletion buildScripts/github/build_internal.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Loading