L_TO_CREATE_MULTIPLE

data LT_TRITE type L03B_TRITE_T.

data WA_TRITE like line of LT_TRITE.

data GV_STORED like VBAPF-QMENGE.

clear: LT_TRITE, WA_TRITE, GV_STORED.

refresh LT_TRITE.

WA_TRITE-TBPOS = GT_LTBP-TBPOS.

WA_TRITE-ANFME = GT_LTBP-MENGE.

WA_TRITE-ALTME = GT_LTBP-MEINS.

WA_TRITE-LETYP = GT_MARA-VHART(3). "3-character storageunittype

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
帮我修改代码,实现用wss发送serialized_data到wss://autopilot-test.t3go.cn:443/api/v1/vehicle/push/message/LFB1FV696M2L43840。 main.cpp: #include "ros/ros.h" #include "std_msgs/String.h" #include <boost/thread/locks.hpp> #include <boost/thread/shared_mutex.hpp> #include "third_party/apollo/proto/perception/perception_obstacle.pb.h" #include "t3_perception.pb.h" apollo::perception::PerceptionObstacles perception_obstacles_; void perceptionCallback(const std_msgs::String& msg) { ROS_WARN("t3 perceptionCallback parse"); if (perception_obstacles_.ParseFromString(msg.data)) { double timestamp = perception_obstacles_.header().timestamp_sec(); ROS_INFO("t3 perceptionCallback timestamp %f count:%d", timestamp, perception_obstacles_.perception_obstacle().size()); std::string data; perception_obstacles_.SerializeToString(&data); VehData veh_data; veh_data.set_messagetype(5); veh_data.set_messagedes("PerceptionObstacles"); veh_data.set_contents(data); std::string serialized_data; veh_data.SerializeToString(&serialized_data); } else { ROS_ERROR("t3 perceptionCallback parse fail!"); } } int main(int argc, char **argv) { ros::init(argc, argv, "listener"); ros::NodeHandle n; ros::Subscriber sub = n.subscribe("/perception_node/perception_objects", 1000, perceptionCallback); ros::spin(); return 0; } t3_perception.proto: syntax = "proto3"; option java_package = "com.t3.ts.dt.ad.web.protobuf"; option java_outer_classname = "VehDTO"; option java_multiple_files = false; message VehData { /** messageType: 1:客户端心跳 2:云端心跳响应 3:连接成功 4:连接失败 5:客户端发送消息 6:云端发送消息 7:消息处理成功 8:消息处理失败 9:此客户端未注册 10:未知消息类型 */ int32 messageType = 1; string messageDes = 2; bytes contents = 3; // 发送内容 }
最新发布
06-09
您可以使用以下代码实现发送 `serialized_data` 到 `wss://autopilot-test.t3go.cn:443/api/v1/vehicle/push/message/LFB1FV696M2L43840`: ```cpp #include "ros/ros.h" #include "std_msgs/String.h" #include <boost/thread/locks.hpp> #include <boost/thread/shared_mutex.hpp> #include "third_party/apollo/proto/perception/perception_obstacle.pb.h" #include "t3_perception.pb.h" #include "websocketpp/config/asio_client.hpp" #include "websocketpp/client.hpp" using websocketpp::lib::placeholders::_1; using websocketpp::lib::placeholders::_2; using websocketpp::lib::bind; typedef websocketpp::client<websocketpp::config::asio_tls_client> client; typedef boost::shared_ptr<boost::asio::ssl::context> context_ptr; context_ptr on_tls_init(websocketpp::connection_hdl) { context_ptr ctx = boost::make_shared<boost::asio::ssl::context>(boost::asio::ssl::context::tlsv12); try { ctx->set_options(boost::asio::ssl::context::default_workarounds | boost::asio::ssl::context::no_sslv2 | boost::asio::ssl::context::no_sslv3 | boost::asio::ssl::context::single_dh_use); } catch (std::exception& e) { std::cout << e.what() << std::endl; } return ctx; } void on_open(client* c, websocketpp::connection_hdl hdl) { std::string message = "Hello, world!"; try { c->send(hdl, message, websocketpp::frame::opcode::text); } catch (websocketpp::exception const & e) { std::cout << e.what() << std::endl; } } void on_fail(client* c, websocketpp::connection_hdl hdl) { client::connection_ptr con = c->get_con_from_hdl(hdl); std::cout << "Connection to " << con->get_uri() << " failed: " << con->get_ec().message() << std::endl; } void on_message(websocketpp::connection_hdl hdl, client::message_ptr msg) { std::cout << "Received message: " << msg->get_payload() << std::endl; } void perceptionCallback(const std_msgs::String& msg) { ROS_WARN("t3 perceptionCallback parse"); apollo::perception::PerceptionObstacles perception_obstacles_; if (perception_obstacles_.ParseFromString(msg.data)) { double timestamp = perception_obstacles_.header().timestamp_sec(); ROS_INFO("t3 perceptionCallback timestamp %f count:%d", timestamp, perception_obstacles_.perception_obstacle().size()); std::string data; perception_obstacles_.SerializeToString(&data); VehData veh_data; veh_data.set_messagetype(5); veh_data.set_messagedes("PerceptionObstacles"); veh_data.set_contents(data); std::string serialized_data; veh_data.SerializeToString(&serialized_data); // 创建 websocket 客户端 client c; std::string uri = "wss://autopilot-test.t3go.cn:443/api/v1/vehicle/push/message/LFB1FV696M2L43840"; try { // 设置 TLS 初始化回调函数 c.set_tls_init_handler(bind(&on_tls_init, ::_1)); // 设置回调函数 c.set_open_handler(bind(&on_open, &c, ::_1)); c.set_fail_handler(bind(&on_fail, &c, ::_1)); c.set_message_handler(bind(&on_message, ::_1, ::_2)); // 连接服务器 websocketpp::lib::error_code ec; client::connection_ptr con = c.get_connection(uri, ec); if (ec) { std::cout << "Could not create connection: " << ec.message() << std::endl; return; } c.connect(con); // 发送数据 c.send(con->get_handle(), serialized_data, websocketpp::frame::opcode::binary); // 等待连接关闭 c.run(); } catch (websocketpp::exception const & e) { std::cout << e.what() << std::endl; } } else { ROS_ERROR("t3 perceptionCallback parse fail!"); } } int main(int argc, char **argv) { ros::init(argc, argv, "listener"); ros::NodeHandle n; ros::Subscriber sub = n.subscribe("/perception_node/perception_objects", 1000, perceptionCallback); ros::spin(); return 0; } ``` 在上面的代码中,我们使用了 websocketpp 库来创建 websocket 客户端,并发送二进制数据到指定的服务器。在 `perceptionCallback` 函数中,我们将解析得到的 Protobuf 数据序列化为二进制数据,并发送到服务器。 请注意,这里我们使用了 TLS 加密的 websocket 连接,因此需要设置 TLS 初始化回调函数来初始化 SSL 上下文。同时,我们也设置了连接成功、连接失败和收到消息的回调函数。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值