In the previous section, overview( Interesting practice of robot programming 01 - brief introduction )Briefly describe the content of the course.
- internet
- Internet of things
- Intelligent Networking (robot)
Opening
What are the specific differences between the Hello World of these device platforms???


For the above device, its Hello World is to measure the heartbeat, and then send it, which can be displayed on the web page. How do you do it?
start
Let's start with a simple program^_^
#Include < iostream > / / header file using namespace std; //Namespace int main() //Main function { cout<<"The simplest text display of the terminal"<<endl; return 0; }
This program is applicable to mobile phones and computers. After compilation, the execution effect is as follows:

This program contains header files, namespaces, and main functions.
Note that in the main function, only cout is output. This is the most original basis for all code learning. This program belongs to single machine terminal display, the most rudimentary human-computer interaction, and publishes a predetermined message.
It doesn't belong to
- Internet program
- Internet of things program
- Robot program
reflection:
- How to realize information interaction between multiple computers? (Internet)
- How to realize data sharing among multiple sensor devices? (Internet of things)
- How to achieve action coordination among multiple robots? (robot)

Tips:
- Data or information (not necessarily a reflection of the real world)
- Actual environmental measurement information
- Complete tasks or changes based on environmental information
Artificial intelligence and other contents will be supplemented in the form of cases
Leap
One way message publishing:
The windows computer sends Hello World to the linux computer, as shown in the following figure:

windows on the left and linux on the right are one-way messaging.

Then start the message publishing on the linux side. The windows side can not only view the messages published by itself, but also see the messages published by linux.
Through such tools plus some graphical skin, you can make LAN chat tools. Of course, pictures can also be transmitted.
Problem leads!
- asynchronous communication
- Synchronous communication
How to synchronize the time between two or more computers???
How to realize real-time video transmission???
The Linux side reference program is as follows:
#include <chrono> #include <functional> #include <memory> #include <string> #include "rclcpp/rclcpp.hpp" #include "std_msgs/msg/string.hpp" using namespace std::chrono_literals; class MinimalPublisher : public rclcpp::Node { public: MinimalPublisher() : Node("minimal_publisher"), count_(0) { publisher_ = this->create_publisher<std_msgs::msg::String>("topic", 10); timer_ = this->create_wall_timer( 2000ms, std::bind(&MinimalPublisher::timer_callback, this)); } private: void timer_callback() { auto message = std_msgs::msg::String(); message.data = "come from Linux News of" + std::to_string(count_++); RCLCPP_INFO(this->get_logger(), "Publishing: '%s'", message.data.c_str()); publisher_->publish(message); } rclcpp::TimerBase::SharedPtr timer_; rclcpp::Publisher<std_msgs::msg::String>::SharedPtr publisher_; size_t count_; }; int main(int argc, char * argv[]) { rclcpp::init(argc, argv); rclcpp::spin(std::make_shared<MinimalPublisher>()); rclcpp::shutdown(); return 0; }
In contrast, the first program has many similarities, but it is more complex. The message released by this case is the character entered by the keyboard.
Review the case at the beginning of this article, which is an Internet of things message case. The data is the heartbeat rate.
So how to write the robot program Hello World???

For details, please refer to the following links:
summary
Hello World has developed from stand-alone to network, and its expression forms have become rich and colorful. The requirements for processor and network bandwidth have also been significantly improved.
- Message exchange from the Internet
- Digitization of real objects to the Internet of things
- Then to the interaction and cooperation between robots and the real world
- The integration of virtual reality and reality is becoming closer and closer
All this comes from the signal from the digital chip:
Hello World
Hello World
Hello World
Hello World
