Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
iri_adc_gui
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
mobile_robotics
ADC
ADC_2021
iri_adc_gui
Commits
45608385
Commit
45608385
authored
3 years ago
by
Fernando Herrero
Browse files
Options
Downloads
Patches
Plain Diff
Update slot timer and public page
parent
cbaf1735
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
html/countdown.js
+41
-16
41 additions, 16 deletions
html/countdown.js
html/index.html
+3
-2
3 additions, 2 deletions
html/index.html
html/public.html
+8
-296
8 additions, 296 deletions
html/public.html
with
52 additions
and
314 deletions
html/countdown.js
+
41
−
16
View file @
45608385
var
countdown_timer
;
var
countdown_running
=
false
;
var
countdown_paused
=
false
;
var
flash
=
0
;
var
remaining_time
=
0
;
function
startTimer
(
duration
,
display
)
{
...
...
@@ -16,6 +18,8 @@ function startTimer(duration, display)
localStorage
.
setItem
(
'
slot_timer_output
'
,
slot_time_string
);
display
.
textContent
=
slot_time_string
;
remaining_time
=
minutes
*
60
+
seconds
;
if
(
--
timer
<
0
)
{
timer
=
0
;
...
...
@@ -28,22 +32,28 @@ function startTimer(duration, display)
},
1000
);
}
function
slot_time
()
function
slot_time
_start_stop
()
{
if
(
!
countdown_running
)
{
var
time
=
document
.
getElementById
(
"
slot_time_input
"
).
value
;
var
time
;
if
(
!
countdown_paused
)
time
=
document
.
getElementById
(
"
slot_time_input
"
).
value
*
60
;
else
time
=
remaining_time
;
display
=
document
.
querySelector
(
'
#slot_timer_output
'
);
startTimer
(
time
,
display
);
document
.
getElementById
(
"
slot_time_button
"
).
innerHTML
=
"
PAUSE
"
;
document
.
getElementById
(
'
slot_time_button
'
).
style
.
backgroundColor
=
"
RoyalBlue
"
;
startTimer
(
time
,
display
);
countdown_running
=
true
;
}
else
{
countdown_running
=
false
;
clearTimeout
(
countdown_timer
);
document
.
getElementById
(
"
slot_time_button
"
).
innerHTML
=
"
START
"
;
document
.
getElementById
(
'
slot_time_button
'
).
style
.
backgroundColor
=
"
blue
"
;
document
.
getElementById
(
"
slot_time_button
"
).
innerHTML
=
"
RESUME
"
;
document
.
getElementById
(
'
slot_time_button
'
).
style
.
backgroundColor
=
"
RoyalBlue
"
;
countdown_paused
=
true
;
}
}
...
...
@@ -51,23 +61,38 @@ function slot_time()
function
slot_time_reset
()
{
clearTimeout
(
countdown_timer
);
document
.
getElementById
(
'
slot_timer_output
'
).
style
.
backgroundColor
=
"
white
"
;
document
.
getElementById
(
"
slot_time_button
"
).
innerHTML
=
"
START
"
;
document
.
getElementById
(
'
slot_time_button
'
).
style
.
backgroundColor
=
"
SeaGreen
"
;
remaining_time
=
document
.
getElementById
(
"
slot_time_input
"
).
value
*
60
;
countdown_paused
=
false
;
countdown_running
=
false
;
show_time
();
}
window
.
onload
=
function
()
function
show_time
()
{
var
duration
=
document
.
getElementById
(
"
slot_time_input
"
).
value
;
var
timer
=
duration
,
minutes
,
seconds
;
display
=
document
.
querySelector
(
'
#slot_timer_output
'
);
minutes
=
parseInt
(
timer
/
60
,
10
);
seconds
=
parseInt
(
timer
%
60
,
10
);
if
(
!
countdown_running
)
{
var
duration
=
document
.
getElementById
(
"
slot_time_input
"
).
value
*
60
;
var
timer
=
duration
,
minutes
,
seconds
;
display
=
document
.
querySelector
(
'
#slot_timer_output
'
);
minutes
=
parseInt
(
timer
/
60
,
10
);
seconds
=
parseInt
(
timer
%
60
,
10
);
minutes
=
minutes
<
10
?
"
0
"
+
minutes
:
minutes
;
seconds
=
seconds
<
10
?
"
0
"
+
seconds
:
seconds
;
minutes
=
minutes
<
10
?
"
0
"
+
minutes
:
minutes
;
seconds
=
seconds
<
10
?
"
0
"
+
seconds
:
seconds
;
var
slot_timer_string
=
minutes
+
"
:
"
+
seconds
;
var
slot_timer_string
=
minutes
+
"
:
"
+
seconds
;
localStorage
.
setItem
(
'
slot_timer_output
'
,
slot_timer_string
);
localStorage
.
setItem
(
'
slot_timer_output
'
,
slot_timer_string
);
display
.
textContent
=
minutes
+
"
:
"
+
seconds
;
display
.
textContent
=
minutes
+
"
:
"
+
seconds
;
}
}
window
.
onload
=
function
()
{
show_time
();
};
This diff is collapsed.
Click to expand it.
html/index.html
+
3
−
2
View file @
45608385
...
...
@@ -251,6 +251,7 @@
feedback_text
=
time
+
text
+
'


