What you need to know now is that ROS is a process of receiving and sending in the final analysis. Here, the information to be sent is packaged first.

Need to look at the drone’s SDK here to build this thing.

https://dl.djicdn.com/downloads/RoboMaster%20TT/Tello_SDK_3.0_User_Guide_cn.pdf

Available on the official website, self pick up

Just know this for now

Video streaming is also required

Let’s create a folder like this

Encapsulate the information we need, the Msg of ROS is fixed

WIFI configuration also has

Write the information we want to compile in Cmake

After all, ROS is a software framework. In the end, a language is needed to implement it. Here it is compiled into C++.

The XML file is the ID card of the package, who it depends on when compiling, the function of the package, etc.

For a robot, we need something to control, right?

Displays drone imagery and provides keyboard control.

T is for takeoff, L is for landing the drone, F is for flipping forward, E is for emergency stop, WASD and arrows are used to control drone movement.

Get our control commands in the SDK

Before writing in detail, I want everyone to have a macro design of this control file

write on the head

We need the ROS2 control library for C++

A complete API is attached, remember to check more when using it

If you don’t check, I think you deserve a beating, why are you so good~

Close common messages in ROS. Includes action messages (acTIonlib_msgs), diagnostics (diagnosTIc_msgs), geometry primitives (geometry_msgs), robot navigation (nav_msgs), and common sensors (sensor_msgs) such as laser rangefinders, cameras, point clouds.

Use this here

This represents the velocity in free space, divided into a linear part and an angular part. You read the source code of ROS after I finish writing this.

What this message package does is: Isolate messages to communicate between stacks in shared dependencies Allow nodes in dependent stacks to communicate without depending on each other. The stack is designed to contain the most common messages used across multiple stacks to provide shared dependencies, eliminating problematic circular dependencies.

The following code is: ROS topic release, don’t ask why you wrote it like this, because others wrote it like this.

Here is how ROS2 is written

Many message definitions from ROS1 to ROS2 are similar, most of them are the same, but there is an additional msg field

I said it myself (praise me)

#include ----> #include

this is change

After learning the template for two days, I came out to do this

The timer of ROS1 uses while, and the second generation is a little more powerful.

Each node has a list of handles (relating to timers, subscribers, clients, services, wait objects) which are put into wait sets. Every time a node spins (executes a cycle), this wait set is checked to see if it is ready to perform any operations.

For timers, this simply means checking if the timer has “expired” -> if so, executing the callback.

For a subscription, think of it as the rcl layer asking the rmw if anything happened at the DDS level, like receiving a message.

But basically, node just checks that the correct event is fired for the correct type of callback. What’s in the callback doesn’t matter. You can put anything in it.

The prototype of this function

Just look at the parameters

Then we can write code like this, damn it, it’s like I teach you 1+1, but leaving homework is like calculus, but that’s how writing programs are. In fact, there is still a callback that has not been written, let’s start~

Let’s explain this thing first. We designed a node that sends commands in the SDK continuously. The commands inside are subscribed externally, and the tasks will be executed when they are received.

Then there was a timer in it. 1ms to see if something happens, or to put it this way, 1ms to see if the callback function is doing anything, I think the callback function is swearing.

Touch the callback function, are you polite with the timer?

I was a local dog before, and I have never used callback functions. I have read many articles, both serious and not serious, but put everything aside. The callback function is nothing more than a little brother waiting to be called. It’s a bit unpretentious to speak the vernacular, so here’s a bit of a drag:As the name suggests, the callback function is to call it back. The callback function is actually a parameter. Pass this function as a parameter to another function. After that function is executed, execute the function passed in.This process is called callback.

Here I also decided to share my notes with you:

Do you understand?

Continue to look at this callback function on the basis of pretending to understand:

first look at the big one

These are the things of OpenCV, which is to take a control photo first, fill the window, and then create and display it. 15ms to see if a button is pressed, remember what I said earlier?

Just look at one, if the button is pressed

just send the message

If there is none, call the manual function, damn, the old sow wears a bra, one set after another, and write another function.

Nothing to say, send the message from the keyboard

send this

Pay attention to the assembly when sending this last message

The end is beautiful~

Compiled files added

Write about the dependencies of OpenCV on it

The content is a bit too much. . . Next is a Node, a software package used to control the DJI Tello drone, providing data and controlling the drone according to the official SDK provided by DJI.

Let’s take a look at the organization

This thing is a bit complicated, and I’m afraid I won’t be able to write it down.

Import the library first

The code is a bit long, look backwards, it is the start of a node

Quaternion to Euler

Euler to Quaternion

I won’t talk about this, because we are an APP, not an algorithm article. I will talk about it next time, and these two functions can be reused.

There are these functions in the node

The built-in parameters of the node at the beginning, do not change. mainly connection information

Get the internal parameters and perform type conversion

Look at this here, because the subject is monocular SLAM, so the parameters of the lens are very important

The parameters of the camera can be obtained from the outside

Where do these parameters come from? It was done using the ROS package about calibration

Here, the externally calibrated data will be passed to the variable.

This is the external Tello control package, I will explain it to you next time

Used in conjunction with the log function to tell the operator (that’s me, the connection status)

The transceiver function of a node is also activated in place

The three threads also start

The drone is ready to take off!

The published node is like this, you should be able to see it clearly. There are images, lens calibration information, Tello status, ID, IMU data, battery, temperature, odometer, etc., followed by broadcasting of coordinates.

Subscribe to external information, take off? Forced landing, control or something, somersault

That is, between ROS, the transmission of information is standard information, so an information conversion is required here. For CV, the idea is to follow the video flow in order. Here is an information capture, conversion, Send, and it is a function that is processed as a thread.

The other one is the info thread for the drone

deadlock send

A power node, in fact, has a lot of information, whether it is unchanged or changed, and everyone will send it out, but for your specific use, you have to choose a subscription, otherwise how do I know what information you want? The information is from Tello got it

The state of tello is like this, pay attention to the keywords I choose, tello is obtained from outside. Interested posture information is available,

The camera information is stored in yaml, just like a plug-in, it is also sent together.

The rest is the sending thread of the odometer

In the final analysis, the odometer is the distance and angle, what you want

This is equivalent to the UTIl function, write several functions related to the machine itself

Through such information, we can precisely control our small computer with RC commands.

I was supposed to show you the compilation process on the computer, but I am so tired, I will show it at the beginning of tomorrow’s article, and here is the compiled script:

#!/bin/bashcd../workspacerm -rf build installlogrosdep install -i --from-path srccolcon build --symlink-install --packages-select tello tello_control tello_msg# Indicates that if the file in install already exists in the src or build folder during compilation,# Just use a hyperlink to point to the file, avoid wasting space, and can also achieve synchronous updates

Leave a Reply

Your email address will not be published.