Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
robot-sample-app
Manage
Activity
Members
Plan
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
CodeLinaro
le
platform
vendor
qcom-opensource
robot-sample-app
Commits
417dba7b
Commit
417dba7b
authored
4 months ago
by
Linux Build Service Account
Browse files
Options
Downloads
Plain Diff
Merge
0308eff3
on remote branch
Change-Id: Icc7d000274cb696f1c4a5a422d7a27a34d0d1302
parents
036a01db
0308eff3
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
inventory_scan/inventory_scan/web/inventory_scan.html
+297
-0
297 additions, 0 deletions
inventory_scan/inventory_scan/web/inventory_scan.html
with
297 additions
and
0 deletions
inventory_scan/inventory_scan/web/inventory_scan.html
0 → 100644
+
297
−
0
View file @
417dba7b
<!--Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved.
SPDX-License-Identifier: BSD-3-Clause-Clear -->
<!DOCTYPE html>
<html
lang=
"en"
>
<head>
<meta
charset=
"UTF8"
>
<title>
ROS Web Interaction
</title>
<style>
body
{
margin
:
20px
;
}
#container
{
display
:
flex
;
justify-content
:
space-between
;
}
#image-container
{
display
:
flex
;
width
:
50%
;
align-items
:
center
;
}
.input-group
{
flex-wrap
:
nowrap
;
margin-bottom
:
20px
;
}
input
[
type
=
"number"
]
{
width
:
120px
;
}
button
{
width
:
100px
;
}
.text-box
{
border
:
1px
solid
#ccc
;
padding
:
20px
;
background-color
:
#f9f9f9
;
width
:
500px
;
height
:
100px
;
}
</style>
</head>
<body>
<h1
style=
"text-align: center;"
>
Inventory Scan
</h1>
<div
id=
"container"
>
<div
id=
"control-container"
>
<div
class=
"input-group"
>
<button
id=
"addStationButton"
>
Add Station
</button>
<input
type=
"number"
id=
"station_x"
placeholder=
"x"
step=
"0.01"
>
<input
type=
"number"
id=
"station_y"
placeholder=
"y"
step=
"0.01"
>
<input
type=
"number"
id=
"station_angle"
placeholder=
"angle"
step=
"0.01"
>
<button
id=
"getStationButton"
>
Get Pose
</button>
</div>
<div
class=
"input-group"
>
<button
id=
"delateStationButton"
>
Delete Station
</button>
<input
type=
"text"
id=
"station_del"
placeholder=
"station1,station2..."
min=
"0"
>
</div>
<div
class=
"input-group"
>
<button
id=
"addPath"
>
Add Path
</button>
<input
type=
"number"
id=
"path_a"
placeholder=
"station number"
min=
"0"
>
<span
class=
"arrow"
>
→
</span>
<input
type=
"number"
id=
"path_b"
placeholder=
"station number"
min=
"0"
>
</div>
<div
class=
"input-group"
>
<button
id=
"deletePath"
>
Delete Path
</button>
<input
type=
"number"
id=
"path_del_a"
placeholder=
"station number"
min=
"0"
>
<span
class=
"arrow"
>
→
</span>
<input
type=
"number"
id=
"path_del_b"
placeholder=
"station number"
min=
"0"
>
</div>
<div
class=
"input-group"
>
<button
id=
"planPath"
>
Planning Path
</button>
<input
type=
"text"
id=
"plan_path_a"
placeholder=
"station1,station2..."
min=
"0"
>
</div>
<div
class=
"input-group"
>
<button
id=
"startScan"
>
Start Scan
</button>
<button
id=
"stopScan"
>
Stop Scan
</button>
</div>
<h2>
Scan Goods information
</h2>
<textarea
id=
"goodsText"
class=
"text-box"
readonly
></textarea>
<h2>
Error Goods information
</h2>
<textarea
id=
"errorsText"
class=
"text-box"
readonly
></textarea>
</div>
<div
id=
"image-container"
>
<img
id=
"mapImage"
src=
""
>
</div>
</div>
<script
src=
"roslib.min.js"
></script>
<script>
document
.
addEventListener
(
"
DOMContentLoaded
"
,
function
()
{
var
host
=
window
.
location
.
hostname
;
var
ros
=
new
ROSLIB
.
Ros
({
url
:
'
ws://
'
+
host
+
'
:9090
'
});
ros
.
on
(
'
connection
'
,
function
()
{
console
.
log
(
'
Connected to websocket server.
'
);
});
ros
.
on
(
'
error
'
,
function
(
error
)
{
alert
(
'
Error connecting to ros bridge server
\n
'
+
'
Please check whether the rosbridge_server is launched
\n
'
+
'
After launched the rosbridge_server, please refresh the website
\n
'
);
console
.
log
(
'
Error connecting to rosbridge_server
'
,
error
);
});
ros
.
on
(
'
close
'
,
function
()
{
alert
(
'
ros bridge server has been closed
'
);
console
.
log
(
'
Connection to websocket server closed.
'
);
});
var
mapListener
=
new
ROSLIB
.
Topic
({
ros
:
ros
,
name
:
'
/scan_map
'
,
messageType
:
'
sensor_msgs/CompressedImage
'
});
mapListener
.
subscribe
(
function
(
message
)
{
document
.
getElementById
(
'
mapImage
'
).
src
=
"
data:image/jpeg;base64,
"
+
message
.
data
;
});
var
resultListener
=
new
ROSLIB
.
Topic
({
ros
:
ros
,
name
:
'
/scan_result
'
,
messageType
:
'
inventory_scan_msgs/msg/ScanResult
'
});
resultListener
.
subscribe
(
function
(
message
)
{
document
.
getElementById
(
'
goodsText
'
).
value
=
''
;
document
.
getElementById
(
'
errorsText
'
).
value
=
''
;
message
.
goods_info
.
forEach
(
function
(
item
)
{
document
.
getElementById
(
'
goodsText
'
).
value
+=
item
+
'
\n
'
;
});
message
.
warnings
.
forEach
(
function
(
item
)
{
document
.
getElementById
(
'
errorsText
'
).
value
+=
item
+
'
\n
'
;
});
});
var
clientPath
=
new
ROSLIB
.
Service
({
ros
:
ros
,
name
:
'
/scan_path
'
,
serviceType
:
'
inventory_scan_msgs/srv/ScanPath
'
});
const
pathCmds
=
{
ADD_STATION
:
0
,
DELETE_STATION
:
1
,
ADD_PATH
:
2
,
DELETE_PATH
:
3
,
QUERY_POSE
:
4
,
ADD_FULL_PATH
:
5
};
function
callRequest
(
cmdId
)
{
switch
(
cmdId
)
{
case
pathCmds
.
ADD_STATION
:
var
x
=
parseFloat
(
document
.
getElementById
(
"
station_x
"
).
value
);
var
y
=
parseFloat
(
document
.
getElementById
(
"
station_y
"
).
value
);
var
angle
=
parseFloat
(
document
.
getElementById
(
"
station_angle
"
).
value
);
var
alertMessage
=
'
Add station failed, please correct the coordinate
'
break
;
case
pathCmds
.
DELETE_STATION
:
var
stations
=
document
.
getElementById
(
"
station_del
"
).
value
.
split
(
'
,
'
).
map
(
Number
);
var
alertMessage
=
'
Delete station failed, please correct the station number
'
break
;
case
pathCmds
.
ADD_PATH
:
var
station1
=
parseFloat
(
document
.
getElementById
(
"
path_a
"
).
value
);
var
station2
=
parseFloat
(
document
.
getElementById
(
"
path_b
"
).
value
);
var
stations
=
[
station1
,
station2
];
var
alertMessage
=
'
Add path failed, please correct the station number
'
break
;
case
pathCmds
.
DELETE_PATH
:
var
station1
=
parseFloat
(
document
.
getElementById
(
"
path_del_a
"
).
value
);
var
station2
=
parseFloat
(
document
.
getElementById
(
"
path_del_b
"
).
value
);
var
stations
=
[
station1
,
station2
];
var
alertMessage
=
'
Delete path failed, please correct the station number
'
break
;
case
pathCmds
.
ADD_FULL_PATH
:
var
stations
=
document
.
getElementById
(
"
plan_path_a
"
).
value
.
split
(
'
,
'
).
map
(
Number
);
var
alertMessage
=
'
Pathing path failed, please correct the pathing path
'
break
;
case
pathCmds
.
QUERY_POSE
:
var
alertMessage
=
'
Get Station failed, please try again
'
break
;
}
var
request
=
new
ROSLIB
.
ServiceRequest
({
cmd_id
:
cmdId
,
x
:
x
,
y
:
y
,
angle
:
angle
,
stations
:
stations
});
clientPath
.
callService
(
request
,
function
(
result
)
{
console
.
log
(
'
Service response:
'
,
result
);
if
(
result
.
result
)
{
if
(
cmdId
==
pathCmds
.
QUERY_POSE
)
{
document
.
getElementById
(
"
station_x
"
).
value
=
result
.
x
;
document
.
getElementById
(
"
station_y
"
).
value
=
result
.
y
;
document
.
getElementById
(
"
station_angle
"
).
value
=
result
.
angle
;
}
}
else
{
alert
(
alertMessage
);
}
});
}
document
.
getElementById
(
'
addStationButton
'
).
addEventListener
(
'
click
'
,
function
()
{
callRequest
(
pathCmds
.
ADD_STATION
);
});
document
.
getElementById
(
'
getStationButton
'
).
addEventListener
(
'
click
'
,
function
()
{
callRequest
(
pathCmds
.
QUERY_POSE
);
});
document
.
getElementById
(
'
delateStationButton
'
).
addEventListener
(
'
click
'
,
function
()
{
callRequest
(
pathCmds
.
DELETE_STATION
);
});
document
.
getElementById
(
'
addPath
'
).
addEventListener
(
'
click
'
,
function
()
{
callRequest
(
pathCmds
.
ADD_PATH
);
});
document
.
getElementById
(
'
deletePath
'
).
addEventListener
(
'
click
'
,
function
()
{
callRequest
(
pathCmds
.
DELETE_PATH
);
});
document
.
getElementById
(
'
planPath
'
).
addEventListener
(
'
click
'
,
function
()
{
callRequest
(
pathCmds
.
ADD_FULL_PATH
);
});
var
clientScan
=
new
ROSLIB
.
Service
({
ros
:
ros
,
name
:
'
/scan_control
'
,
serviceType
:
'
inventory_scan_msgs/srv/ScanControl
'
});
const
scanResults
=
{
NAVIGATING
:
0
,
NAVI_NOT_READY
:
1
,
NAVI_ERROR
:
2
,
NAVI_STOPPED
:
3
,
};
document
.
getElementById
(
'
startScan
'
).
addEventListener
(
'
click
'
,
function
()
{
const
buttons
=
document
.
querySelectorAll
(
'
button
'
);
var
request
=
new
ROSLIB
.
ServiceRequest
({
cmd_id
:
0
,
});
clientScan
.
callService
(
request
,
function
(
result
)
{
console
.
log
(
'
start scan control, response:
'
,
result
);
if
(
result
.
result
)
{
alert
(
"
inventory scan fail to start
"
);
}
else
{
buttons
.
forEach
(
btn
=>
{
if
(
btn
.
id
!==
'
stopScan
'
)
{
btn
.
disabled
=
true
;
}
});
}
});
});
document
.
getElementById
(
'
stopScan
'
).
addEventListener
(
'
click
'
,
function
()
{
const
buttons
=
document
.
querySelectorAll
(
'
button
'
);
var
request
=
new
ROSLIB
.
ServiceRequest
({
cmd_id
:
1
,
});
clientScan
.
callService
(
request
,
function
(
result
)
{
console
.
log
(
'
stop scan control, response:
'
,
result
);
});
buttons
.
forEach
(
btn
=>
{
btn
.
disabled
=
false
;
btn
.
style
.
backgroundColor
=
''
;
});
});
});
</script>
</body>
</html>
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment