-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
64 changed files
with
2,901 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
contract motherbase { | ||
address creator; | ||
int256 public homebaseLongitude; | ||
int256 public homebaseLatitude; | ||
mapping (address => bool) droneActiveOf; | ||
address public airwayAdminAddr; | ||
|
||
|
||
modifier creatorCheck { if (msg.sender == creator) _ } | ||
|
||
/* Functions */ | ||
function motherbase(int256 _homebaseLongitude, | ||
int256 _homebaseLatitude, | ||
address _airwayAdminAddr) { | ||
creator = msg.sender; | ||
homebaseLatitude = _homebaseLatitude; | ||
homebaseLongitude = _homebaseLongitude; | ||
airwayAdminAddr = _airwayAdminAddr; | ||
} | ||
|
||
function setDrone(address _droneAddr) creatorCheck returns(bool result) { | ||
droneActiveOf[_droneAddr] = true; | ||
result true; | ||
} | ||
|
||
function inactiveDrone(address _droneAddr) creatorCheck returns(bool result) { | ||
droneActiveOf[_droneAddr] = false; | ||
result true; | ||
} | ||
|
||
|
||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
ROS/aira_ros_bridge/lib/msg/dron_common_msgs/RouteRequest.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// Init libs | ||
var ROSLIB = require('roslib'); | ||
var Helpers = require('../helpers'); | ||
var SatFix = require('../dron_common_msgs/SatFix'); | ||
// Solidity message definition | ||
var bytecode = '606060405260405161016f38038061016f83398101604052805160805191019060605182516000805482825581805290927f290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e563918201929190608001821560bc579160200282015b8281111560bc5782518254600160a060020a03191617825560209290920191600191909101906066565b505080600160006101000a81548163ffffffff021916908302179055505050608c806100e36000396000f35b5060909291505b8082111560df578054600160a060020a031916815560010160c3565b509056606060405260e060020a6000350463af640d0f81146024578063b8a24252146032575b005b608260015463ffffffff1681565b60826004356000805482908110156002575080527f290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e563015473ffffffffffffffffffffffffffffffffffffffff1681565b6060908152602090f3'; | ||
var abi = [{"constant":true,"inputs":[],"name":"id","outputs":[{"name":"","type":"uint32"}],"type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"checkpoints","outputs":[{"name":"","type":"address"}],"type":"function"},{"inputs":[{"name":"_checkpoints","type":"address[]"},{"name":"_id","type":"uint32"}],"type":"constructor"}]; | ||
// JSON message converter | ||
function eth2json(address, web3) { | ||
var msg = Helpers.getContract(abi, address, web3); | ||
var route = []; | ||
var ix = 0; | ||
while (msg.checkpoints(ix) != "0x") | ||
route.push(SatFix.eth2json(msg.checkpoints(ix++), web3)); | ||
return { | ||
// Message fields START | ||
id: parseInt(msg.id()), | ||
checkpoints: route | ||
// Message fields END | ||
} | ||
} | ||
function mkArray(arr, obj, web3, fn) { | ||
var count = 0; | ||
arr.forEach(function(e, i, a) { | ||
obj.ros2eth(e, web3, function(err, r) { | ||
arr[i] = r; | ||
++count; | ||
}); | ||
}); | ||
while (count != arr.length); | ||
return arr; | ||
} | ||
// Setup exports | ||
module.exports = { | ||
/* | ||
* This message converter should be autogenerated from | ||
* ROS message definition language. | ||
* TODO: converter implementation. | ||
*/ | ||
abi: abi, | ||
eth2json: eth2json, | ||
eth2ros: function(msg, web3) {return new ROSLIB.Message(eth2json(msg, web3))}, | ||
ros2eth: function(msg, web3, fun) { | ||
var id = msg.id; | ||
|
||
mkArray(msg.checkpoints, SatFix, web3, function(checkpoints) { | ||
var args = [id, checkpoints]; | ||
Helpers.newContract(abi, bytecode, web3, args, fun); | ||
}); | ||
} | ||
} |
62 changes: 62 additions & 0 deletions
62
ROS/aira_ros_bridge/lib/msg/dron_common_msgs/RouteResponse.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// Init libs | ||
var ROSLIB = require('roslib'); | ||
var Helpers = require('../helpers'); | ||
var SatFix = require('../dron_common_msgs/SatFix'); | ||
// Solidity message definition | ||
var bytecode = '606060405260405161019038038061019083398101604052805160805160a051919290910160a05160008054610100850264ffffffff001960ff1990921687179190911617815582516001805482825592819052927fb10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf69283019290608001821560c2579160200282015b8281111560c25782518254600160a060020a03191617825560209290920191908401906089565b505050505060a8806100e86000396000f35b5060b09291505b8082111560e4578054600160a060020a0319168155830160c9565b509056606060405260e060020a6000350463af640d0f8114602e578063b980c78f146042578063c1991219146093575b005b609e60005463ffffffff6101009091041681565b609e600435600180548290811015600257506000527fb10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf6015473ffffffffffffffffffffffffffffffffffffffff1681565b609e60005460ff1681565b6060908152602090f3'; | ||
var abi = [{"constant":true,"inputs":[],"name":"id","outputs":[{"name":"","type":"uint32"}],"type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"route","outputs":[{"name":"","type":"address"}],"type":"function"},{"constant":true,"inputs":[],"name":"valid","outputs":[{"name":"","type":"bool"}],"type":"function"},{"inputs":[{"name":"_valid","type":"bool"},{"name":"_id","type":"uint32"},{"name":"_route","type":"address[]"}],"type":"constructor"}]; | ||
// JSON message converter | ||
function eth2json(address, web3) { | ||
var msg = Helpers.getContract(abi, address, web3); | ||
var route = []; | ||
var val = true; | ||
var ix = 0; | ||
while (msg.route(ix) != "0x") | ||
route.push(SatFix.eth2json(msg.route(ix++), web3)); | ||
if (msg.valid() == "False") | ||
val = false; // TODO: check | ||
return { | ||
// Message fields START | ||
valid: val, | ||
id: parseInt(msg.id()), | ||
route: route | ||
// Message fields END | ||
} | ||
} | ||
function mkArray(arr, obj, web3, fn) { | ||
var count = 0; | ||
arr.forEach(function(e, i, a) { | ||
console.log("Make new message: " + i); | ||
obj.ros2eth(e, web3, function(err, r) { | ||
arr[i] = r; | ||
++count; | ||
console.log("Message created: " + i); | ||
}); | ||
}); | ||
setTimeout(function cb() { | ||
if (count == arr.length) | ||
fn(arr); | ||
else | ||
setTimeout(cb, 1000); | ||
}, 1000); | ||
} | ||
// Setup exports | ||
module.exports = { | ||
/* | ||
* This message converter should be autogenerated from | ||
* ROS message definition language. | ||
* TODO: converter implementation. | ||
*/ | ||
abi: abi, | ||
eth2json: eth2json, | ||
eth2ros: function(msg, web3) {return new ROSLIB.Message(eth2json(msg, web3))}, | ||
ros2eth: function(msg, web3, fun) { | ||
var valid = msg.valid; | ||
var id = msg.id; | ||
|
||
mkArray(msg.route, SatFix, web3, function(route) { | ||
var args = [valid, id, route]; | ||
Helpers.newContract(abi, bytecode, web3, args, fun); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// Init libs | ||
var ROSLIB = require('roslib'); | ||
var Helpers = require('../helpers'); | ||
// Solidity message definition | ||
var bytecode = '6060604052604051606080608683395060c06040525160805160a05160009283556001919091556002556050908190603690396000f3606060405260e060020a60003504634fd7d76a8114602e578063589af69c146036578063d906896a14603e575b005b604660005481565b604660015481565b604660025481565b6060908152602090f3'; | ||
var abi = [{"constant":true,"inputs":[],"name":"latitude","outputs":[{"name":"","type":"int256"}],"type":"function"},{"constant":true,"inputs":[],"name":"longitude","outputs":[{"name":"","type":"int256"}],"type":"function"},{"constant":true,"inputs":[],"name":"altitude","outputs":[{"name":"","type":"int256"}],"type":"function"},{"inputs":[{"name":"_latitude","type":"int256"},{"name":"_longitude","type":"int256"},{"name":"_altitude","type":"int256"}],"type":"constructor"}]; | ||
// JSON message converter | ||
function eth2json(address, web3) { | ||
var msg = Helpers.getContract(abi, address, web3); | ||
return { | ||
// Message fields START | ||
latitude: parseInt(msg.latitude()) / 1000000.0, | ||
longitude: parseInt(msg.longitude()) / 1000000.0, | ||
altitude: parseInt(msg.altitude()) / 1000000.0 | ||
// Message fields END | ||
}; | ||
} | ||
// Setup exports | ||
module.exports = { | ||
/* | ||
* This message converter should be autogenerated from | ||
* ROS message definition language. | ||
* TODO: converter implementation. | ||
*/ | ||
abi: abi, | ||
eth2json: eth2json, | ||
eth2ros: function(address, web3) {return new ROSLIB.Message(eth2json(address, web3))}, | ||
ros2eth: function(msg, web3, fun) { | ||
var latitude = msg.latitude * 1000000; | ||
var longitude = msg.longitude * 1000000; | ||
var altitude = msg.altitude * 1000000; | ||
var args = [latitude, longitude, altitude]; | ||
Helpers.newContract(abi, bytecode, web3, args, fun); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Init libs | ||
var ROSLIB = require('roslib'); | ||
var Helpers = require('../helpers'); | ||
// Solidity data | ||
var bytecode = '606060405260405160208060638339506080604052516000805463ffffffff1916821790555060328060316000396000f3606060405260e060020a600035046373d4a13a8114601a575b005b602860005463ffffffff1681565b6060908152602090f3'; | ||
var abi = [{"constant":true,"inputs":[],"name":"data","outputs":[{"name":"","type":"uint32"}],"type":"function"},{"inputs":[{"name":"_data","type":"uint32"}],"type":"constructor"}]; | ||
// JSON serialization | ||
function eth2json(address, web3) { | ||
var msg = Helpers.getContract(abi, address, web3); | ||
return {data: parseInt(msg.data())} | ||
} | ||
// Setup exports | ||
module.exports = { | ||
/* | ||
* This message converter should be autogenerated from | ||
* ROS message definition language. | ||
* TODO: converter implementation. | ||
*/ | ||
abi: abi, | ||
eth2json: eth2json, | ||
eth2ros: function(msg, web3) {return new ROSLIB.Message(eth2json(msg, web3))}, | ||
ros2eth: function(msg, web3, fun) { | ||
// | ||
var msg_data = msg.data; | ||
var args = [msg_data]; | ||
// | ||
Helpers.newContract(abi, bytecode, web3, args, fun); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
if (process.argv.length < 3) | ||
console.log("Usage: " + process.argv[0] + " " + process.argv[1] + " ADDRESS"); | ||
console.log("Usage: " + process.argv[0] + " " + process.argv[1] + " CONTRACT_ADDRESS BRIDGE_PORT"); | ||
else | ||
require('./lib/aira_bridge')(process.argv[2]) | ||
require('./lib/aira_bridge')(process.argv[2], process.argv[3]) |
Oops, something went wrong.