CrazySwarm with Loco Positioning Node

All discussions related to the Loco Positioning system
aesreal
Beginner
Posts: 22
Joined: Thu Mar 08, 2018 6:34 am

CrazySwarm with Loco Positioning Node

Post by aesreal »

Hi guys,

Has anyone tried using the CrazySwarm repo with UWBs/Loco Positioning Node, instead of vicon/optitrack? If so, any tips to help in configuring the setup?

I found this in their version of crazyflie_ros/crazyflie_driver/src in mocap_helper.cpp.

Code: Select all

#ifdef ENABLE_VICON
  else if (motionCaptureType == "vicon")
  {
    std::string hostName;
    nl.getParam("vicon_host_name", hostName);
    mocap = new libmotioncapture::MotionCaptureVicon(hostName,
      /*enableObjects*/ false,
      /*enablePointcloud*/ true);
  }
#endif
#ifdef ENABLE_OPTITRACK
  else if (motionCaptureType == "optitrack")
  {
    std::string localIP;
    std::string serverIP;
    nl.getParam("optitrack_local_ip", localIP);
    nl.getParam("optitrack_server_ip", serverIP);
    mocap = new libmotioncapture::MotionCaptureOptitrack(localIP, serverIP);
  }
#endif
#ifdef ENABLE_PHASESPACE
  else if (motionCaptureType == "phasespace")
  {
    std::string ip;
    int numMarkers;
    nl.getParam("phasespace_ip", ip);
    nl.getParam("phasespace_num_markers", numMarkers);
    std::map<size_t, std::pair<int, int> > cfs;
    cfs[231] = std::make_pair<int, int>(10, 11);
    mocap = new libmotioncapture::MotionCapturePhasespace(ip, numMarkers, cfs);
  }
Originally thought that the configuration might be just limited to vicon/optitrack, but the "phasespace" option looks promising. Anyone know what kind of setup does it lead to? Is it the Loco Positioning System?
arnaud
Bitcraze
Posts: 2538
Joined: Tue Feb 06, 2007 12:36 pm

Re: CrazySwarm with Loco Positioning Node

Post by arnaud »

I have not so much experience with Crazyswarm (I am currently implementing Qualisys support for it but have yet to successfully fly a swarm using Crazyswarm) and the main developers can correct me if they pass-by but this is my knowledge on the subject:

My understanding is that the main problem solved by Crazyswarm is the tracking of a big swarm of Quadcopters (and other robots) using a mocap system. This is done by implementing a tracker that tacks quads with the same marker configuration and the implementation of an efficient position communication protocol to send their position to each individual of the swarm (using broadcasting packets).

These two functionalities are not needed with LPS since the position is acquired in each Crazyflie (and the custom tracking is AFAIK not used by phasespace). The piece of code you copy-pasted is not going to be useful for LPS.

The other set of functionalities includes a controller and a high-level commander to be able to follow tight trajectories. These functionalities are either already merged or about to be merged into the Crazyflie master firmware. Anyway, I think the Crazyswarm Crazyflie firmware fork is now rebased on the official master, so LPS should work fine with it.

Also to be noted: I am not sure how useful the Crazyswarm controller is for LPS, the few tests I have done have resulted in instant flip at take-off. I am not sure of what I did wrong there but I suspect the controller is very tightly tuned and requires very good positioning quality.
aesreal
Beginner
Posts: 22
Joined: Thu Mar 08, 2018 6:34 am

Re: CrazySwarm with Loco Positioning Node

Post by aesreal »

Thanks for the reply!

I did not even get Crazyswarm to work and I'm not sure what I had did wrong (I do highly suspect that it is because there is a lack of input from either a Vicon or Optitrack system.) The figure8_canned.py script that they place in their guide just shows 3 dots (I'm using 3 Crazyflies for now) raising up. There is a "press enter or joystick" thing on the command line, but after following their instructions nothing happens lol. Also ran the hover_swarm.launch and tried again but nothing happened. Quite sure that I got their complicated installation done right with their build script.

The thing I'm trying to do here is the controlling of a big swarm of Quadcopters, but I guess Crazyswarm's system is not really suitable for me because it is an expensive solution to implement (Vicon, Optitrack). For now I've reverted back to the original Crazyflie Libraries and would start working from there, at least until I figure out how to use Crazyswarm.

The issue now is that the Crazyflies are hovering unstably using the original files, which is something that is not seen in the Crazyswarm demo videos. In those videos, you could see the Crazyflies being launched shakily and slowly becoming more stable before the next commands are pushed out. I'm not sure if PID is being implemented on the Crazyflies, and if they are an appropriate form of control here, but if not I guess that is where I'm heading towards next.
arnaud
Bitcraze
Posts: 2538
Joined: Tue Feb 06, 2007 12:36 pm

Re: CrazySwarm with Loco Positioning Node

Post by arnaud »

How unstable is unstable?

The reason Crazyswarm is using expensive motion capture system is that these system are ridiculously precise (we can measure how much the floor of our office bends with our Qualisys system) and fast. You usually get sub-millimeter precision at 100Hz with a mocap system.

