Skip to content

Commit ab149a0

Browse files
committed
Added route scheduling.
1 parent 7109bde commit ab149a0

File tree

3 files changed

+30
-8
lines changed

3 files changed

+30
-8
lines changed

drone_employee/doc/scheduler.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Simple scheduling for Drone Employee routes
2+
3+
The case is making periodicaly routes with autonomous
4+
decentralized administrative registration and releasing of route.
5+
6+
## Scheduler
7+
8+
For this case try to use UNIX Cron daemon and `run_route.js` script.
9+
Sample **crontab** file below:
10+
11+
0 * * * * node /path/to/run_route.js 0x7f43839b8e4c39d811da781ab191e885ca2b9508 '[[65.12, -39.17, 10], [65.11, -39.17, 10]]'
12+
13+
* **run_route.js** script takes two arguments: *DroneEmployee* contract address and waypoint list in format [latitude, longitude, altitude];
14+
* the first five words is a crontab time format, in sample they says 'run every hour', detailed description available [there](https://en.wikipedia.org/wiki/Cron).
15+
16+
## Enviroment
17+
18+
**run_route.js** script require running *geth* or *eth* with enabled RPC port `8545`.
19+
20+
The scheduller communicates with standart DroneEmployee contract by ethereum node and can be run separately or on robot computer.
21+
22+

drone_employee/scripts/quad_controller.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def take_current(queue):
2020
return queue.get(True, None)
2121

2222
def quad_controller(route_queue, position_queue, arming_queue):
23-
flight_done_pub = Publisher('release', UInt32, queue_size=1)
23+
flight_done_pub = Publisher('remove', UInt32, queue_size=1)
2424
while not is_shutdown():
2525
# Take a route
2626
route = route_queue.get(True, None)

drone_employee/scripts/run_route.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ if (process.argv.length < 4) {
55

66
var address = process.argv[2];
77
var points = JSON.parse(process.argv[3]);
8-
var web3 = new require('web3')();
8+
var Web3 = require('web3');
9+
var web3 = new Web3();
910
web3.setProvider(new web3.providers.HttpProvider('http://localhost:8545'));
1011
var drone_employee_abi = [{"constant":false,"inputs":[{"name":"_response","type":"address"}],"name":"setRoute","outputs":[],"type":"function"},{"constant":false,"inputs":[{"name":"_route_id","type":"uint32"}],"name":"flightDone","outputs":[],"type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"subscribers","outputs":[{"name":"","type":"address"}],"type":"function"},{"constant":false,"inputs":[{"name":"latitude","type":"int256"},{"name":"longitude","type":"int256"},{"name":"altitude","type":"int256"}],"name":"addCheckpoint","outputs":[],"type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"checkpoints","outputs":[{"name":"","type":"address"}],"type":"function"},{"constant":false,"inputs":[],"name":"initROS","outputs":[],"type":"function"},{"constant":false,"inputs":[],"name":"takeFlight","outputs":[],"type":"function"},{"constant":false,"inputs":[{"name":"_name","type":"string"},{"name":"_type","type":"string"}],"name":"mkPublisher","outputs":[{"name":"","type":"address"}],"type":"function"},{"constant":false,"inputs":[{"name":"_name","type":"string"},{"name":"_type","type":"string"},{"name":"_callback","type":"address"}],"name":"mkSubscriber","outputs":[{"name":"","type":"address"}],"type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"publishers","outputs":[{"name":"","type":"address"}],"type":"function"},{"inputs":[{"name":"_controller","type":"address"}],"type":"constructor"}];
1112

1213
var contract = web3.eth.contract(drone_employee_abi).at(address);
13-
points.map(function(pt) {
14-
contract.addCheckpoint.sendTransaction({from: web3.eth.accounts[0]},
15-
pt[0] * 1000000,
16-
pt[1] * 1000000,
17-
pt[2] * 1000000);
14+
points.forEach(function(p, i, arr) {
15+
contract.addCheckpoint(
16+
p[0] * 1000000, p[1] * 1000000, p[2] * 1000000,
17+
{from: web3.eth.accounts[0], gas: 3000000});
1818
});
19-
contract.takeFlight.sendTransaction({from: web3.eth.accounts[0]});
19+
contract.takeFlight({from: web3.eth.accounts[0], gas: 3000000});

0 commit comments

Comments
 (0)