Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot execute multiple missions? #25

Open
mflores16 opened this issue Apr 4, 2016 · 0 comments
Open

Cannot execute multiple missions? #25

mflores16 opened this issue Apr 4, 2016 · 0 comments

Comments

@mflores16
Copy link

Hello All,

I am currently a senior Electrical Engineering major undertaking my senior design project. My project includes many things, but most relevantly performing autonomous navigation processes on the AR Drone 2.0. My team and I have chosen to utilize ardrone-autonomy libraries we found on GitHub; however we are having some small issues with it. We are primarily using the Mission module. Our strategy involves utilizing an external freestanding to determine whether the drone is in the permitted flight zone or not. A Java program writes an integer value depending on the drone's condition. Theoretically, we wish to have the drone flying straight ahead so long as it is in the permitted area. Once it is outside, the drone should turn and return to the area. The basic idea is to have the drone snake through the seating area in this manner. I have attached an image to this e-mail that depicts this. The cones in the image mark the allowed flight zone.

We are having trouble implementing this in our drone software. Our initial idea was to have different missions written up, one to fly straight a meter, one to turn left and return, and another to turn right and return. Then the program would essentially run through an infinite loop, reading the aforementioned file and executing the desired mission. We first attempted this without the infinite loop file reading aspect. That is, we simply wrote two different missions and tried to execute them sequentially. Only the first mission is executed before the program terminates. We have attempted a couple of different ways of writing the program in order to fix this, but we have not succeeded and don't quite understand what is happening. I have listed two of the many ways we have attempted solving this issue. Our issues could also be a result of our lack of Javascript expertise. That being said, we were wondering if you could provide any insight or advice as to how to solve these issues or in which way to proceed? Any help would be greatly appreciated. Thank you so much for your time, and we look forward to hearing from you.

Way 1:
`var df = require('dateformat')
var autonomy = require('ardrone-autonomy')
var arDrone = require('ar-drone')
var arDroneConstants = require('ar-drone/lib/constants')
var mission1 = autonomy.createMission()
var mission2 = autonomy.createMission()
var d_one = 0.3048
;

function navdata_option_mask(c) {
return 1 << c;
}

// From the SDK.
var navdata_options = (
navdata_option_mask(arDroneConstants.options.DEMO)
| navdata_option_mask(arDroneConstants.options.VISION_DETECT)
| navdata_option_mask(arDroneConstants.options.MAGNETO)
| navdata_option_mask(arDroneConstants.options.WIFI)
);

// Land on ctrl-c
var exiting = false;
process.on('SIGINT', function() {
if (exiting) {
process.exit(0);
} else {
console.log('Got SIGINT. Landing, press Control-C again to force exit.');
exiting = true;
mission1.control().disable();
mission1.client().land(function() {
process.exit(0);
});
}
});

// Connect and configure the drone
mission1.client().config('general:navdata_demo', true);
mission1.client().config('general:navdata_options', navdata_options);
mission1.client().config('video:video_channel', 1);
mission1.client().config('detect:detect_type', 12);

// Connect and configure the drone
mission2.client().config('general:navdata_demo', true);
mission2.client().config('general:navdata_options', navdata_options);
mission2.client().config('video:video_channel', 1);
mission2.client().config('detect:detect_type', 12);

// Log mission for debugging purposes
//mission1.log("mission-" + df(new Date(), "yyyy-mm-dd_hh-MM-ss") + ".txt");

// Plan first mission
mission1.ftrim()
.takeoff()
.zero()
.hover(1000)
.altitude(1)
.go({x:d_one, y:0}) // 1 ft
.hover(2000)
.land();

// Plan second mission
mission2.takeoff()
.zero()
.hover(1000)
.altitude(1)
.cw(90) // turn clockwise 90 degrees
.hover(2000)
.land();

// Execute first mission
mission1.run(function (err, result) {
if (err) {
console.trace("Oops, something bad happened: %s", err.message);
mission1.client().stop();
mission1.client().land();
} else {
console.log("We are done!");
process.exit(0);
}
});

// Execute second mission
mission2.run(function (err, result) {
if (err) {
console.trace("Oops, something bad happened: %s", err.message);
mission2.client().stop();
mission2.client().land();
} else {
console.log("We are done!");
process.exit(0);
}
});`

Way 2:
var df = require('dateformat')
var autonomy = require('ardrone-autonomy')
var arDrone = require('ar-drone')
var arDroneConstants = require('ar-drone/lib/constants')
var mission1 = autonomy.createMission()
var mission2 = autonomy.createMission()
var d_one = 0.3048
;

function navdata_option_mask(c) {
return 1 << c;
}

// From the SDK.
var navdata_options = (
navdata_option_mask(arDroneConstants.options.DEMO)
| navdata_option_mask(arDroneConstants.options.VISION_DETECT)
| navdata_option_mask(arDroneConstants.options.MAGNETO)
| navdata_option_mask(arDroneConstants.options.WIFI)
);

// Land on ctrl-c
var exiting = false;
process.on('SIGINT', function() {
if (exiting) {
process.exit(0);
} else {
console.log('Got SIGINT. Landing, press Control-C again to force exit.');
exiting = true;
mission1.control().disable();
mission1.client().land(function() {
process.exit(0);
});
}
});

// Connect and configure the drone
mission1.client().config('general:navdata_demo', true);
mission1.client().config('general:navdata_options', navdata_options);
mission1.client().config('video:video_channel', 1);
mission1.client().config('detect:detect_type', 12);

// Connect and configure the drone
mission2.client().config('general:navdata_demo', true);
mission2.client().config('general:navdata_options', navdata_options);
mission2.client().config('video:video_channel', 1);
mission2.client().config('detect:detect_type', 12);

// Log mission for debugging purposes
//mission1.log("mission-" + df(new Date(), "yyyy-mm-dd_hh-MM-ss") + ".txt");

// Plan first mission
mission1.ftrim()
.takeoff()
.zero()
.hover(1000)
.altitude(1)
.go({x:d_one, y:0}) // 1 ft
.hover(2000)
.land();

// Plan second mission
mission2.takeoff()
.zero()
.hover(1000)
.altitude(1)
.cw(90) // turn clockwise 90 degrees
.hover(2000)
.land();

// Execute first mission
mission1.run(function (err, result) {
if (err) {
console.trace("Oops, something bad happened: %s", err.message);
mission1.client().stop();
mission1.client().land();
} else {
// Execute second mission
mission2.run(function (err, result) {
if (err) {
console.trace("Oops, something bad happened: %s", err.message);
mission2.client().stop();
mission2.client().land();
} else {
console.log("We are done!");
process.exit(0);
}
});
}
});``

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant