Skip to content

Commit f2dcfd6

Browse files
committed
deprecate qt3d
1 parent 229bd2b commit f2dcfd6

11 files changed

Lines changed: 94 additions & 26 deletions

File tree

xbot2_gui/Monitoring/JointCommandCard.qml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Card {
1414
property ClientEndpoint client
1515
property RobotModelNode robotCmd
1616
signal resetCmd()
17+
signal cmdChanged()
1718
function selectJoint(jname) {
1819
nameCombo.currentIndex = nameCombo.find(jname)
1920
}
@@ -55,6 +56,7 @@ Card {
5556
onMoved: {
5657
robotCmd.q[nameCombo.currentIndex] = value
5758
robotCmd.qChanged()
59+
root.cmdChanged()
5860
}
5961
from: SharedData.qmin[SharedData.jointNames.indexOf(nameCombo.currentText)]
6062
to: SharedData.qmax[SharedData.jointNames.indexOf(nameCombo.currentText)]
@@ -101,7 +103,7 @@ Card {
101103
text: 'Reset'
102104
onReleased: {
103105
root.resetCmd()
104-
// nameCombo.currentIndexChanged()
106+
nameCombo.currentIndexChanged()
105107
}
106108
}
107109

xbot2_gui/Monitoring/Monitoring.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ function jsCallback(js) {
1717

1818
addJointStatePoint(livePlot, js)
1919

20-
// robotViewer.updateRobotState(js,
21-
// robotViewer.robotState,
22-
// 'linkPos')
20+
robotViewer.updateRobotState(js,
21+
robotViewer.robotState,
22+
'linkPos')
2323

2424
for(let aux of js.aux_types) {
2525
barPlot.addAuxType(aux)

xbot2_gui/Monitoring/Monitoring.qml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ MultiPaneResponsiveLayout {
1919

2020
id: root
2121
property Item livePlot: CommonProperties.globalLivePlot
22-
onBeforeLayoutChange: loader.active = false
23-
onAfterLayoutChange: loader.active = true
22+
// onBeforeLayoutChange: loader.active = false
23+
// onAfterLayoutChange: loader.active = true
2424
property real vbatt
2525
property real iload
2626

@@ -185,7 +185,7 @@ MultiPaneResponsiveLayout {
185185

186186
id: loader
187187
width: parent.width
188-
asynchronous: false
188+
asynchronous: true
189189
// visible: status === Loader.Ready
190190
active: true
191191

@@ -195,8 +195,8 @@ MultiPaneResponsiveLayout {
195195

196196
sourceComponent: V.RobotModelViewer {
197197
id: robotViewer
198-
199198
client: root.client
199+
color: Qt.transparent
200200
// backgroundColor: 'transparent'
201201

202202
}
@@ -209,6 +209,7 @@ MultiPaneResponsiveLayout {
209209
client: root.client
210210
robotCmd: loader.item.robotCmd
211211
onResetCmd: robotViewer.resetCmd()
212+
onCmdChanged: robotViewer.showRobotCmd = true
212213
enabled: jointDevice.jointActive
213214
}
214215

xbot2_gui/RobotModel/robot_model.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class RobotModel::Impl
1919

2020
QList<QString> getJointNames();
2121

22-
int ndof;
22+
int ndof = 0;
2323

2424
QList<QString> jointNames;
2525

xbot2_gui/ViewerQuick3D/CustomMesh.qml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Node {
1212
property string meshUri
1313

1414
property alias visible: model.visible
15+
property alias axesVisible: axes.visible
1516
property color color: Qt.rgba(0.8, 0.8, 0.8, 1.0)
1617
property alias alpha: material.opacity
1718

@@ -49,6 +50,7 @@ Node {
4950
}
5051

5152
Axes3D {
53+
id: axes
5254
scale: Qt.vector3d(0.1, 0.1, 0.1)
5355
}
5456

xbot2_gui/ViewerQuick3D/RobotModelNode.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,10 @@ function getPose(model, linkName) {
6262

6363
function updateQ(q) {
6464

65-
console.log(`updateQ ${JSON.stringify(q)}`)
65+
if(q.length !== model.ndof) {
66+
console.error(`q.length !== model.ndof (${q.length} !== ${model.ndof})`)
67+
return
68+
}
6669

6770
model.setJointPosition(q)
6871

xbot2_gui/ViewerQuick3D/RobotModelNode.qml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Node {
2020

2121
property alias ndof: model.ndof
2222

23-
property bool visible: true
23+
property bool axesVisible: false
2424

2525
property var q: Array(ndof).fill(0.0)
2626

@@ -65,6 +65,7 @@ Node {
6565
alpha: root.alpha
6666
visible: root.visible
6767
client: root.client
68+
axesVisible: root.axesVisible
6869
}
6970
}
7071

xbot2_gui/ViewerQuick3D/RobotModelViewer.js

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@ function updateViewerState(js, robot, fieldName) {
1414

1515
function updateViewerQ(js, jointNames, fieldName, q) {
1616

17-
18-
console.log(`updateViewerQ1 ${JSON.stringify(q)}`)
19-
2017
for(let i = 0; i < js.name.length; i++) {
2118

2219
let name = js.name[i]
@@ -26,15 +23,10 @@ function updateViewerQ(js, jointNames, fieldName, q) {
2623
continue
2724
}
2825

29-
console.log(`${q[idx]} ${js[fieldName][i]}`)
30-
3126
q[idx] = js[fieldName][i]
3227

3328
}
3429

35-
36-
console.log(`updateViewerQ2 ${JSON.stringify(q)}`)
37-
3830
return q
3931
}
4032

xbot2_gui/ViewerQuick3D/RobotModelViewer.qml

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
import QtQuick
2+
import QtQuick.Layouts
3+
import QtQuick.Controls
24
import QtQuick3D
35
import QtQuick3D.Helpers
46

57
import Main
8+
import Common
69
import "/qt/qml/Main/sharedData.js" as SharedData
710
import "RobotModelViewer.js" as Logic
811

@@ -13,6 +16,7 @@ Rectangle {
1316
property ClientEndpoint client
1417
property alias robotState: robotState
1518
property alias robotCmd: robotCmd
19+
property alias showRobotCmd: showCmdChk.checked
1620

1721
function updateRobotState(js, robot, fieldName) {
1822
Logic.updateViewerState(js, robot, fieldName)
@@ -27,6 +31,28 @@ Rectangle {
2731
//
2832
id: root
2933

34+
Control {
35+
36+
z: 10
37+
38+
contentItem: GridLayout {
39+
columns: 2
40+
CheckBox {
41+
id: showAxesChk
42+
Layout.fillWidth: true
43+
Layout.columnSpan: 2
44+
text: 'Show axes'
45+
}
46+
CheckBox {
47+
id: showCmdChk
48+
Layout.fillWidth: true
49+
Layout.columnSpan: 2
50+
text: 'Show command robot'
51+
}
52+
}
53+
54+
}
55+
3056
// The root scene
3157
Node {
3258

@@ -51,7 +77,7 @@ Rectangle {
5177
}
5278

5379
Axes3D {
54-
80+
visible: showAxesChk.checked
5581
}
5682

5783
Node {
@@ -64,16 +90,14 @@ Rectangle {
6490
eulerRotation.x: -25
6591
}
6692

67-
68-
6993
RobotModelNode {
7094
id: robotState
7195
client: root.client
7296
eulerRotation.x: -90
7397
y: 75
74-
opacity: 0.5
98+
opacity: showAxesChk.checked ? 0.9 : 1
7599
color: 'green'
76-
visible: false
100+
axesVisible: showAxesChk.checked
77101
}
78102

79103
RobotModelNode {
@@ -82,6 +106,7 @@ Rectangle {
82106
eulerRotation.x: -90
83107
y: 75
84108
opacity: 0.5
109+
visible: showCmdChk.checked
85110
}
86111

87112
}
@@ -97,7 +122,7 @@ Rectangle {
97122

98123
environment: SceneEnvironment {
99124
backgroundMode: SceneEnvironment.Color
100-
clearColor: Qt.rgba(0.8, 0.8, 0.8, 1)
125+
clearColor: palette.active.base
101126
InfiniteGrid {
102127
gridInterval: 30
103128
}

xbot2_gui/main.cpp

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
#include "ViewerQuick3D/meshgeometry.h"
2121
#endif
2222

23+
#include <QtCore/qcoreapplication_platform.h>
24+
2325
class AppData : public QObject
2426
{
2527
Q_OBJECT
@@ -68,6 +70,45 @@ class AppData : public QObject
6870
}
6971
}
7072

73+
Q_INVOKABLE void keepScreenOn(bool on)
74+
{
75+
#ifdef ANDROID
76+
QNativeInterface::QAndroidApplication::runOnAndroidMainThread(
77+
[on]()
78+
{
79+
QJniObject activity = QNativeInterface::QAndroidApplication::context();
80+
81+
if (activity.isValid())
82+
{
83+
QJniObject window =
84+
activity.callObjectMethod("getWindow", "()Landroid/view/Window;");
85+
86+
if (window.isValid())
87+
{
88+
const int FLAG_KEEP_SCREEN_ON = 128;
89+
90+
if (on)
91+
{
92+
window.callMethod<void>("addFlags", "(I)V", FLAG_KEEP_SCREEN_ON);
93+
}
94+
else
95+
{
96+
window.callMethod<void>("clearFlags", "(I)V", FLAG_KEEP_SCREEN_ON);
97+
}
98+
}
99+
}
100+
101+
QJniEnvironment env;
102+
103+
if (env->ExceptionCheck()) {
104+
env->ExceptionClear();
105+
}
106+
});
107+
#else
108+
static_cast<void>(on);
109+
#endif
110+
}
111+
71112
public:
72113

73114
QString hostname { "localhost" };
@@ -82,6 +123,7 @@ class AppData : public QObject
82123

83124
int main(int argc, char *argv[])
84125
{
126+
85127
// create appdata global object
86128
AppData appdata;
87129

0 commit comments

Comments
 (0)