blandry / crazyflie-tools

A collection of tools to develop controllers for the Crazyflie using Drake
MIT License
76 stars 45 forks source link

Vicon folder #24

Open nakaimauricio opened 8 years ago

nakaimauricio commented 8 years ago

Hi

Can't access the Vicon folder. Can somebody help me?

Thanks

Mauricio

peteflorence commented 8 years ago

Hi Mauricio,

The Vicon folder is proprietary software and so we unfortunately can't share it. If you do have a Vicon setup, though, then we can figure out how to make it work.

We are working on developing a way so that you won't need Vicon, but instead just a webcam, in order to track the CrazyFlie offboard.

We have somebody who has adapted crazyflie-tools to use Optitrack as well, in case that is an option available to you.

Also, if you are up to the challenge, it would be great to have somebody integrate a Kinect option as well.

Let me know if you have any question about what's available or if you're interested in helping develop?

Thanks,

Pete

@lexfridman @blandry @rdeits

nakaimauricio commented 8 years ago

Hi Pete

Thanks for your aswer. I will try something about vicon first and go to something else after.

Thanks

Mauricio

2015-10-15 11:37 GMT-03:00 Pete Florence notifications@github.com:

Hi Mauricio,

The Vicon folder is proprietary software and so we unfortunately can't share it.

We are working on developing a way so that you won't need Vicon, but instead just a webcam, in order to track the CrazyFlie offboard.

We have somebody who has adapted crazyflie-tools to use Optitrack as well, in case that is an option available to you.

Also, if you are up to the challenge, it would be great to have somebody integrate a Kinect option as well.

Let me know if you have any question about what's available or if you're interested in helping develop?

Thanks,

Pete

@lexfridman https://github.com/lexfridman @blandry https://github.com/blandry @rdeits https://github.com/rdeits

— Reply to this email directly or view it on GitHub https://github.com/blandry/crazyflie-tools/issues/24#issuecomment-148405940 .

Mauricio Eiji Nakai (16) 98244-7449

blandry commented 8 years ago

For reference, here is a description of what the vicon folder does: https://github.com/blandry/crazyflie-tools/issues/20

nakaimauricio commented 8 years ago

Thanks for the link. I read there that you can give the client without a proprietary file. Could you sent it to me?

blandry commented 8 years ago

Do you have this library libViconDataStreamSDK_CPP.so?

nakaimauricio commented 8 years ago

Yes, I have, we have a vicon system at the university

2015-10-16 14:56 GMT-03:00 Benoit Landry notifications@github.com:

Do you have this library libViconDataStreamSDK_CPP.so?

— Reply to this email directly or view it on GitHub https://github.com/blandry/crazyflie-tools/issues/24#issuecomment-148785651 .

Mauricio Eiji Nakai (16) 98244-7449

blandry commented 8 years ago

So I just checked and it is a bit tricky since the client is based of an example which I think it also proprietary. But I can guide you to reproduce the client.

First create an LCM type

package vicon_t;

struct vicon_pos_t
{
    int64_t timestamp;
    double q[6];
}

Instructions to compile it: https://lcm-proj.github.io/tut_cpp.html

Then in the vicon Linux DataStream SDK (http://www.vicon.com/downloads) there should be an example file called ViconDataStreamSDK_CPPTest.cpp. All you need to do is modify that example to publish the position of your crazyflie on LCM.

You're probably going to end up removing a lot of code and having at least those lines

Output_GetSegmentGlobalTranslation ObjectTranslation = MyClient.GetSegmentGlobalTranslation( object_name, object_name );
Output_GetSegmentGlobalRotationEulerXYZ ObjectRotationEulerXYZ = MyClient.GetSegmentGlobalRotationEulerXYZ( object_name, object_name );

Our state estimator also looks out for a specific state that corresponds to Vicon dropping the crazyflie [-1000 0 0 0 0 0] so you might want to recreate something like this

for(k=0;k<3;k++)
{
    q[k]=ObjectTranslation.Translation[k];
}
for(k=0;k<3;k++)
{
    q[k+3]=ObjectRotationEulerXYZ.Rotation[k];
}
dropFlag=0;
for(k=0;k<6;k++)
{
    if(q[k]==0.0)
    {
        dropFlag=1;
    }
 }
 if(dropFlag==1)
 {
       q[0]=-1000000.0;
       q[1]=0;
       q[2]=0;
       q[3]=0;
       q[4]=0;
       q[5]=0;
   }
   gettimeofday(&td_end,NULL);
   elapsed = 1000000.0 * (td_end.tv_sec -td_start.tv_sec);
   elapsed += (td_end.tv_usec - td_start.tv_usec);
   elapsed=elapsed/1000000.0;

   double time;
   time=(double)elapsed;

   // Convert time to milliseconds
  time = time*1000;

  q[0] =  q[0]/1000.0; // x (+ is forwards) in m
  q[1] =  q[1]/1000.0; // y (+ is right) in m
  q[2] =  q[2]/1000.0; // z (+ is up) in m

   q[3] =  q[3]; // roll  in rad
   q[4] =  q[4]; // pitch  in rad
   q[5] =  q[5]; // yaw  in rad

   lcm_publish_vicon(object_name,q,time);  // should be an easy function to implement on your own
nakaimauricio commented 8 years ago

Hi Blandry

The code helped a lot. =] I will spend a time to understand the code but now it started to make sense for me. I probably will come back here to ask some questions in the future.

Thanks