We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Let's say we want to pass the PLC IP from terminal to C++ code. Consider this code:
#include <ros/ros.h> #include <rospack#include <std_msgs/String.h> #include <AdsLib/AdsLib.h> #include "AdsLib/AdsNotificationOOI.h" #include "AdsLib/AdsVariable.h" #include <array> #include <cstring> #include <iostream> #include <iomanip> #include <unistd.h> class BeckhoffClass { public: cv_bridge::CvImagePtr cvImageSubscribePtr; int imgWidth, imgHeight; int imgPixels; int rosRate; std::string plcNetId, plcIp, localNetId; AdsDevice* route = nullptr; bool AdsConenction = false; BeckhoffClass() : private_nh("~"), it_(nh_) { // } ~BeckhoffClass() { } void connectTwinCatAds() { try { static const AmsNetId remoteNetId { 169, 254, 94, 16, 1, 1}; static const char remoteIpV4[] = "10.2.2.157"; AdsSetLocalAddress({10, 2, 2, 128, 1, 1}); route = new AdsDevice(remoteIpV4, remoteNetId, AMSPORT_R0_PLC_TC3); AdsConenction = true; std::cout << "Asd connected! \n"; } catch (const AdsException& ex) { std::cout << "Error: " << ex.errorCode << "\n"; std::cout << "AdsException message: " << ex.what() << "\n"; } catch (const std::runtime_error& ex) { std::cout << ex.what() << '\n'; } } }; int main(int argc, char** argv) { std::string plcIp = arv[1]; BeckhoffClass beckhoff_class(plcIp); return 0; }
How can I initialize ADS struct inside Beckhoff class constructor?
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Let's say we want to pass the PLC IP from terminal to C++ code. Consider this code:
How can I initialize ADS struct inside Beckhoff class constructor?
The text was updated successfully, but these errors were encountered: