diff --git a/html/css/style.css b/html/css/style.css index 5db41f43b54606125098980385df237cd0812427..0a665f07379ea28ce4bf70591a4b106084889e69 100644 --- a/html/css/style.css +++ b/html/css/style.css @@ -1,5 +1,5 @@ body { - background-color: white; + background-color: DarkGrey; padding-top: 30px; height: 100%; } diff --git a/html/jury.html b/html/jury.html index a45d90ac82554a02d1854f01ceca1530a82939ca..20eac0bd79b64aedab2126f6bc081788811abf42 100644 --- a/html/jury.html +++ b/html/jury.html @@ -122,27 +122,67 @@ var set_building1_service_client = new ROSLIB.Service({ ros : ros, name : '/jury/set_building1', - serviceType : 'iri_adc_msgs/set_semaphore' //TODO change + serviceType : 'std_srvs/SetBool' }); var set_building2_service_client = new ROSLIB.Service({ ros : ros, name : '/jury/set_building2', - serviceType : 'iri_adc_msgs/set_semaphore' //TODO change + serviceType : 'std_srvs/SetBool' }); var set_building3_service_client = new ROSLIB.Service({ ros : ros, name : '/jury/set_building3', - serviceType : 'iri_adc_msgs/set_semaphore' //TODO change + serviceType : 'std_srvs/SetBool' }); var building_request = new ROSLIB.ServiceRequest({ - status : 0 + data : 0 + }); + + var start_rosbag_record_service_client = new ROSLIB.Service({ + ros : ros, + name : '/rosbag_record/start', + serviceType : 'std_srvs/Empty' + }); + + var stop_rosbag_record_service_client = new ROSLIB.Service({ + ros : ros, + name : '/rosbag_record/stop', + serviceType : 'std_srvs/Empty' + }); + + var rosbag_record_request = new ROSLIB.ServiceRequest({}); + + var rosbag_record_prefix_param = new ROSLIB.Param({ + ros : ros, + name : '/remote_rosbag_record/prefix' + }); + + var rosbag_record_is_recording_subscriber = new ROSLIB.Topic({ + ros : ros, + name : '/rosbag_record/is_recording', + messageType : 'std_msgs/Bool' }); + rosbag_record_is_recording_subscriber.subscribe(function(message) { + is_recording = message.data; + //console.log('Received message on ' + rosbag_record_is_recording_subscriber.name + ': ' + message.data); + //rosbag_record_is_recording_subscriber.unsubscribe(); + }); + + var challenge_xodr_param = new ROSLIB.Param({ + ros : ros, + name : '/iri_adc_gui_image_generator/xodr_file' + }); + + + + + var adc_jury_service_client = new ROSLIB.Service({ ros : ros, @@ -180,11 +220,25 @@ var iteration_timeout; var feedback_param_value; - var image_topic = "/iri_adc_gui_image_generator/image/image_raw"; + var date_string=""; + var time_string=""; + + var map_image_topic = "/iri_adc_gui_image_generator/image/image_raw"; + var front_camera_image_topic = "/adc_car/sensors/basler_camera/image_raw"; + var rear_camera_image_topic = "/adc_car/sensors/delock_camera/image_raw"; + var image_topic = map_image_topic; var image_type="mjpeg"; //mjpeg, ros_compressed var image_quality=100; //var image_size=100; var first=true; + var bgcolor; + var is_recording=false; + var rosbag_record_ready=true; + var ch0_xodr="adc/adc.xodr"; + var ch1_xodr="challenge1/challenge1.xodr"; + var ch2_xodr="challenge2/challenge2.xodr"; + var ch3_xodr="challenge3/challenge3.xodr"; + var ch4_xodr="challenge4/challenge4.xodr"; function update_team() { @@ -198,18 +252,39 @@ challenge = document.getElementById("challenge_input").value; localStorage.setItem('challenge', challenge); challenge_param.set(challenge); + set_challenge_xodr_param(challenge); load_goals_from_yaml(); } + + function set_challenge_xodr_param(challenge) + { + if(challenge==0) + challenge_xodr_param.set(ch0_xodr); + else if(challenge==1) + challenge_xodr_param.set(ch1_xodr); + else if(challenge==2) + challenge_xodr_param.set(ch2_xodr); + else if(challenge==3) + challenge_xodr_param.set(ch3_xodr); + else if(challenge==4) + challenge_xodr_param.set(ch4_xodr); + } function send_goal() { //load_goals_from_yaml(); //TODO: sync load. Now is async and done on input.onchange and at the beginning + + //save start date/time + var now = new Date(); + date_string = now.toLocaleDateString("es-ES"); + time_string = now.toLocaleTimeString("es-ES"); init_goal_msg(); action_goal.send(); clear_feedback(); add_feedback_line0("[GUI] START"); + start_rosbag_record(); document.getElementById("action_info").innerHTML = "Goal sent. Expecting feedback..."; document.getElementById("action_info").style.backgroundColor = 'yellow' ; @@ -231,8 +306,8 @@ { received_feedback=true; action_running=true; - document.getElementById("action_info").innerHTML = "Feedback received!"; - document.getElementById("action_info").style.backgroundColor = 'SeaGreen' ; + //document.getElementById("action_info").innerHTML = "Feedback received!"; + //document.getElementById("action_info").style.backgroundColor = 'SeaGreen' ; var feedback_new_line= msg.status; add_feedback_line(feedback_new_line); }); @@ -251,10 +326,11 @@ if(timer_running) startStop(); document.getElementById("action_info").innerHTML = "Action finished"; - document.getElementById("action_info").style.backgroundColor = 'white' ; + document.getElementById("action_info").style.backgroundColor = bgcolor; action_running=false; clearTimeout(feedback_timer); add_feedback_line0("[GUI] FINISHED"); + stop_rosbag_record(); save_feedback_file(); clearTimeout(iteration_timeout); } @@ -263,7 +339,7 @@ { action_goal.cancel(); document.getElementById("action_info").innerHTML = "Goal cancelled"; - document.getElementById("action_info").style.backgroundColor = 'white' ; + document.getElementById("action_info").style.backgroundColor = bgcolor; } function jury_mode() @@ -359,6 +435,59 @@ console.error("ERROR: couldn't contact service server!!!"); } } + + function start_rosbag_record() + { + if(is_recording) + { + console.error("rosbag record already recording"); + document.getElementById("action_info").innerHTML = "Already recording! Something went wrong"; + document.getElementById("action_info").style.backgroundColor = 'red' ; + stop_rosbag_record(); + } + + var rosbag_name = "bag_team_" + team + "_challenge_" + challenge + "_date_" + date_string.replace(/\//g, '_') + "_time_" + time_string.replace(/:/g, '_'); ; + rosbag_record_prefix_param.set(rosbag_name); + rosbag_record_ready=false; + document.getElementById('startStop').disabled=true; + start_rosbag_record_service_client.callService(rosbag_record_request, + function(result) + { + rosbag_record_ready=true; + document.getElementById('startStop').disabled=false; + }, + function(result) + { + rosbag_record_ready=true; + document.getElementById('startStop').disabled=false; + //console.warn("start rosbag record service server didn't respond, trying again"); + start_rosbag_record(); + }); + } + + function stop_rosbag_record() + { + if(!is_recording) + { + console.error("rosbag record not recording!"); + document.getElementById("action_info").innerHTML = "Was not recording! Something went wrong"; + document.getElementById("action_info").style.backgroundColor = 'red' ; + } + rosbag_record_ready=false; + document.getElementById('startStop').disabled=true; + stop_rosbag_record_service_client.callService(rosbag_record_request, + function(result) + { + rosbag_record_ready=true; + document.getElementById('startStop').disabled=false; + }, + function(result) + { + rosbag_record_ready=true; + document.getElementById('startStop').disabled=false; + console.error("stop rosbag record service server didn't respond!"); + }); + } function add_feedback_line0(text) { @@ -397,8 +526,17 @@ if(received_feedback) { received_feedback=false; - document.getElementById("action_info").innerHTML = "Feedback received!"; - document.getElementById("action_info").style.backgroundColor = 'SeaGreen' ; + if(is_recording) + { + document.getElementById("action_info").innerHTML = "Feedback received!"; + document.getElementById("action_info").style.backgroundColor = 'SeaGreen'; + } + else + { + document.getElementById("action_info").innerHTML = "Feedback received!. BUT NOT RECORDING!"; + document.getElementById("action_info").style.backgroundColor = 'red'; + } + //document.getElementById("action_info").style.backgroundColor = document.getElementById("body").style.backgroundColor; feedback_watchdog_timer(); } else @@ -492,10 +630,10 @@ function save_feedback_file() { var textbox = document.getElementById('feedback_text'); - var now = new Date(); - var date_string = now.toLocaleDateString("es-ES"); - var time_string = now.toLocaleTimeString("es-ES"); - var filename = "log_team_" + team + "_challenge_" + challenge + "_date_" + date_string + "_time_" + time_string; + // var now = new Date(); + // var date_string = now.toLocaleDateString("es-ES"); + // var time_string = now.toLocaleTimeString("es-ES"); + var filename = "log_team_" + team + "_challenge_" + challenge + "_date_" + date_string.replace(/\//g, '_') + "_time_" + time_string.replace(/:/g, '_'); download(textbox.value, filename, "text/plain" ); } @@ -512,26 +650,36 @@ document.getElementById('video_image').src =""; document.getElementById('video_image').src ="http://"+ip+":8080/stream?topic="+ image_topic + "&type="+image_type+"&quality="+image_quality; } + else + { + document.getElementById('video_image').src =""; + document.getElementById('video_image').src ="http://"+ip+":8080/stream?topic="+ image_topic + "&type="+image_type+"&quality="+image_quality; + } } else image_topic_param.set(image_topic); }); image_quality_param.get(function(value) + { + if(value!=null) { - if(value!=null) + var new_quality = value; + if(new_quality!=image_quality) { - var new_quality = value; - if(new_quality!=image_quality) - { - image_quality=new_quality; - document.getElementById('video_image').src =""; - document.getElementById('video_image').src ="http://"+ip+":8080/stream?topic="+ image_topic + "&type="+image_type+"&quality="+image_quality; - } + image_quality=new_quality; + document.getElementById('video_image').src =""; + document.getElementById('video_image').src ="http://"+ip+":8080/stream?topic="+ image_topic + "&type="+image_type+"&quality="+image_quality; } else - image_quality_param.set(image_quality); - }); + { + document.getElementById('video_image').src =""; + document.getElementById('video_image').src ="http://"+ip+":8080/stream?topic="+ image_topic + "&type="+image_type+"&quality="+image_quality; + } + } + else + image_quality_param.set(image_quality); + }); } function semaphore1_green() @@ -731,7 +879,7 @@ function building1_on() { - building_request.status=1; + building_request.data=true; set_building1_service_client.callService(building_request, function(result) { @@ -745,7 +893,7 @@ function building1_off() { - building_request.status=0; + building_request.data=false; set_building1_service_client.callService(building_request, function(result) { @@ -759,7 +907,7 @@ function building2_on() { - building_request.status=1; + building_request.data=true; set_building2_service_client.callService(building_request, function(result) { @@ -773,7 +921,7 @@ function building2_off() { - building_request.status=0; + building_request.data=false; set_building2_service_client.callService(building_request, function(result) { @@ -787,7 +935,7 @@ function building3_on() { - building_request.status=1; + building_request.data=true; set_building3_service_client.callService(building_request, function(result) { @@ -801,7 +949,7 @@ function building3_off() { - building_request.status=0; + building_request.data=false; set_building3_service_client.callService(building_request, function(result) { @@ -826,13 +974,46 @@ building2_off(); building3_off(); } - - + + function show_map_image() + { + if(image_topic!=map_image_topic) + { + image_topic=map_image_topic; + document.getElementById('video_image').src =""; + document.getElementById('video_image').src ="http://"+ip+":8080/stream?topic="+ image_topic + "&type="+image_type+"&quality="+image_quality; + image_topic_param.set(image_topic); + } + } + + function show_front_camera_image() + { + if(image_topic!=front_camera_image_topic) + { + image_topic=front_camera_image_topic; + document.getElementById('video_image').src =""; + document.getElementById('video_image').src ="http://"+ip+":8080/stream?topic="+ image_topic + "&type="+image_type+"&quality="+image_quality; + image_topic_param.set(image_topic); + } + } + + function show_rear_camera_image() + { + if(image_topic!=rear_camera_image_topic) + { + image_topic=rear_camera_image_topic; + document.getElementById('video_image').src =""; + document.getElementById('video_image').src ="http://"+ip+":8080/stream?topic="+ image_topic + "&type="+image_type+"&quality="+image_quality; + image_topic_param.set(image_topic); + } + } $(document).ready ( function () { + bgcolor = window.getComputedStyle(document.body, null).getPropertyValue('background-color'); + if ("team" in localStorage) { team = localStorage.getItem('team'); @@ -851,12 +1032,14 @@ challenge = localStorage.getItem('challenge'); document.getElementById("challenge_input").value = challenge; challenge_param.set(challenge); + set_challenge_xodr_param(challenge); } else { challenge=1; localStorage.setItem('challenge', challenge); challenge_param.set(challenge); + set_challenge_xodr_param(challenge); } load_goals_from_yaml(); @@ -904,7 +1087,7 @@ <input type="number" id="team_input" min="0" max="4" step="1" style="width: 2em" value="1" onchange="update_team()"> <!--<br>--> Challenge - <input type="number" id="challenge_input" min="0" max="5" step="1" style="width: 2em" value="1" onchange="update_challenge()"> + <input type="number" id="challenge_input" min="0" max="4" step="1" style="width: 2em" value="1" onchange="update_challenge()"> <br> Goals <span id="goals_info" > </span> </div> @@ -977,7 +1160,7 @@ <span id="semaphore4_info" ></span> </div> <div style="width: 50%"> - All                     + All <button class="btn btn-success btn-semaphore" id="semaphores_green" onclick="semaphores_green()">green</button> <button class="btn btn-danger btn-semaphore" id="semaphores_red" onclick="semaphores_red()">red</button> <button class="btn btn-dark btn-semaphore" id="semaphores_off" onclick="semaphores_off()">off</button> @@ -1003,13 +1186,17 @@ <button class="btn btn-dark btn-semaphore" id="building3_off" onclick="building3_off()">off</button> </div> <div style="width: 50%"> - All               + All <button class="btn btn-light btn-semaphore" id="buildings_on" onclick="buildings_on()">on</button> <button class="btn btn-dark btn-semaphore" id="buildings_off" onclick="buildings_off()">off</button> </div> </div> <hr> - Image <button class="btn btn-dark btn-semaphore" id="reload_image" onclick="reload_image()">Reload</button> + Image + <button class="btn btn-dark btn-semaphore" id="reload_image" onclick="reload_image()">Reload</button> + <button class="btn btn-dark btn-semaphore" id="map_image" onclick="show_map_image()">Map</button> + <button class="btn btn-dark btn-semaphore" id="front_camera_image" onclick="show_front_camera_image()">Front camera</button> + <button class="btn btn-dark btn-semaphore" id="rear_camera_image" onclick="show_rear_camera_image()">Rear camera</button> </div> <div style="width: 60%; text-align: center;"> <img class="image" id="video_image" src="" alt="map image"/> diff --git a/html/penalizations.html b/html/penalizations.html index 45640ba42f5f0ad50b84f74b9c845810edaef2fd..14213b576237064dc4c2ac1ce7a5fa14a20cb1db 100644 --- a/html/penalizations.html +++ b/html/penalizations.html @@ -203,7 +203,7 @@ var textbox = textbox + penalizations_log; - var filename = "penalizations_team_" + team + "_challenge_" + challenge + "_date_" + date_string + "_time_" + time_string; + var filename = "penalizations_team_" + team + "_challenge_" + challenge + "_date_" + date_string.replace(/\//g, '_') + "_time_" + time_string.replace(/:/g, '_'); download(textbox, filename, "text/plain" ); }, false);