This page has deprecated and will be archived. Please go to [[https://www.bitcraze.io/]].
This page is outdated, the Loco Positioning system is no longer in Early Access. Please see [[doc:lps:index|Loco positioning system]] for updated documentation.
====== Loco positioning system ======
The Loco Positioning system (LPS) project is a set of hardware and software designed to implement a local positioning system (LPS). Current hardware comprises one [[projects:lps:node|LPS Node]] and one [[projects:lps:deck|LPS Deck]]. Both are based on the Decawave DWM1000 chip.
===== System overview =====
The local positioning system is based on the [[http://www.decawave.com/|DecaWave]] DWM1000 module. The system consists of a number of anchors that are continuously pinged from the Crazyflie 2.0 deck that's based on the same module. The anchors are placed around the room at known positions.
===== Getting started =====
Currently the local positioning system base setup is to fly a Crazyflie 2.0 autonomously using two-way ranging with 4 to 6 anchors placed at known location.
This getting started documentation is intended to guide you from receiving your Loco Positioning Indoor Explorer Bundle to having an autonomous Crazyflie 2.0.
{{youtube>ZgH4bLZdq2A}}
==== Prerequisites ====
For the Loco Positioning System early access we are using [[http://ros.org|ROS]] on Ubuntu 16.04. So for the rest of this getting started I will assume that you have:
* One computer running Ubuntu 16.04
* One Indoor explorer bundle:
* One Crazyflie 2.0
* One Loco Positioning Deck
* Six Loco positioning nodes
* One Crazyradio
* Enough hardware to power the six nodes
* Either USB batteries or cable and 5V power block
It is possible to run Ubuntu 16.04 in a virtual machine but it is not tested.
==== Updating anchor firmware ====
Since The LPS is in early access, the software is being updated quite often so you should use the latest version of both the node (anchor) and the Crazyflie 2.0. See the flashing documentation for the [[projects:lps:node#building_and_flashing|node]].
==== Updating Crazyflie firmware ====
The Kalman filter used position Crazyflie in the LPS is not yet part of the default firmware so you need to compile the Crazyflie firmware with Kalman support activated. Clone or pull the latest version from Github and put the following lines in your tools/make/config.mk:
ESTIMATOR = kalman
Compile and flash the Crazyflie:
make clean
make
make cload
For "make cload" to work, you need to have the [[https://github.com/bitcraze/crazyflie-clients-python|Crazyflie client]] cloned and installed in the same folder as the Crazyflie firmware.
==== Addresses ====
The anchors are addressed from 1 to 6. You need to set your nodes in anchor mode with the correct address using the usb port. See the [[projects:lps:node#configuring_the_node|node product page]] for more information.
==== Anchor set-up ====
The LPS nodes can be configured in 3 different modes; tag, anchor or sniffer. By default they come pre-configured as anchors. The anchors are powered with 5V either through micro usb, power jack or screw terminal.
A nice way to power the anchors is to use usb power pack like we do here:
{{:projects:lps:dwm-setup.jpg|}}
Place the anchors at least 15 cm from the wall or ceiling, and preferably at least 2 meter apart.
We use 3d printed anchor-stands that can be found [[https://github.com/bitcraze/bitcraze-mechanics/blob/master/LPS-anchor-stand/anchor-stand.stl|here]]. It is good if the anchors are placed above and bellow the wanted flight altitude to maximize Z accuracy. Avoid placing all the anchor in the same plane.
Try to place the anchors around your working area. See [[https://en.wikipedia.org/wiki/Dilution_of_precision_(GPS)|Dilution Of Precision]].
The position in X/Y/Z of the anchor UWB antenna needs to be measured. To do so chose an origin (in a square/rectangular room one of the corners is a good choice), choose your axis to be a [[https://en.wikipedia.org/wiki/Right-hand_rule|right-handed coordinates]]. Finally you can measure the X/Y/Z position of the anchors in this coordinate system. Using a corner as origin means that you can use a laser-ranger against the walls to get a direct reading of the coordinates.
==== ROS ====
The ROS module for positioning with the LPS is available on Github: https://github.com/bitcraze/lps-ros. It is developed and tested on ROS Kinetic running on Ubuntu 16.04. As of now ROS is the only software environment in which the system has been tested.
To get started from a newly installed Ubuntu 16.04:
- Install ROS (full desktop): http://wiki.ros.org/kinetic/Installation/Ubuntu
- Install the ros joystick node with sudo apt-get install ros-kinetic-joy
- Create your workspace: http://wiki.ros.org/ROS/Tutorials/InstallingandConfiguringROSEnvironment#Create_a_ROS_Workspace
- Clone https://github.com/bitcraze/lps-ros and https://github.com/whoenig/crazyflie_ros in the workspace src folder
- Run //catkin_make// to build the packages
- Source the workspace //devel/setup.bash// again
- Run //rosdep install bitcraze_lps_estimator// to install dependencies
The positions of the anchors has to be entered in a configuration file. Create a file at //catkin_ws/src/lps-ros/data/anchor_pos.yaml// and enter your anchor coordinates. An example is present in the data folder:
n_anchors: 6
anchor0_pos: [ 0, 0, 1.85]
anchor1_pos: [ 0, 2, 1.85]
anchor2_pos: [ 4, 2, 1.85]
anchor3_pos: [ 4, 0, 1.85]
anchor4_pos: [1.3, 1, 1.85]
anchor5_pos: [2.6, 1, 1.85]
The positions are in meters, [x, y, z], from the origin.
Anchor0 in ROS will be the anchor with address 1. Anchor5 in ROS is then the anchor programmed with address 6. This is because the anchors are addressed from 1 while the ROS implementation starts at 0. The inconsistency will be fixed in the future by addressing anchors starting by 0.
When this file is configured, connect an XBox 360 (or compatible) gamepad, start the Crazyflie 2.0 and launch:
$ roslaunch bitcraze_lps_estimator dwm_loc_ekf_hover.launch uri:=radio://0/80/250K x:=3 y:=2.3 z:=1.0
Change the URI with your copter radio configuration. You will see the anchor position in RED so that you can verify there position make sense. The Crazyflie position will be shown in green, before flying you can verify that the position is roughly correct.
The X,Y,Z parameter will be the hovering point, make sure they make sense in your setup and it is better to place the Crazyflie just under this first setpoint to start with. The gamepad mapping is (this is for an X-Box gamepad):
| **Button** | **Action** |
| X | Take-off |
| A | Land |
| B | Emergency stop (this is the red button ;) |
| Left joystick | X/Y position |
| Right joystick | Altitude/Yaw setpoint |
Note that the YAW setpoint is not handled yet.
==== Using the system without ROS ====
There is an ongoing effort to implement all the functionality that is needed to use the Loco Positioning system without ROS, only using the Crazyflie client and lib. The support is not complete yet but there are a few useful tools.
=== Verifying system setup using the PC-client ===
The [[doc:crazyflie:client:pycfclient:index#loco_positioning|Loco Positioning tab in the PC-client]] can be used to validate anchor positions and to verify that the estimated position is reasonable.
Currently the anchor positions must be compiled into the Crazyflie firmware to make this work.
* Edit the src/deck/drivers/interface/locodeck.h file and set the LOCODECK_NR_OF_ANCHORS define to the number of anchors in your system.
* Edit the src/deck/drivers/src/locodeck.c file and set the appropriate anchor positions around line 90.
Rebuild the firmware and flash to the Crazyflie.
==== Controlling an autonomous Crazyflie from a python script ====
There is a python example to show how to send set-points to the Crazyflie: https://github.com/bitcraze/crazyflie-lib-python/blob/master/examples/autonomousSequence.py. Note that this script is also setting the anchor position so you have to make sure they are accurate.
==== Experimental TDoA mode ====
There has been some recent work on Flying Crazyflie using TDoA measurement. This is still very experimental and not tested a lot but is is already pushed in our github repos. To get your Crazyflie to fly with TDoA position estimation you need to:
- Update the Crazyflie firmware, LPS node firmware and lps-ros project to the latest master branch
- Compile and flash the crazyflie firmware with "ESTIMATOR = kalman" and "LPS_TDOA_ENABLE=1" in tools/make/config.mk
- Compile and flash the LPS nodes (anchors)
- Configure the LPS nodes in TDoA by opening the serial console and pressing "m" for mode and "3" for TDoA mode.
- Set the address of the LPS nodes **from 0 to 7**. TDoA works with up to 8 anchors and they much now be addressed from 0
The anchor placement is even more important with TDoA. The Crazyflie must fly within the 3D [[https://en.wikipedia.org/wiki/Convex_hull|convex hull]] formed by the anchors. For that reason it is easier to use 8 anchors. With 6 anchors you can place them forming 2 aligned triangle (one on the floor, one one the ceiling). Also since the anchor time are synchronized together it is very important that the anchors have direct line of sight between them.
You can then fly with the same launchfile as before. You can also try the new "dwm_loc_ekf_swarm_hover.launch" which is already setup for 5 Crazyflies. Just edit the top of the file to set the address and channel of your Crazyflies.