The XMLRPC code is in the _comm-noet-develulitiesxmlrpcpp path at the end.
Fortunately, the whole project is not too big. XMLRPC is divided into two parts: client and server.
Let's look at the client first. The main code is in the XmlRpcClient.cpp file.
The core function in the XmlRpcClient.cpp file is execu, which is used to execute remote calls. The code is as follows.
// Execute the named procedure on the remote server.
// Pas should be an array of the arguments f the method.
// Returns true if the request was sent and a result received (although the result might be a fault).
bool XmlRpcClient::execute(const char* method, XmlRpcValue const& params, XmlRpcValue& result)
{
XmlRpcUtil::log(1, "XmlRpcClient::execute: method %s (_connectionState %s).", method, connectionStateStr(_connectionState));
// This is not a thre-safe operation, if you want to do multithreng, use separate
// clients for eh thread. If you want to protect youelf from multiple threads
// accessing the same client, replace this code with a real mutex.
if (_executing)
return false;
_executing = true;
ClearFlagOnExit cf(_executing);
_sendAttempts = 0;
_isFault = false;
if ( ! setupConnection())
return false;
if ( ! generateRequest(method, params))
return false;
result.clear();
double msTime = -1.0; // Process until exit is cal
_disp.work(msTime);
if (_connectionState != IDLE || ! parseResponse(result)) {
_header = "";
return false;
}
// close() if server does not supports HTTP1.1
// otherwise, reusing the socket to write leads to a SIGPE because
// the remote server could shut down the corresponding socket.
if (_header.find("HTTP/1.1 200 OK", 0, 15) != 0) {
close();
}
XmlRpcUtil::log(1, "XmlRpcClient::execute: method %s completed.", method);
_header = "";
_response = "";
return true;
}
It first calls the setupConnection() function to establish a connection with the server.
After the connection is successful, call the generateRequest() function to generate a request message.
The header of the XMLRPC request message is handed over to the generateHeader() function. The code is as follows.
// Prepend http headers
std::string XmlRpcClient::generateHeader(size_t length) const
{
std::string header =
"POST " + _uri + " HTTP/1.1rn"
"User-Agent: ";
header += XMLRPC_VERSION;
header += "rnHost: ";
header += _host;
char buff[40];
std::snprintf(buff,40,":%drn", _port);
header += buff;
header += "Content-Type: text/xmlrnContent-length: ";
std::snprintf(buff,40,"%zurnrn", length);
return header + buff;
}
The body part first converts the remote call method and parameters into XML format, and the generateRequest() function combines the header and body into a complete message, as follows:
std::string header = generateHeader(body.length());
_request = header + body;
After sending the message to the server, it starts waiting quietly.
Once the message returned by the server is received, the parseResponse function is called to parse the message data, that is, to convert the XML format into a pure data format.
We found that XMLRPC uses the socket function to implement the client and server.
We searched for the word socket and found that its original meaning is socket. This is very vivid, establishing a connection to achieve communication is like inserting a plug into a socket.
Although XMLRPC is also part of ROS, it is just a basic function after all. We will just use it and will not explore its implementation details for the time being.
Previous article:SenseTime and Spain's BOMAPA Group Sign AI Industrial Solutions Cooperation Agreement
Next article:What is XMLRPC in ROS
- Popular Resources
- Popular amplifiers
- Using IMU to enhance robot positioning: a fundamental technology for accurate navigation
- Researchers develop self-learning robot that can clean washbasins like humans
- Universal Robots launches UR AI Accelerator to inject new AI power into collaborative robots
- The first batch of national standards for embodied intelligence of humanoid robots were released: divided into 4 levels according to limb movement, upper limb operation, etc.
- New chapter in payload: Universal Robots’ new generation UR20 and UR30 have upgraded performance
- Humanoid robots drive the demand for frameless torque motors, and manufacturers are actively deploying
- MiR Launches New Fleet Management Software MiR Fleet Enterprise, Setting New Standards in Scalability and Cybersecurity for Autonomous Mobile Robots
- Nidec Drive Technology produces harmonic reducers for the first time in China, growing together with the Chinese robotics industry
- DC motor driver chip, low voltage, high current, single full-bridge driver - Ruimeng MS31211
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- Linux Command Detailed Dictionary
- ARM register analysis and exception handling methods
- Qorvo has recently launched Wi-Fi 6 and IoT solutions. Will you choose them?
- TI DSP Simulation
- Radar System Engineering: Antenna System (summarizes many sub-projects) You can take a look at it to absorb scattered memories
- 【GD32307E-START】Development environment construction + development practice -> light up the onboard LED
- DM642 hard interrupt delay problem
- Is the semiconductor industry still worth investing in?
- Regarding the question of safety capacitors, let's see who is right
- Download and get a gift! Rohm will teach you tips on power supply design and application