Commit 48a82c22 authored by Léo-Paul Géneau's avatar Léo-Paul Géneau 👾

erp5_officejs_drone_simulator: add timestamp to position

See merge request !1897

* change property drone_dict into function getDroneDict
* add timestamp to getCurrentPosition return value
* add timestamp to drone_info
parent bd4eebcf
...@@ -121,7 +121,8 @@ var FixedWingDroneAPI = /** @class */ (function () { ...@@ -121,7 +121,8 @@ var FixedWingDroneAPI = /** @class */ (function () {
'longitude' : drone_position.longitude, 'longitude' : drone_position.longitude,
'yaw': drone.getYaw(), 'yaw': drone.getYaw(),
'speed': drone.getSpeed(), 'speed': drone.getSpeed(),
'climbRate': drone.getClimbRate() 'climbRate': drone.getClimbRate(),
'timestamp': drone_position.timestamp
}; };
_this._drone_dict_list[_this._id] = drone_info; _this._drone_dict_list[_this._id] = drone_info;
//broadcast drone info using internal msg //broadcast drone info using internal msg
......
...@@ -246,7 +246,7 @@ ...@@ -246,7 +246,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>1014.60714.57448.36454</string> </value> <value> <string>1014.60733.7318.44953</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -266,7 +266,7 @@ ...@@ -266,7 +266,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1709288420.35</float> <float>1709564488.61</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -64,11 +64,6 @@ var DroneManager = /** @class */ (function () { ...@@ -64,11 +64,6 @@ var DroneManager = /** @class */ (function () {
// swap y and z axis so z axis represents altitude // swap y and z axis so z axis represents altitude
return new BABYLON.Vector3(vector.x, vector.z, vector.y); return new BABYLON.Vector3(vector.x, vector.z, vector.y);
}; };
Object.defineProperty(DroneManager.prototype, "drone_dict", {
get: function () { return this._API._drone_dict_list; },
enumerable: true,
configurable: true
});
Object.defineProperty(DroneManager.prototype, "can_play", { Object.defineProperty(DroneManager.prototype, "can_play", {
get: function () { return this._canPlay; }, get: function () { return this._canPlay; },
set: function (value) { this._canPlay = value; }, set: function (value) { this._canPlay = value; },
...@@ -175,6 +170,9 @@ var DroneManager = /** @class */ (function () { ...@@ -175,6 +170,9 @@ var DroneManager = /** @class */ (function () {
); );
this._last_command_timestamp = this._API._gameManager._game_duration; this._last_command_timestamp = this._API._gameManager._game_duration;
}; };
DroneManager.prototype.getDroneDict = function () {
return this._API._drone_dict_list;
};
/** /**
* Returns the list of things a drone "sees" * Returns the list of things a drone "sees"
*/ */
...@@ -307,6 +305,7 @@ var DroneManager = /** @class */ (function () { ...@@ -307,6 +305,7 @@ var DroneManager = /** @class */ (function () {
this._controlMesh.position.z, this._controlMesh.position.z,
this._controlMesh.position.y this._controlMesh.position.y
); );
position.timestamp = this._API._gameManager._game_duration;
//Backward compatibility sanitation //Backward compatibility sanitation
position.x = position.latitude; position.x = position.latitude;
position.y = position.longitude; position.y = position.longitude;
......
...@@ -246,7 +246,7 @@ ...@@ -246,7 +246,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>1014.60733.7318.44953</string> </value> <value> <string>1014.65026.25145.27272</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -266,7 +266,7 @@ ...@@ -266,7 +266,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1709546292.39</float> <float>1709560433.33</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -318,7 +318,8 @@ ...@@ -318,7 +318,8 @@
{<br> {<br>
&nbsp;&nbsp;latitude: number, //in degrees<br> &nbsp;&nbsp;latitude: number, //in degrees<br>
&nbsp;&nbsp;longitude: number, //in degrees<br> &nbsp;&nbsp;longitude: number, //in degrees<br>
&nbsp;&nbsp;altitude: number //in meters<br> &nbsp;&nbsp;altitude: number, //in meters<br>
&nbsp;&nbsp;timestamp: number //in milliseconds<br>
}<br> }<br>
</p> </p>
...@@ -331,6 +332,36 @@ ...@@ -331,6 +332,36 @@
<div class="line"></div> <div class="line"></div>
<!-- getDroneDict -->
<h4 class="item-name" id="getDroneDict"><span>getDroneDict</span><span>: dictionary</span></h4>
<p class="item-descr">Access drones information dictionary. It contains one entry per drone:<br>
key-id: value-drone_dict<br>
{<br>
latitude: number, //latitude (in degrees)<br>
longitude: number, //longitude (in degrees)<br>
altitudeAbs: number, //altitude (in meters)<br>
altitudeRel: number, //altitude over ground (in meters)<br>
yaw: number, //yaw angle (in degrees)<br>
speed: number, //ground speed (in meters per second)<br>
climbRate: number, //climb rate (in meters per second)<br>
timestamp: number //timestamp (in milliseconds)<br>
}<br>
</p>
<h5 class="item-param-1">Example</h5>
<p class="item-example">
var leader = me.getDroneDict()[LEADER_ID];<br>
console.log("leader latitude:", leader.latitude);<br>
console.log("leader longitude:", leader.longitude);<br>
console.log("leader absolute altitude:", leader.altitudeAbs);<br>
console.log("leader relative altitude:", leader.altitudeRel);<br>
console.log("leader yaw angle:", leader.yaw);<br>
console.log("leader climb rate:", leader.climbRate);<br>
console.log("leader's position timestamp:", leader.timestamp);<br>
</p>
<div class="line"></div>
<!-- getDroneViewInfo --> <!-- getDroneViewInfo -->
<h4 class="item-name" id="getDroneViewInfo"><span>getDroneViewInfo</span><span>: void</span></h4> <h4 class="item-name" id="getDroneViewInfo"><span>getDroneViewInfo</span><span>: void</span></h4>
<p class="item-descr"> <p class="item-descr">
...@@ -607,28 +638,6 @@ ...@@ -607,28 +638,6 @@
<div class="line"></div> <div class="line"></div>
<!-- drone_dict -->
<h4 class="item-name" id="id"><span>drone_dict</span><span>: dictionary</span></h4>
<p class="item-descr">Access drones information dictionary. It contains one entry per drone:<br>
key-id: value-drone_dict<br>
{<br>
latitude: number, //latitude (in degrees)<br>
longitude: number, //longitude (in degrees)<br>
altitudeAbs: number //altitude (in meters)<br>
}<br>
</p>
<h5 class="item-param-1">Example</h5>
<p class="item-example">
var leader = me.drone_dict[LEADER_ID];<br>
console.log("leader latitude:", leader.latitude);<br>
console.log("leader longitude:", leader.longitude);<br>
console.log("leader absolute altitude:", leader.altitudeAbs);<br>
</p>
<div class="line"></div>
<!--<h3 class="category-name">Drone Physics Schema</h3> <!--<h3 class="category-name">Drone Physics Schema</h3>
<center><img src="assets/schema.png"></center> <center><img src="assets/schema.png"></center>
......
...@@ -244,7 +244,7 @@ ...@@ -244,7 +244,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>1014.48209.18178.31351</string> </value> <value> <string>1014.65292.62763.3464</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -264,7 +264,7 @@ ...@@ -264,7 +264,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1708710825.64</float> <float>1709564153.67</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -125,7 +125,8 @@ var FixedWingDroneAPI = /** @class */ (function () { ...@@ -125,7 +125,8 @@ var FixedWingDroneAPI = /** @class */ (function () {
'longitude' : drone_position.longitude, 'longitude' : drone_position.longitude,
'yaw': drone.getYaw(), 'yaw': drone.getYaw(),
'speed': drone.getSpeed(), 'speed': drone.getSpeed(),
'climbRate': drone.getClimbRate() 'climbRate': drone.getClimbRate(),
'timestamp': drone_position.timestamp
}; };
_this._drone_dict_list[_this._id] = drone_info; _this._drone_dict_list[_this._id] = drone_info;
//broadcast drone info using internal msg //broadcast drone info using internal msg
......
...@@ -240,7 +240,7 @@ ...@@ -240,7 +240,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>1014.60724.24572.64853</string> </value> <value> <string>1014.60733.7318.44953</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -260,7 +260,7 @@ ...@@ -260,7 +260,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1709289024.77</float> <float>1709562449.93</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -62,11 +62,6 @@ var DroneManager = /** @class */ (function () { ...@@ -62,11 +62,6 @@ var DroneManager = /** @class */ (function () {
// swap y and z axis so z axis represents altitude // swap y and z axis so z axis represents altitude
return new BABYLON.Vector3(vector.x, vector.z, vector.y); return new BABYLON.Vector3(vector.x, vector.z, vector.y);
}; };
Object.defineProperty(DroneManager.prototype, "drone_dict", {
get: function () { return this._API._drone_dict_list; },
enumerable: true,
configurable: true
});
Object.defineProperty(DroneManager.prototype, "can_play", { Object.defineProperty(DroneManager.prototype, "can_play", {
get: function () { return this._canPlay; }, get: function () { return this._canPlay; },
enumerable: true, enumerable: true,
...@@ -120,6 +115,9 @@ var DroneManager = /** @class */ (function () { ...@@ -120,6 +115,9 @@ var DroneManager = /** @class */ (function () {
enumerable: true, enumerable: true,
configurable: true configurable: true
}); });
DroneManager.prototype.getDroneDict = function () {
return this._API._drone_dict_list;
};
DroneManager.prototype.internal_start = function (initial_position) { DroneManager.prototype.internal_start = function (initial_position) {
this._API.internal_start(this); this._API.internal_start(this);
this._canPlay = true; this._canPlay = true;
...@@ -271,11 +269,13 @@ var DroneManager = /** @class */ (function () { ...@@ -271,11 +269,13 @@ var DroneManager = /** @class */ (function () {
DroneManager.prototype.getCurrentPosition = function () { DroneManager.prototype.getCurrentPosition = function () {
if (this._controlMesh) { if (this._controlMesh) {
// swap y and z axis so z axis represents altitude // swap y and z axis so z axis represents altitude
return this._API.getCurrentPosition( var position = this._API.getCurrentPosition(
this._controlMesh.position.x, this._controlMesh.position.x,
this._controlMesh.position.z, this._controlMesh.position.z,
this._controlMesh.position.y this._controlMesh.position.y
); );
position.timestamp = this._API._gameManager._game_duration;
return position;
} }
return null; return null;
}; };
......
...@@ -240,7 +240,7 @@ ...@@ -240,7 +240,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>1014.60716.53618.32563</string> </value> <value> <string>1014.65027.38618.31573</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -260,7 +260,7 @@ ...@@ -260,7 +260,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1709288704.17</float> <float>1709560536.57</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment