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
19 changes: 14 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,26 +170,31 @@ 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@341f515d43170dc9ffb4a82b1a1f885ab9511248
with:
checks: 'level0,level1,level2'
database: './compile_commands.json'
database: 'build'
fail-on-warning: true
install-stable: true
only-diff: true
root-dir: ${{ github.workspace }}
ignore-header-deps: true
ignore-external-files: true
ignore-dirs: '^(buildScripts|thirdparty|installer)$'
if: ${{ inputs.lint_clazy }}

- 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 +207,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
6 changes: 5 additions & 1 deletion buildScripts/github/build_installer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,14 @@ 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_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,13 +78,14 @@
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)
{
for (auto *item : mScene->selectedItems()) {

Check warning on line 88 in plugins/robots/common/twoDModel/src/engine/model/physics/box2DPhysicsEngine.cpp

View workflow job for this annotation

GitHub Actions / build-ubuntu-release-tests / build

c++11 range-loop might detach Qt container (QList) [-Wclazy-range-loop-detach]
Box2DItem *bItem = mBox2DDynamicItems.value(item, nullptr);
if (bItem) {
if (active) {
Expand All @@ -110,7 +111,7 @@
mPrevPosition = b2Body_GetPosition(bodyId);
mPrevAngle = b2Rot_GetAngle(b2Body_GetRotation(bodyId));

connect(robot, &model::RobotModel::positionChanged, this, [&] (const QPointF &newPos) {

Check warning on line 114 in plugins/robots/common/twoDModel/src/engine/model/physics/box2DPhysicsEngine.cpp

View workflow job for this annotation

GitHub Actions / build-ubuntu-release-tests / build

Pass small and trivially-copyable type by value (const class QPointF &) [-Wclazy-function-args-by-value]
onRobotStartPositionChanged(newPos, dynamic_cast<model::RobotModel *>(sender()));
});

Expand Down Expand Up @@ -157,7 +158,7 @@
});
}

void Box2DPhysicsEngine::addRobot(model::RobotModel * const robot, const QPointF &pos, qreal angle)

Check warning on line 161 in plugins/robots/common/twoDModel/src/engine/model/physics/box2DPhysicsEngine.cpp

View workflow job for this annotation

GitHub Actions / build-ubuntu-release-tests / build

Pass small and trivially-copyable type by value (const class QPointF &) [-Wclazy-function-args-by-value]
{
if (mBox2DRobots.contains(robot)) {
delete mBox2DRobots[robot];
Expand All @@ -168,7 +169,7 @@
mRightWheels[robot] = mBox2DRobots[robot]->getWheelAt(1);
}

void Box2DPhysicsEngine::onRobotStartPositionChanged(const QPointF &newPos, model::RobotModel *robot)

Check warning on line 172 in plugins/robots/common/twoDModel/src/engine/model/physics/box2DPhysicsEngine.cpp

View workflow job for this annotation

GitHub Actions / build-ubuntu-release-tests / build

Pass small and trivially-copyable type by value (const class QPointF &) [-Wclazy-function-args-by-value]
{
if (!mBox2DRobots.contains(robot)) {
return;
Expand All @@ -187,7 +188,7 @@
mBox2DRobots[robot]->setRotation(angleToBox2D(newAngle));
}

void Box2DPhysicsEngine::onMouseReleased(const QPointF &newPos, qreal newAngle)

Check warning on line 191 in plugins/robots/common/twoDModel/src/engine/model/physics/box2DPhysicsEngine.cpp

View workflow job for this annotation

GitHub Actions / build-ubuntu-release-tests / build

Pass small and trivially-copyable type by value (const class QPointF &) [-Wclazy-function-args-by-value]
{
Box2DRobot *robot = mBox2DRobots.first();

Expand All @@ -200,14 +201,14 @@

void Box2DPhysicsEngine::onMousePressed()
{
for (Box2DRobot *robot: mBox2DRobots){

Check warning on line 204 in plugins/robots/common/twoDModel/src/engine/model/physics/box2DPhysicsEngine.cpp

View workflow job for this annotation

GitHub Actions / build-ubuntu-release-tests / build

c++11 range-loop might detach Qt container (QMap) [-Wclazy-range-loop-detach]
robot->startStopping();
}

onPressedReleasedSelectedItems(false);
}

void Box2DPhysicsEngine::onRecoverRobotPosition(const QPointF &pos)

Check warning on line 211 in plugins/robots/common/twoDModel/src/engine/model/physics/box2DPhysicsEngine.cpp

View workflow job for this annotation

GitHub Actions / build-ubuntu-release-tests / build

Pass small and trivially-copyable type by value (const class QPointF &) [-Wclazy-function-args-by-value]
{
clearForcesAndStop();

Expand All @@ -220,7 +221,7 @@
stop(mBox2DRobots.first()->getWheelAt(0)->getBodyId());
stop(mBox2DRobots.first()->getWheelAt(1)->getBodyId());

onMouseReleased(pos, mBox2DRobots.keys().first()->startPositionMarker()->rotation());

Check warning on line 224 in plugins/robots/common/twoDModel/src/engine/model/physics/box2DPhysicsEngine.cpp

View workflow job for this annotation

GitHub Actions / build-ubuntu-release-tests / build

allocating an unneeded temporary container [-Wclazy-container-anti-pattern]

Check warning on line 224 in plugins/robots/common/twoDModel/src/engine/model/physics/box2DPhysicsEngine.cpp

View workflow job for this annotation

GitHub Actions / build-ubuntu-release-tests / build

allocating an unneeded temporary container [-Wclazy-container-anti-pattern]
}

void Box2DPhysicsEngine::removeRobot(model::RobotModel * const robot)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
class Box2DItem;
}

class Box2DPhysicsEngine : public PhysicsEngineBase

Check warning on line 45 in plugins/robots/common/twoDModel/src/engine/model/physics/box2DPhysicsEngine.h

View workflow job for this annotation

GitHub Actions / build-ubuntu-release-tests / build

twoDModel::model::physics::Box2DPhysicsEngine should take QObject parent argument in CTOR [-Wclazy-ctor-missing-parent-argument]
{
Q_OBJECT
public:
Expand Down Expand Up @@ -77,6 +77,18 @@

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