Skip to content

The ultimate node.js library for controlling Bitcraze Crazyflie 2.0 drones

License

Notifications You must be signed in to change notification settings

michaelgira23/swarms

Repository files navigation

swarms

The ultimate node.js client for controlling Bitcraze Crazyflie 2.0 drones

npm npm Travis Dependency Status Dev Dependency Status

Motive

There were too many outdated and undocumented node.js libraries out there for programming Crazyflies. This package's goal is to fix that.

Prerequisites

Crazyflie Firmware

This package assumes you have the latest version of the Crazyflie firmware.

Crazyradio Driver on Windows

If on a Windows machine, look on the Bitcraze wiki for instructions to install the correct driver onto your Crazyradio. You do not need to do this on macOS or Linux!

Installation

This package's main dependency is node-usb. Refer to its installation directions for any help installing it on your operating system.

$ npm install swarms

Note: On Windows, you may get errors installing the node-usb package like the following: you may fail to install the node-usb package getting errors like:

error C2011: 'timespec': 'struct' type redefinition

You can fix this by following the directions here.

Usage

The following script moves the drone's propellers. More examples are located in the /examples directory.

const { Crazyradio } = require('swarms');

const radio = new Crazyradio();

// Because you can only use `await` within an async function...
main();
async function main() {
	try {
		await radio.init();
		const drones = await radio.findDrones();

		if (drones.length < 1) {
			throw 'Could not find any drones!';
		}

		const drone = await radio.connect(drones[0]);

		await drone.commander.setpoint({
			roll  : 0,
			yaw   : 0,
			pitch : 0,
			thrust: 32500
		});

	} catch (err) {
		console.log('Uh oh!', err);
		await radio.close();
	}
}

Documentation

Check out the repository documentation for information, tutorials, and more!

Troubleshooting

Got a problem? Refer to the troubleshooting page in the documentation. If that doesn't help, create an issue.

Contributing

Encounter a bug or have an idea for a new feature? Open up an issue! Pull requests also welcome! Check out the Contributing Guide for more details.

License

This project is under the MIT License.

Acknowledgments

Special thanks to the following people, whose libraries were used as a reference: