Skip to content

Commit 767413b

Browse files
IKhonakhbeevaiakov
andcommitted
Fix lost robot's position for loadWorldModel action (#1622)
* Fix lost robot's position for loadWorldModel action * Fix deploy Co-authored-by: iakov <iakov@users.noreply.github.com>
1 parent 7cacb17 commit 767413b

File tree

5 files changed

+54
-35
lines changed

5 files changed

+54
-35
lines changed

.github/workflows/main.yml

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,7 @@ jobs:
6969
run: |
7070
ARCH=32
7171
PLATFORM=i686
72-
pacman --verbose --noconfirm -S msys/zlib-devel dos2unix ccache rsync unzip sshpass mingw$ARCH/mingw-w64-$PLATFORM-libzip mingw$ARCH/mingw-w64-$PLATFORM-libusb mingw$ARCH/mingw-w64-$PLATFORM-zlib mingw$ARCH/mingw-w64-$PLATFORM-pkg-config
73-
74-
# https://github.com/msys2/MSYS2-packages/issues/2485 - sshpass failed with strange error
75-
- name: Get older sshpass
76-
run: |
77-
wget http://repo.msys2.org/msys/x86_64/sshpass-1.06-1-x86_64.pkg.tar.xz
78-
pacman --verbose --noconfirm -U ./sshpass-1.06-1-x86_64.pkg.tar.xz
79-
rm ./sshpass-1.06-1-x86_64.pkg.tar.xz
72+
pacman --verbose --noconfirm -S msys/zlib-devel dos2unix ccache rsync unzip openssh mingw$ARCH/mingw-w64-$PLATFORM-libzip mingw$ARCH/mingw-w64-$PLATFORM-libusb mingw$ARCH/mingw-w64-$PLATFORM-zlib mingw$ARCH/mingw-w64-$PLATFORM-pkg-config
8073
8174
- name: Inject slug/short variables
8275
uses: rlespinasse/github-slug-action@v3.x
@@ -230,7 +223,10 @@ jobs:
230223

231224
- name: Deploy installer
232225
if: ${{ matrix.deploy-installer && github.event_name != 'pull_request' && github.repository_owner == 'trikset' }}
233-
run: sshpass -p ${{ secrets.DL_PASSWORD }} rsync -ve "ssh -o StrictHostKeyChecking=no" installer/trik-studio*installer*.exe ${{ secrets.DL_USERNAME }}@${{ secrets.DL_HOST }}:~/dl/ts/fresh/installer/trik-studio-${{ env.GITHUB_REF_SLUG }}-i686-installer.exe
226+
run: |
227+
install -m 600 -D /dev/null ~/.ssh/id_rsa
228+
echo "${{ secrets.DL_PRIVATE_SSH_KEY }}" > ~/.ssh/id_rsa
229+
rsync -v --rsh="ssh -o StrictHostKeyChecking=no" installer/trik-studio*installer*.exe ${{ secrets.DL_USERNAME }}@${{ secrets.DL_HOST }}:~/dl/ts/fresh/installer/trik-studio-${{ env.GITHUB_REF_SLUG }}-i686-installer.exe
234230
235231
- name: Prepare for RDP connection
236232
if: false #comment this line to create RDP session

plugins/robots/common/twoDModel/include/twoDModel/engine/view/twoDModelWidget.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,8 @@ private slots:
234234

235235
void incrementTimelineCounter();
236236

237+
const QDomDocument loadXmlWithConversion(const QString &loadFileName) const;
238+
237239
Ui::TwoDModelWidget *mUi {};
238240
QScopedPointer<TwoDModelScene> mScene;
239241
QScopedPointer<ActionsBox> mActions;

plugins/robots/common/twoDModel/src/engine/view/twoDModelWidget.cpp

Lines changed: 39 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -506,16 +506,7 @@ void TwoDModelWidget::loadWorldModel()
506506
return;
507507
}
508508

509-
QString errorMessage;
510-
int errorLine = 0;
511-
int errorColumn = 0;
512-
const QDomDocument save = utils::xmlUtils::loadDocument(loadFileName, &errorMessage, &errorLine, &errorColumn);
513-
if (!errorMessage.isEmpty()) {
514-
mModel.errorReporter()->addError(QString("%1:%2: %3")
515-
.arg(QString::number(errorLine), QString::number(errorColumn), errorMessage));
516-
}
517-
518-
auto command = new commands::LoadWorldCommand(*this, save);
509+
auto command = new commands::LoadWorldCommand(*this, loadXmlWithConversion(loadFileName));
519510
if (mController) {
520511
mController->execute(command);
521512
}
@@ -528,14 +519,7 @@ void TwoDModelWidget::loadWorldModelWithoutRobot()
528519
return;
529520
}
530521

531-
QString errorMessage;
532-
int errorLine = 0;
533-
int errorColumn = 0;
534-
QDomDocument save = utils::xmlUtils::loadDocument(loadFileName, &errorMessage, &errorLine, &errorColumn);
535-
if (!errorMessage.isEmpty()) {
536-
mModel.errorReporter()->addError(QString("%1:%2: %3")
537-
.arg(QString::number(errorLine), QString::number(errorColumn), errorMessage));
538-
}
522+
QDomDocument save = loadXmlWithConversion(loadFileName);
539523

540524
auto newWorld = save.firstChildElement("root");
541525
auto oldWorld = generateWorldModelXml().firstChildElement("root");
@@ -1131,3 +1115,40 @@ void TwoDModelWidget::incrementTimelineCounter()
11311115
{
11321116
mUi->timelineBox->stepBy(1);
11331117
}
1118+
1119+
const QDomDocument TwoDModelWidget::loadXmlWithConversion(const QString &loadFileName) const
1120+
{
1121+
QString errorMessage;
1122+
int errorLine = 0;
1123+
int errorColumn = 0;
1124+
const QDomDocument save = utils::xmlUtils::loadDocument(loadFileName, &errorMessage, &errorLine, &errorColumn);
1125+
if (!errorMessage.isEmpty()) {
1126+
mModel.errorReporter()->addError(QString("%1:%2: %3")
1127+
.arg(QString::number(errorLine), QString::number(errorColumn), errorMessage));
1128+
return save;
1129+
}
1130+
1131+
QDomElement root = save.firstChildElement("root");
1132+
1133+
QDomElement oldRobot = root.firstChildElement("robots").firstChildElement("robot");
1134+
if (oldRobot.hasAttribute("position") || oldRobot.hasAttribute("direction")
1135+
|| !oldRobot.firstChildElement("startPosition").isNull()) {
1136+
QDomElement world = root.firstChildElement("world");
1137+
if (world.isNull()) {
1138+
world = root.ownerDocument().createElement("world");
1139+
root.appendChild(world);
1140+
}
1141+
1142+
QDomElement robot = world.ownerDocument().createElement("robot");
1143+
robot.setAttribute("position", oldRobot.attribute("position", "0:0"));
1144+
robot.setAttribute("direction", oldRobot.attribute("direction", "0"));
1145+
robot.appendChild(oldRobot.firstChildElement("startPosition"));
1146+
world.appendChild(robot);
1147+
1148+
oldRobot.removeAttribute("position");
1149+
oldRobot.removeAttribute("direction");
1150+
// start position reparented automatically
1151+
}
1152+
1153+
return save;
1154+
}

qrtranslations/fr/plugins/robots/twoDModel_fr.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -763,22 +763,22 @@
763763
<message>
764764
<location line="+0"/>
765765
<location line="+20"/>
766-
<location line="+22"/>
766+
<location line="+13"/>
767767
<source>2D model saves (*.xml)</source>
768768
<translation>Fichiers de sauvegarde du modèle 2D (*.xml) </translation>
769769
</message>
770770
<message>
771-
<location line="-22"/>
771+
<location line="-13"/>
772772
<source>Loading world and robot model</source>
773773
<translation>Chargement des modèles du monde et du robot</translation>
774774
</message>
775775
<message>
776-
<location line="+22"/>
776+
<location line="+13"/>
777777
<source>Loading world without robot model</source>
778778
<translation type="unfinished"></translation>
779779
</message>
780780
<message>
781-
<location line="+316"/>
781+
<location line="+309"/>
782782
<source>Hide details</source>
783783
<translation type="unfinished"></translation>
784784
</message>

qrtranslations/ru/plugins/robots/twoDModel_ru.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1106,17 +1106,17 @@
11061106
<message>
11071107
<location line="+0"/>
11081108
<location line="+20"/>
1109-
<location line="+22"/>
1109+
<location line="+13"/>
11101110
<source>2D model saves (*.xml)</source>
11111111
<translation>Файлы 2D модели (*.xml)</translation>
11121112
</message>
11131113
<message>
1114-
<location line="-22"/>
1114+
<location line="-13"/>
11151115
<source>Loading world and robot model</source>
11161116
<translation>Загрузка модели мира</translation>
11171117
</message>
11181118
<message>
1119-
<location line="+22"/>
1119+
<location line="+13"/>
11201120
<source>Loading world without robot model</source>
11211121
<translation>Загрузка модели мира без модели робота</translation>
11221122
</message>
@@ -1133,7 +1133,7 @@
11331133
<translation type="vanished">Попытка загрузить слишком большое изображение может заморозить выполнение на некоторое время. Продолжить?</translation>
11341134
</message>
11351135
<message>
1136-
<location line="+316"/>
1136+
<location line="+309"/>
11371137
<source>Hide details</source>
11381138
<translation>Скрыть детали</translation>
11391139
</message>

0 commit comments

Comments
 (0)