Go to the documentation of this file.00001
00023 #include <iostream>
00024 #include <vector>
00025 #include "opensplice_dds_broker/check_status.h"
00026 #include "opensplice_dds_broker/publisher.h"
00027 #include "gsdf_msgs/CommPacket.h"
00028 #include "gsdf_msgs/JoinSwarm.h"
00029 #include "micros_swarm/message.h"
00030
00031 #define MAX_PACKET_LEN 1024
00032 #define NUM_PACKET 1000000
00033
00034 using namespace DDS;
00035
00036 void dump_string(const std::string& s)
00037 {
00038 std::cout<<"length: "<<s.length()<<", data: ";
00039 for(int i = 0; i < s.length(); i++) {
00040 std::cout<<(int)s[i];
00041 }
00042 std::cout<<std::endl;
00043 }
00044
00045 void dump_char_seq(char* s, int len)
00046 {
00047 std::cout<<"length: "<<len<<", data: ";
00048 for(int i = 0; i < len; i++) {
00049 std::cout<<(int)(*(s+i));
00050 }
00051 std::cout<<std::endl;
00052 }
00053
00054 void dump_char_vec(std::vector<uint8_t> vec)
00055 {
00056 std::cout<<"length: "<<vec.size()<<", data: ";
00057 for(int i = 0; i < vec.size(); i++) {
00058 std::cout<<(int)(vec[i]);
00059 }
00060 std::cout<<std::endl;
00061 }
00062
00063 int main()
00064 {
00065 opensplice_dds_broker::GSDFPacket packet;
00066 checkHandle(&packet, "new MSFPPacket");
00067 char buf[MAX_PACKET_LEN];
00068
00069 std::string test = "";
00070 opensplice_dds_broker::Publisher publisher("micros_swarm_framework_topic");
00071
00072 gsdf_msgs::JoinSwarm js;
00073 js.robot_id = 1;
00074 js.swarm_id = 2;
00075 std::vector<uint8_t> msg_data = micros_swarm::serialize_ros(js);
00076
00077 unsigned int bufsize = msg_data.size();
00078 std::cout<<bufsize<<std::endl;
00079 packet.data.replace(bufsize, bufsize, (char*)(&msg_data[0]), false);
00080
00081 for (int i = 1; i <= NUM_PACKET; i++) {
00082 dump_char_vec(msg_data);
00083 publisher.publish(packet);
00084 sleep (1);
00085 }
00086 return 0;
00087 }