'
+
feedback_text
;
document
.
getElementById
(
"
feedback_text
"
).
innerHTML
=
feedback_text
;
localStorage
.
setItem
(
'
feedback_text_full
'
,
feedback_text
);
}
last_feedback_line
=
text
;
}
...
...
@@ -401,8 +402,8 @@
</div>
<div
class=
"column"
>
SLOT TIME
<input
type=
"number"
id=
"slot_time_input"
min=
"1"
max=
"60"
step=
"1"
style=
"width: 2.5em"
value=
"12"
>
<button
class=
"btn btn-success"
id =
"slot_time_button"
style=
"width:20%; height: 50px"
onclick =
"this.blur();slot_time()"
>
START
</button>
<input
type=
"number"
id=
"slot_time_input"
min=
"1"
max=
"60"
step=
"1"
style=
"width: 2.5em"
value=
"12"
onchange=
"show_time()"
>
<button
class=
"btn btn-success"
id =
"slot_time_button"
style=
"width:20%; height: 50px"
onclick =
"this.blur();slot_time
_start_stop
()"
>
START
</button>
<button
class=
"btn btn-danger"
id =
"slot_time_reset_button"
style=
"width:20%; height: 50px"
onclick =
"this.blur();slot_time_reset()"
>
RESET
</button>
<span
id=
"slot_timer_output"
>
00:00
</span>
</div>
...
...
This diff is collapsed.
Click to expand it.
html/public.html
+
8
−
296
View file @
45608385
...
...
@@ -23,7 +23,7 @@
<script>
document
.
title
=
"
ADC GUI
"
;
document
.
title
=
"
ADC GUI
PUBLIC
"
;
var
ip
;
ip
=
document
.
domain
;
...
...
@@ -35,311 +35,23 @@
var
ros
=
new
ROSLIB
.
Ros
();
ros
.
connect
(
'
ws://
'
+
ip
+
'
:9090
'
);
var
goals_param
=
new
ROSLIB
.
Param
({
ros
:
ros
,
name
:
'
/goals
'
});
var
adc_jury_service_client
=
new
ROSLIB
.
Service
({
ros
:
ros
,
name
:
'
/jury/set_mode
'
,
serviceType
:
'
iri_adc_msgs/jury_mode
'
});
var
srv_request
=
new
ROSLIB
.
ServiceRequest
({
enable
:
false
});
var
adc_jury_client
=
new
ROSLIB
.
ActionClient
({
ros
:
ros
,
serverName
:
'
/jury/challenge
'
,
actionName
:
'
iri_adc_msgs/adc_juryAction
'
});
var
goal_array_msg
=
new
ROSLIB
.
Message
(
{
});
var
team
;
var
challenge
;
var
feedback_text
=
""
;
var
last_feedback_line
=
""
;
var
i
=
0
;
var
service_answered
=
false
;
var
service_ok
=
false
;
var
received_feedback
=
false
;
var
feedback_timer
;
var
jury_mode_running
=
false
;
var
action_running
=
false
;
var
goals_loaded
=
false
;
function
update_team
()
{
team
=
document
.
getElementById
(
"
team_input
"
).
value
;
localStorage
.
setItem
(
'
team
'
,
team
);
}
function
update_challenge
()
{
challenge
=
document
.
getElementById
(
"
challenge_input
"
).
value
;
localStorage
.
setItem
(
'
challenge
'
,
challenge
);
}
function
send_goal
()
{
//load_goals_from_yaml(); //TODO: sync load. Now is async and done on input.onchange and at the beginning
init_goal_msg
();
action_goal
.
send
();
document
.
getElementById
(
"
action_info
"
).
innerHTML
=
"
Goal sent. Expecting feedback...
"
;
document
.
getElementById
(
"
action_info
"
).
style
.
backgroundColor
=
'
yellow
'
;
feedback_watchdog_timer
();
//action_running=true; //true when received feedback?
}
function
init_goal_msg
()
{
action_goal
=
new
ROSLIB
.
Goal
(
{
actionClient
:
adc_jury_client
,
goalMessage
:
goal_array_msg
}
);
action_goal
.
on
(
'
feedback
'
,
function
(
msg
)
{
received_feedback
=
true
;
action_running
=
true
;
document
.
getElementById
(
"
action_info
"
).
innerHTML
=
"
Feedback received!
"
;
document
.
getElementById
(
"
action_info
"
).
style
.
backgroundColor
=
'
green
'
;
var
feedback_new_line
=
msg
.
status
;
add_feedback_line
(
feedback_new_line
);
});
action_goal
.
on
(
'
result
'
,
function
(
result
)
{
if
(
action_running
)
{
finish_action
();
}
});
}
function
finish_action
()
{
if
(
timer_running
)
startStop
();
document
.
getElementById
(
"
action_info
"
).
innerHTML
=
"
Action finished
"
;
document
.
getElementById
(
"
action_info
"
).
style
.
backgroundColor
=
'
white
'
;
action_running
=
false
;
clearTimeout
(
feedback_timer
);
add_feedback_line
(
"
Finished
"
);
}
function
cancel_goal
()
{
action_goal
.
cancel
();
document
.
getElementById
(
"
action_info
"
).
innerHTML
=
"
Goal cancelled
"
;
document
.
getElementById
(
"
action_info
"
).
style
.
backgroundColor
=
'
white
'
;
}
function
jury_mode
()
{
if
(
!
jury_mode_running
)
jury_mode_enable
();
else
jury_mode_disable
();
}
function
jury_mode_enable
()
{
document
.
getElementById
(
"
service_info
"
).
innerHTML
=
"
Called service, waiting response...
"
;
document
.
getElementById
(
"
service_info
"
).
style
.
backgroundColor
=
'
yellow
'
;
document
.
getElementById
(
'
jury_mode_button
'
).
disabled
=
true
;
srv_request
.
enable
=
true
;
adc_jury_service_client
.
callService
(
srv_request
,
function
(
result
)
{
service_answered
=
true
;
service_ok
=
true
;
jury_mode_answered
();
},
function
(
result
)
{
service_answered
=
true
;
service_ok
=
false
;
jury_mode_answered
();
});
}
function
jury_mode_disable
()
{
document
.
getElementById
(
"
service_info
"
).
innerHTML
=
"
Called service server, waiting response...
"
;
document
.
getElementById
(
"
service_info
"
).
style
.
backgroundColor
=
'
yellow
'
;
document
.
getElementById
(
'
jury_mode_button
'
).
disabled
=
true
;
srv_request
.
enable
=
false
;
adc_jury_service_client
.
callService
(
srv_request
,
function
(
result
)
{
service_answered
=
true
;
service_ok
=
true
;
jury_mode_answered
();
},
function
(
result
)
{
service_answered
=
true
;
service_ok
=
false
;
jury_mode_answered
();
});
}
function
jury_mode_answered
()
{
document
.
getElementById
(
'
jury_mode_button
'
).
disabled
=
false
;
if
(
service_ok
)
{
service_ok
=
false
;
document
.
getElementById
(
"
service_info
"
).
innerHTML
=
"
Service responded
"
;
document
.
getElementById
(
"
service_info
"
).
style
.
backgroundColor
=
'
green
'
;
if
(
!
jury_mode_running
)
{
add_feedback_line
(
"
Jury mode enabled
"
);
jury_mode_running
=
true
;
document
.
getElementById
(
"
jury_mode_button
"
).
innerHTML
=
"
DISABLE
"
;
document
.
getElementById
(
'
jury_mode_button
'
).
style
.
backgroundColor
=
"
Red
"
;
if
(
document
.
getElementById
(
"
startStop
"
).
innerHTML
==
"
START
"
)
document
.
getElementById
(
'
startStop
'
).
disabled
=
true
;
}
else
{
add_feedback_line
(
"
Jury mode disabled
"
);
jury_mode_running
=
false
;
document
.
getElementById
(
"
jury_mode_button
"
).
innerHTML
=
"
ENABLE
"
;
document
.
getElementById
(
'
jury_mode_button
'
).
style
.
backgroundColor
=
"
RoyalBlue
"
;
if
(
document
.
getElementById
(
"
startStop
"
).
innerHTML
==
"
START
"
)
document
.
getElementById
(
'
startStop
'
).
disabled
=
false
;
}
}
else
{
document
.
getElementById
(
"
service_info
"
).
innerHTML
=
"
ERROR: couldn't contact service server!!!
"
;
document
.
getElementById
(
"
service_info
"
).
style
.
backgroundColor
=
'
red
'
;
console
.
error
(
"
ERROR: couldn't contact service server!!!
"
);
}
}
// function add_fake_feedback()
// {
// feedback_new_line=document.getElementById("fake_feedback_text").value+" "+i;
// i=i+1;
// add_feedback_line(feedback_new_line);
// }
function
add_feedback_line
(
text
)
{
if
(
text
!=
last_feedback_line
)
{
// var currentTime = new Date();
// var secs = Math.floor(currentTime.getTime()/1000);
// var nsecs = Math.round(1000000000*(currentTime.getTime()/1000-secs));
// var time = "["+secs+","+nsecs+"]: ";
var
time
=
"
[
"
+
time_string
+
"
]:
"
;
feedback_text
=
time
+
text
+
'


'
+
feedback_text
;
document
.
getElementById
(
"
feedback_text
"
).
innerHTML
=
feedback_text
;
}
last_feedback_line
=
text
;
}
function
clear_feedback
()
{
feedback_text
=
""
;
last_feedback_line
=
""
;
i
=
0
;
document
.
getElementById
(
"
feedback_text
"
).
innerHTML
=
feedback_text
;
}
function
feedback_watchdog_timer
()
{
feedback_timer
=
setTimeout
(
function
()
{
if
(
action_running
)
{
if
(
received_feedback
)
{
received_feedback
=
false
;
document
.
getElementById
(
"
action_info
"
).
innerHTML
=
"
Feedback received!
"
;
document
.
getElementById
(
"
action_info
"
).
style
.
backgroundColor
=
'
green
'
;
feedback_watchdog_timer
();
}
else
{
//clearTimeout(feedback_timer);
console
.
warn
(
"
WARN: feedback not received!
"
);
document
.
getElementById
(
"
action_info
"
).
innerHTML
=
"
WARN: feedback NOT received!
"
;
document
.
getElementById
(
"
action_info
"
).
style
.
backgroundColor
=
'
yellow
'
;
//TODO: what to do then?
feedback_watchdog_timer
();
}
}
},
2000
);
}
function
load_goals_from_yaml
()
{
document
.
getElementById
(
"
goals_info
"
).
innerHTML
=
"
Loading file
"
;
document
.
getElementById
(
"
goals_info
"
).
style
.
backgroundColor
=
'
yellow
'
;
goals_file
=
document
.
getElementById
(
"
goals_file
"
).
value
;
var
goals_from_yaml
;
$
.
ajax
(
{
url
:
goals_file
,
success
:
function
(
result
)
{
goals_from_yaml
=
jsyaml
.
load
(
result
);
goal_array_msg
=
new
ROSLIB
.
Message
(
{
goals
:
goals_from_yaml
});
goals_loaded
=
true
;
document
.
getElementById
(
"
goals_info
"
).
innerHTML
=
"
Loaded
"
;
document
.
getElementById
(
"
goals_info
"
).
style
.
backgroundColor
=
'
green
'
;
document
.
getElementById
(
'
startStop
'
).
disabled
=
false
;
},
error
:
function
(
xhr
,
ajaxOptions
,
thrownError
)
{
//alert(xhr.status);
//alert(thrownError);
document
.
getElementById
(
"
goals_info
"
).
innerHTML
=
"
Error loading file
"
;
document
.
getElementById
(
"
goals_info
"
).
style
.
backgroundColor
=
'
red
'
;
document
.
getElementById
(
'
startStop
'
).
disabled
=
true
;
console
.
error
(
"
ERROR: couldn't load goals
"
);
}
}
);
}
function
iteration
()
{
public_timer_timeout
=
setTimeout
(
function
()
{
var
public_time_string
=
localStorage
.
getItem
(
'
attempt_time
'
);
//console.log("time_string: ", time_string);
document
.
getElementById
(
"
timer_output
"
).
innerHTML
=
public_time_string
;
var
public_slot_time_string
=
localStorage
.
getItem
(
'
slot_time
'
);
document
.
getElementById
(
"
slot_timer_output
"
).
innerHTML
=
public_slot_time_string
;
document
.
getElementById
(
"
timer_output
"
).
innerHTML
=
localStorage
.
getItem
(
'
attempt_time
'
);
document
.
getElementById
(
"
slot_timer_output
"
).
innerHTML
=
localStorage
.
getItem
(
'
slot_timer_output
'
);
document
.
getElementById
(
"
feedback_text
"
).
innerHTML
=
localStorage
.
getItem
(
'
feedback_text_full
'
);
document
.
getElementById
(
"
team_id
"
).
innerHTML
=
localStorage
.
getItem
(
'
team
'
);
document
.
getElementById
(
"
challenge_id
"
).
innerHTML
=
localStorage
.
getItem
(
'
challenge
'
);
iteration
();
},
100
);
}
...
...
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