Flying indoor with optitrack

Hello everyone!

I am doing a test using the code of the offboard example with an optitrack camera system (6 Flex 13), I am not using a companion computer, I am using a ubuntu pc with kinetic ros and 1.6.3 firmware version, my procedure is:

One Windows computer running Motive 1.10, streaming data using the vrpn broadcast.

One Ubuntu computer connected via LAN to the first, running ROS (including MAVROS and vrpn_client_ros).

vrpn_client_node with the Motive IP as an argument. This node will auto-detect trackers and send positions to / tf.

$ roslaunch vrpn_client_ros sample.launch server: = 192.168.1.192

I connect with a usb my ubuntu pc to fcu (pixhawk).

$ rosrun mavros mavros_node _fcu_url: = / dev / ttyACM0: 921600

To have the pose data sent to mavros, I use a relay node from the topic_tools:

$ rosrun topic_tools relay /vrpn_client_node/Quadcopter /pose/ mavros/mocap/pose

Finally, I send the setpoints to mavros/setpoint_position/local

$ rosrun quadrirotor offboard_example

Offboard_example.cpp is a file similar to MAVROS Offboard Example · PX4 Developer Guide, just add the orientation.

I want my 3dr iris to get an altitude of 0.5 m (z = 0.5m) and stay at that point.

My problem is that I do not get the desired result, my drone takes off and flies to any direction, the drone does not get a desired altitude.

Why does this happen?
Is it necessary to have a companion computer?

I attach some images: rqt_grapg, my ubuntu terminal and offbiard_example.cpp

my offboard_example video: 20170703 193959 - YouTube

Regards!!

Hi Mario,

We have offboard control working on a similar setup in our lab.
We are using:

  • OptiTrack
  • mocap_optitrack (instead of vrpn_client_ros) - we are forwarding pose to /mavros/mocap/pose directly from the mocap_optitrack node
  • 1.6.0 px4 firmware
  • Intel Nuc as a companion computer (but I think the only difference from what you are doing is the length of the USB connecting to the pixhawk)
  • ROS Kinetic
  • LPE_FUSION=12
  • ATT_EXT_HDG_M=2

Here are some things we tried before getting offboard mode to work:

  • Use rqt_plot to check that /mavros/mocap/pose and /mavros/local_position/pose are similar - while doing so verify you are using the correct coordinate frame (x=forward, y=left, z=up)
  • Check you can fly in position control mode using pose estimation from the optitrack.

Let me know if you have any questions.

You may also plot the mocap and lpe pose via px4logs.

Hello @Sam.S

Thanks for reply!!

I had to change the pc, in the previous pc I had installed the debian version of mavros, so with the new pc I installed the source version of mavros, with this version when compiling my offboard_example.cpp I get the error "no such file Mavros_msgs / CommanBool "I’m stuck with this problem.

So I’m trying to check with rqt_plot but it does not show me anything.

Why am I having these problems?
Do I have to go back to the debian version?

I will continue trying to solve these problems and publish the data of my graphics here.

Hello! @abdullahmohiuddin

What is px4logs?

Is px4logs in QGC?

thanks for you reply!

I will show my graphs as soon as possible

Regards!

@Sam.S @abdullahmohiuddin

Is it normal that the orientation in /mavros/local_position/pose is very different from the orientation of /mavros/mocap/pose?

Mocap left and local position right

No it should not be different. It should be similar. You should align your pixhawk to x-axis while creating the rigid body

You can download px4logs from QGC. Or use the sd card from autopilot. This is flight data , very useful.

How can I align my pixhawk?, I have to align in optitrack motive software?

Thanks for reply!

Using Optitrack software, you can see where is your x-axis.
There is an arrow printed on top of your pixhawk. Allign them and then create a rigid body. Then compare mocap and lpe. If orientations are similar you got the transformation right.

Hello! @abdullahmohiuddin

I did the alignment of the x axis, the pixhawk arrow has the direction to the right as the x axis of the optitrack sofware to the right and got the same result, the orientation still has great differences between the orientation mocap and local position.

So, the pixhawk is doing wrong the coordinate transformation?
I am sending mocap data to usb port of pixhawk, Do I have to send the mocap data to TELEM2 of pixhawk?

thanks for helping!

I am sorry I thought you are sending mocap data to mavros through a mocap package. I am not sure how trqnsformation works if you send it to telemtery

May be , you can try the transformation in the optitrack software.
There is an option to do the transformation in optitrack software.
Align the x-axis of the optitrack to the x axis of pixhawk and then you just have to rotate around one axis in optitrack. I am not sure, but I thought of this once, never tried it. But for that you need to know the euler angles of the mocap orientation. so that you can decide on transformation via 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?