Flying indoor with optitrack

What do you mean, with “mocap package”?

I said about the pixhawk port (TELEM2) because I read that many people have a companion computer on top of the drone, so they using wifi receive mocap data on the companion computer and with an usb2ttl connect the companion computer to the pixhawk using the telemetry port (TELEM2) with a baudrate of 921600.

I do not have a companion computer, I am sending the data optitrack mocap with a long USB cable to the pixhawk using the usb port of the pixhawk.

Regards!!

This is what I said , exactly. If you have a companion computer, that computer talks to px4 via MAVLINK.
MAVROS, is the software that connects ROS to MAVLINK. So, we need a package in the companion computer that can publish the optitrack data to the mavros topic so that it can be sent to the px4 via MAVLINK.
So if we use that package which is the mocap package, this package does the transformation for us. I think, in your case you will have to do it manually via optitrack software.

Hi @Mario1577 and @abdullahmohiuddin

We are also working with the similar project (flying the drone indoor with Optitrack cameras).
We are using Intel Aero RTF drone (including an Intel Aero FC and a computation board) and 6 Optitrack cameras. Because we have no idea with ROS but only Dronekit. Is it possible for us to send the local position to the FCU via Mavlink message ATT_POS_MOCAP?

I am using vrpn_client_ros package, Is vrpn a mocap package?

I am getting the mocap data of optitrack sofware to ROS using vrpn_client_ros, often I use a relay node for send mocap data to /mavros/mocap/pose topic.

So, Is the vrpn_client_ros package not plublishing correctly the mocap data to /mavros/mocap/pose?

I’m a little confused…

Regard! and thanks for reply! @abdullahmohiuddin

I understand that you can send the mocap data via mavlink message, but I think using mavros is easier @Duy_Vu

Hi @Mario1577

Thank you for your quick reply.
Have you successfully flown your drone indoor?
We are sending the ATT_POS_MOCAP message to our FCU and can get the local position by listening to the LOCAL_POSITION_NED message. The position from vision and drone match each other, but we have another problem with takeoff. Our procedure is:

  1. set the drone to POSCTL mode
  2. arm the motors
  3. continuously send SET_POSITION_TARGET_LOCAL_NED message with type_mask = 0b0001111011000000, x = 0, y = 0, z = -0.5, vx = 0, vy = 0, vz = 0.1, coordinate_frame = MAV_FRAME_LOCAL_OFFSET_NED
    4.
    on reaching the target altitude, we continuously send another NED message with type_mask = 0b0011111011111000, x = 0, y = 0, z = 0.

However, our drone still tries to jet to the higher altitude after reaching the target one. We have not figured out what wrong with it. Do you have any suggestion?

*we follow the setting type_mak of step 3 and 4 from Offboard automatic TakeOff / Landing using MAV_CMD_LAND/TAKEOFF_LOCAL

Hello!

I still get the same results, my drone does not get the desired height (0.5m) and stay at that point with optitrack position data, before I sent the mocap data to the usb port of the pixhak but now I’m sending them to the TELEM2 port of the pixhaw But I still get the same results.

my pixhawk setup:

I am using LPE with companion computer (TELEM2) with 921600 baudrate
ATT_EXT_HDG_M = 2
LPE_FUSION= 12

am I missing something else?

Will the pixhawk be receiving the mocap data?

I am getting my mocap data with vrpn, but many people use the mocap_optitrack package, will it be the cause of my problem?

Here is the link to my flight review (.log file): https://logs.px4.io/plot_app?log=0c81e0f8-bf97-469e-9c1d-431e9621a036

@abdullahmohiuddin Before creating the rigid body, when I align the arrow of the pixhawk to the axis x of the motive optitrack, the pixhawk has to be with the battery connected? orDo I first have to align the arrow of the pixhak with the x-axis optitrack then I create the rigid body and finally connect the battery of the drone?

I think creation of rigid body does not require, battery for the drone.

Hello @abdullahmohiuddin

I already managed to send the mocap data correctly to pixhawk. My drone gets the desired height (x = 0, y = 0 and z = 0.3 m)

video test: https://youtu.be/bCe2heEmP64

Thanks!

1 Like

That is great, I saw your video, how did you figure the problem, and why are you using tethered drone.

Hello! @abdullahmohiuddin

I am using tethered drone because I don’t have a raspberry, odroid or wifi module, I am sending mocap data of a ubuntu pc to pixhawk with usb cable.

My ubuntu pc has installed vrpn and mavros. I am using xbee usb adapter board (USB to TTL).

Hello @Mario1577

I’m working to get a very similar setup working except with the f450 instead of the 3dr iris. Do you happen to have any suggestions or sample launch files that you used to get this working?

Thanks,
Ken

Hello @k-chaney

What kind of suggetions Do you need?

HI @Mario1577 and @abdullahmohiuddin,
I am doing the same project what you did recently.
I am using crazyflie 2.0 and Optitrack and vrpn_client_node.
Also, I am using two computer to stream optitrack data from window pc to ubuntu pc via vrpn.

I followed all you mentioned…in not only in this page, but also other resources…
Crazyflie is using radio signal to communicate with ubuntu PC, so I cannot see any data of /mavros/local_position/pose…(but, I can see its data when I use USB connection.)
So I tried to relay optitrack data to /mavros/local_position/pose… also I did relay optitrack data to /mavros/mocap/pose, but I did see any successful flight… it failed…

I have some question.
Please answer if you are available.

1. Frames
When I calibrate and set ground with OptiTrack system, the ground plane has two axis; x-axis & z-axis.
So y-axis is for vertical direction.
Then does y-axis of OptiTrack turn to z-axis of ENU frames in MAVROS automatically when we use vrpn_client_node/?
That is the reason why we use “z=0.5” in offboard example code?

2.
How did you get the result of this video (https://youtu.be/bCe2heEmP64)?
What was the major changes to get the result of the above video?
My situation is exactly the same with yours as like in this video (https://youtu.be/XBbBbEaNlrc), but I do not understand when you said

as the answer for the abdullah’s question; [quote=“abdullahmohiuddin, post:23, topic:3782”]
how did you figure the problem
[/quote]

Could you please explain more about it?

Please help me to resolve these issues…

Thank you.

Hello! @netkimjh

Yes, Mavros have a plugin (mocap_pose_estimate). the plugin transforms the ENU (Optitrack) to NED (PX4) coordinates, therefore, when you make a trajectory you must use the z axis.

I solved my trouble doing the follow:

  • I changed the 1.6.3 to 1.6.5 PX4 Version ( the 1.6.3 version was not working)
  • I changed a parameter of Motive Sofware (DataStreaming Pane): Y up to Z up.

Regards!!

Thank you for your kind reply @Mario1577!

I have questions about data of “/mavros/local_position/pose”
I tried to check it with USB connection (not under the Optitrack, because my cable is short…) and wireless connection.

With USB connection, it showed the weird values…

In addition, with wireless connection, it did not show any message at all.
Do you have any idea to resolve this issue?
Do you think this data (/mavros/local_position/pose) is important to control quadrotors?

Actually, I relayed OptiTrack data to the /mavros/local_position/pose. But the quadrotor flew as like your first video…

Thank you!

Thank you.

Hello @netkimjh

What kind of wireless connection Do you use?

Yes, it is important to control quadrotors, you have to make sure that vrpn_client_node/tracker name/pose, mavros/mocap/pose and /mavros/local_position/pose topics have the same values.

you don’t have to send optitrack data to /mavros/local_position/pose, you have to send optitrack data to /mavros/mocap/pose topic.

Hi @Mario1577,

I am using Crazyflie 2, and CrazyRadio PA to communicate with PC and CF2.
(https://www.bitcraze.io/crazyradio-pa/)

Since I cannot see any data when I use wireless communication, not USB connection, I am relaying OptiTrack data to not only /mavros/mocap/pose, also /mavros/local_position/pose.

How do you think about relaying OptiTrack data to both topics?

One more question is that is “pose.pose.orientation.w = 1” correct in the offboard code?

I am testing now… I will show some results soon.

Thank you.

P.S. Thanks for giving me a tip about “UP Axis” option. After switching this option, the quadrotor is flying upward!!

Hello @netkimjh

Maybe you cannot see any data because CrazyRadio PA does not have enough baudrate, if you are sending optitrack data you have to have a baudrate of 921600. Actually I have a companion computer (Raspberry pi3) on my 3dr iris.

My windows pc with Motive Software is sending optitrack data to raspberry using wifi, the raspberry is connected to TELEM2 port of pixhawk using serial with 921600 baudrate.

The orientation.w is the real part of the quaternion The orientation is parameterized as a quaternion hence w, x, y, z

Why are you relaying to /mavros/local_position/pose?

Regards!!

Hi @Mario1577,
First, I would like to thank you for your instruction. I have followed all the steps and have my drone taken off nicely.
However, there is a remaining issue. Although I send NED of 0.0, 0.0, 0.5, my drone does not hover as stable as in your clip but goes back and forth, up and down in an area of about 1x1x1 meter. Do you have any suggestion to fix it?