Mocap Offboard going to local position

#1

Hello :slight_smile:
I connected my drone with a custom mocap device which determined the local position of the drone, so if the device is 0,0,0 the drone is -1,-2,-3 for example. I want to write a script that makes the drone why to the device, what is the best way. I tried the mavros offboard example, but it didn’t work well. It armed and took off gave me a message that it reached the goal but then instead of landing it crashed in my wall. What should I do?

#2

I think you need to check the log and figure out why it crashed into the wall. Switching to e.g. the Dronecode SDK probably won’t help because it would do the same as MAVROS.

#3

Thanks.
https://review.px4.io/plot_app?log=33fd4851-3afd-410d-ac8e-bfbadada2c47

Can you help on the review?

#4

So I can see that first the vehicle was in offboard mode for a short time. Then it lost offboard mode and went into descent, then at some point, offboard is back.

Also, during the second offboard face it doesn’t seem to track roll/pitch setpoints at all. Does the vehicle fly well in manual mode? And does it fly properly in position control? It’s the prerequisite that this works properly. Also, have you checked that all directions in the mocap system are correct and yaw/heading is correct?

#5

Thank you, @JulianOes! I will take a look and test again.

#6

Hello, @JulianOes! I tested my system again. It works well in manual mode. Last time I didn’t set the heading param, but now I did. I tried again the previous script, but the thing is that the initial position (smilar to -0.2, 0.3, 0.11) is close to the 0,0,0(the motion capture device) and I when want to go a meter above it - for example 0,0,1, some props refuse to spin/move. How to achieve that going over the center having the initial position, that is coordinates regarding the center? How to write appropriate script to first reach the z and then move to the x and y over the mocap device? Please help me out.

#7

I would first only set the new z and then compare the telemetry so that it reaches the altitude that you want. Once it reached the altitude, you give it the horizontal position that you want to go to. Also, make sure to test in SITL first to get a feel for what will happen.

#8

Can you specify what do you mean by “compare the telemetry so that it reaches the altitude”? To what should I subscribe to get the altitude? Global position/rel_alt or get it from mavros_msgs/Altitude?

One more thing, how can I avoid movement after it has reached the desired position? How can I keep it in one like-“hold” position?

#9

Can you specify what do you mean by “compare the telemetry so that it reaches the altitude”? To what should I subscribe to get the altitude? Global position/rel_alt or get it from mavros_msgs/Altitude?

You can subscribe to this info:


here:

One more thing, how can I avoid movement after it has reached the desired position? How can I keep it in one like-“hold” position?

You just keep commanding that same position, so it should stay there. That’s if you’re commanding position. If you’re commanding velocity, you would command 0 velocity.

#10

Thanks a lot, Julian! :thumbsup:
What about without DronecodeSDK? Can you give me the same information in MAVROS example? Since I am not using the Dronecode yet. Is it better to use it and use velocity commands or not?

#11

I don’t know MAVROS but in the docs I found this:
http://wiki.ros.org/mavros#mavros.2BAC8-Plugins.setpoint_position
http://wiki.ros.org/mavros#mavros.2BAC8-Plugins.setpoint_velocity

Is it better to use it and use velocity commands or not?

It depends what you want to achieve. Do you want to move the drone to a specific point (position control) or do you want to move it at a specific velocity until you say stop (velocity control)?

#12

I want to achieve more like position control, so it’s okay. Thanks for the help and the fast responses. If I still struggle with something I will reach out to you. :slight_smile:

1 Like
#13

I have some troubles. My drone refuses to take off to a certain distance and then move forward. It literally heads straight forward, what should I chance or do?

#14

Give it a setpoint to go up first. Then after some time or when it has reached the point you can go forward. You’re in control with the setpoints and should be able to guide the drone how you want.