LPS is more noisy and less precise, but much cheaper and using radio that can have advantages (if there is sun shinning through the windows, our mocap becomes un-usable, there might be way to solve it but our current fix is to close the blinds ....). So I am not surprised that you are not observing similar performance between the Crazyswarm video and experiments with the LPS.

The crazyflie is currently using a simple PID controller. Using better controllers (like the one from Crazyswarm or the one from Mike at ETH that I used in a demo at Fosdem 17) helps a lot the dynamic performance. This is things that are currently being merged-in but everything is open-source so if you feel like tweaking controllers you can test them. If you want I can try to find the Mike's controller code, we have it in a branch somewhere, it is a Quaternion-based controller and it is a bit simpler to tune than the Crazyswarm controller.
aesreal
Beginner
Posts: 22
Joined: Thu Mar 08, 2018 6:34 am

Re: CrazySwarm with Loco Positioning Node

Post by aesreal »

Sorry for the slow reply,

Have decided to dump Crazyswarm altogether. Although it is precise, it is just too expensive of a solution.

How unstable is unstable? It is unstable when changing positions, from a single waypoint to another. Lets say I have 2 waypoints. When it goes to waypoint 2 from waypoint 1, sometimes it would overshot. Although it would return, it would start being shaky and all. Sometimes it would go there smoothly and there would be no vibrations. Sometimes when it overshot too much, it would start flying in a random elliptical motion before reaching waypoint 2. It sounds like a PID tuning issue, so although we have already tested each CrazyFlie for their PID values, we went back to retune every CrazyFlie again. And it did turn out to be an issue. At least for now, the CrazyFlie does not do that random elliptical motion anymore.

I'm indeed using LPS because its cheaper. Right now, the unstableness that still persists is when it has to fly in things like figure 8, from the flowSequence.py script. Instead of just doing a figure8, it would start to hover up and down while moving, sort of like the horses in a carousell or merry-go-round.

It would be great if there is a link to the Quaternion-based controller! It would definitely be good for studying and perhaps be even better for the PID control. Thanks in advance!
arnaud
Bitcraze
Posts: 2538
Joined: Tue Feb 06, 2007 12:36 pm

Re: CrazySwarm with Loco Positioning Node

Post by arnaud »

Hi,

The position PID controller is not good at all at following trajectory. What you are describing correspond to my experience as well.

To follow trajectory you need to be able to send velocity and maybe even acceleration setpoints, this way you can get the Crazyflies to follow the trajectory much better. By sending a series of position setpoint to the PID controller, the controller tends to oscillate around the setpoint which makes things like circle looks very bad. Sending position, velocity and acceleration allows to keep the Crazyflie in the intended state during the trajectory, we have done some nice quick circles that way: https://www.youtube.com/watch?v=yTf_2lmjLYM. In this video we are running the LPS in TWR mode, I would expect the new TDoA mode to allow for similar flight.

The branch for ICRA that included a merge of the quaternion controller is there: https://github.com/bitcraze/crazyflie-f ... ller_new.c. The branch is old-ish but I am not expecting it to be so hard to move it to a recent firmware. In this branch the setpoint is generated internally: https://github.com/bitcraze/crazyflie-f ... #L314-L328 the index on x,y,z represents position, velocity, acceleration. On a more recent firmware, there is a generic commander packet that already contains the full state so maybe this can be used instead.
aesreal
Beginner
Posts: 22
Joined: Thu Mar 08, 2018 6:34 am

Re: CrazySwarm with Loco Positioning Node

Post by aesreal »

Hi arnaud,

Thank you so much for all the comprehensive reply!

That helix is insane! Very cool!

I'll go test all of these out and see what we get.
percy.jaiswal
Beginner
Posts: 14
Joined: Sun Apr 01, 2018 4:23 am

Re: CrazySwarm with Loco Positioning Node

Post by percy.jaiswal »

Sir, are you using Flow Deck also (along with LPS) in this Youtube demo?
arnaud
Bitcraze
Posts: 2538
Joined: Tue Feb 06, 2007 12:36 pm

Re: CrazySwarm with Loco Positioning Node

Post by arnaud »

No, only the LPS. There will be some problem doing the same with the flow since in this demo the Crazyflie was tilted quite a lot and the flow sensor will then not be oriented towards the ground which will affect tracking.
percy.jaiswal
Beginner
Posts: 14
Joined: Sun Apr 01, 2018 4:23 am

Re: CrazySwarm with Loco Positioning Node

Post by percy.jaiswal »

Thank you arnaud, I was expecting this to be the case. Only reason I asked was coz in some thread, I was reading that without flowdeck, we get fairly noisy z (height) data. But trajectory shown in video seems to be very precise.

I had couple of follow on questions
1. Is there a separate firmware for Crazyswarm, other than crazyflie firmware in your github repository? Reason for asking this coz I have seen you point to some other github repository in one of the forum thread. Some research group / university repo.
2. In SwarmSequence example, you are controlling 10 Cfs at maximum speed of 2M using cflib, just double checking, can a single crazyradio PA support 10 Cfs at that speed?
3. Can I double the number of controlled CFs by using 2 radios on same PC, perhaps in same script?

Thanks in advance
Post Reply