From a1286256197e68bc20cfecbdbdb7f7f8153c6018 Mon Sep 17 00:00:00 2001 From: Vivek Shankar Varadharajan Date: Sun, 9 Oct 2016 19:58:50 -0400 Subject: [PATCH] launch file commit --- .gitignore | 0 CMakeLists.txt | 3 +- launch/rosbuzz.launch | 11 ++++ package.xml | 4 +- src/buzz_utility.cpp | 4 +- src/buzz_utility.h | 2 +- src/out.basm | 150 ------------------------------------------ src/out.bdbg | Bin 6120 -> 0 bytes src/out.bo | Bin 525 -> 0 bytes src/rosbuzz.cpp | 57 +++++++++++----- src/test.bzz | 13 +--- 11 files changed, 59 insertions(+), 185 deletions(-) create mode 100644 .gitignore create mode 100644 launch/rosbuzz.launch delete mode 100644 src/out.basm delete mode 100644 src/out.bdbg delete mode 100644 src/out.bo diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/CMakeLists.txt b/CMakeLists.txt index 247e8a5..84f05b5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -37,4 +37,5 @@ install(TARGETS rosbuzz_node RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION} ) - +find_package(catkin REQUIRED COMPONENTS roslaunch) +roslaunch_add_file_check(launch) diff --git a/launch/rosbuzz.launch b/launch/rosbuzz.launch new file mode 100644 index 0000000..d79ce4d --- /dev/null +++ b/launch/rosbuzz.launch @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/package.xml b/package.xml index 3f9b78d..2a425c7 100644 --- a/package.xml +++ b/package.xml @@ -40,8 +40,8 @@ catkin - message_generation - message_runtime + + diff --git a/src/buzz_utility.cpp b/src/buzz_utility.cpp index f521feb..61697d7 100644 --- a/src/buzz_utility.cpp +++ b/src/buzz_utility.cpp @@ -199,13 +199,13 @@ static int buzz_register_hooks() { /****************************************/ int buzz_script_set(const char* bo_filename, - const char* bdbg_filename) { + const char* bdbg_filename, int robot_id) { /* Get hostname */ char hstnm[30]; gethostname(hstnm, 30); /* Make numeric id from hostname */ /* NOTE: here we assume that the hostname is in the format Knn */ - int id = strtol(hstnm + 1, NULL, 10); + int id = robot_id; //strtol(hstnm + 1, NULL, 10); cout << " Robot ID" << id<< endl; /* Reset the Buzz VM */ if(VM) buzzvm_destroy(&VM); diff --git a/src/buzz_utility.h b/src/buzz_utility.h index 2bd0102..256f7d3 100644 --- a/src/buzz_utility.h +++ b/src/buzz_utility.h @@ -22,7 +22,7 @@ void in_msg_process(uint64_t* payload); uint64_t* out_msg_process(); int buzz_script_set(const char* bo_filename, - const char* bdbg_filename); + const char* bdbg_filename, int robot_id); void buzz_script_step(); void buzz_script_destroy(); diff --git a/src/out.basm b/src/out.basm deleted file mode 100644 index 4cb2833..0000000 --- a/src/out.basm +++ /dev/null @@ -1,150 +0,0 @@ -!24 -'init -'i -'s -'swarm -'create -'join -'step -'neighbors -'foreach -'print -'robot -': -'distance = -'distance -', -'azimuth = -'azimuth -'elevation = -'elevation -'exec -'uav_takeoff -'uav_goto -'reset -'destroy - - pushs 0 - pushcn @__label_1 - gstore - pushs 6 - pushcn @__label_2 - gstore - pushs 22 - pushcn @__label_8 - gstore - pushs 23 - pushcn @__label_9 - gstore - nop - -@__label_0 - -@__exitpoint - done - -@__label_1 - pushs 1 |3,1,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz - pushi 0 |3,2,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz - gstore |3,3,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz - pushs 2 |4,2,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz - pushs 3 |4,9,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz - gload |4,9,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz - pushs 4 |4,10,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz - tget |4,16,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz - pushi 10 |4,17,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz - pushi 1 |4,20,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz - callc |4,20,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz - gstore |4,20,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz - pushs 2 |5,1,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz - gload |5,1,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz - pushs 5 |5,2,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz - tget |5,6,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz - pushi 0 |5,8,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz - callc |5,8,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz - ret0 |7,1,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz - -@__label_2 - pushs 7 |12,9,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz - gload |12,9,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz - pushs 8 |12,10,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz - tget |12,17,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz - pushl @__label_3 |13,2,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz - pushi 1 |17,42,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz - callc |17,42,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz - pushs 1 |18,4,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz - gload |18,4,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz - pushi 1 |18,6,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz - eq |18,7,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz - jumpz @__label_4 |18,8,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz - pushs 2 |19,1,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz - gload |19,1,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz - pushs 19 |19,2,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz - tget |19,6,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz - pushl @__label_6 |19,7,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz - pushi 1 |19,34,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz - callc |19,34,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz - pushs 1 |20,1,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz - pushi 0 |20,2,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz - gstore |20,3,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz - jump @__label_5 |22,4,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz -@__label_4 |22,4,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz - pushs 2 |23,1,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz - gload |23,1,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz - pushs 19 |23,2,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz - tget |23,6,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz - pushl @__label_7 |23,7,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz - pushi 1 |23,51,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz - callc |23,51,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz - pushs 1 |24,1,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz - pushi 1 |24,2,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz - gstore |24,3,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz -@__label_5 |25,1,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz - ret0 |35,1,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz - -@__label_3 - pushs 9 |14,9,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz - gload |14,9,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz - pushs 10 |14,10,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz - lload 1 |14,23,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz - pushs 11 |14,25,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz - pushs 12 |15,8,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz - lload 2 |15,28,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz - pushs 13 |15,29,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz - tget |15,37,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz - pushs 14 |15,39,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz - pushs 15 |16,8,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz - lload 2 |16,28,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz - pushs 16 |16,29,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz - tget |16,36,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz - pushs 14 |16,38,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz - pushs 17 |17,8,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz - lload 2 |17,28,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz - pushs 18 |17,29,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz - tget |17,38,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz - pushi 11 |17,40,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz - callc |17,40,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz - ret0 |17,41,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz - -@__label_6 - pushs 20 |19,30,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz - gload |19,30,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz - pushi 0 |19,32,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz - callc |19,32,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz - ret0 |19,33,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz - -@__label_7 - pushs 21 |23,27,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz - gload |23,27,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz - pushf 1.1234 |23,28,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz - pushf 2.2345 |23,35,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz - pushf 3.3456 |23,42,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz - pushi 3 |23,49,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz - callc |23,49,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz - ret0 |23,50,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz - -@__label_8 - ret0 |39,1,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz - -@__label_9 - ret0 |43,1,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz diff --git a/src/out.bdbg b/src/out.bdbg deleted file mode 100644 index 53ec6f761cd3d2537849cd01e36c9b394169e332..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6120 zcmb`LJxml)6op6SM{p4Vqu?*dk3S@gNTQ84G}>rmqm2gEP23RKgk3P1MjIQo(ZPe)8ygyJY;0__P>G2@iPAs=1)dD=#?#(2?=}0H`|UaBzPbB$R<h^rnBr37&}94o5)xt9S20l zW75$sGERcg6>3k2jBzl!Lv54DSfe}!MaC1#!+PxP?db?!&Jd$T^s+&DsC{`#dGv`o z&XSi_kV9&e^^$csA1 zRw8)062Z$V=}_-uSD|Bf$P(Lpc{5$4Ow}2*hHtjBZfDJ_;~IHUpOKss57WJf|n{7cGt%?UtTXQ z5p=YI(Hy>C)$sv^mZ>@mXTd0%M~xWjb6WzVXdWHJP<4C+!!lK8VT1Be?;rETP=EKk zDGyc0C(1*eV?CrpefB?-j$`6;n}K0xeL`gPM)2}Af|oup>|9`*FYg@tMmmm*jD28~ zLall)Tmr-X-yRZm+ySF#Z|{Q98@?age0eiHjKZRM`~ah99{r?4y<7ey9sOb+_rS1B z)tNj@UTijd`|>A(mk}^JLJq2z`;>=zr~6A@2E@KR0An!JVw*2-rpqX_XHI=L{t%3! O@5V>Luydil`}_wAnT!Ac diff --git a/src/out.bo b/src/out.bo deleted file mode 100644 index 8a95520bdb92df3610cef8bc3ed517d8cf6f2303..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 525 zcmZ9IZB7C)5QYbI{Q^b&DiN|fMx%c`fr*hD_|LzlECWP2-#9jn#uHW4^)tgbo~v*-=Dz>urZ=CyF2;TqVr-$2;Cj4K#ySy# z6)9D*arRACP23V#o5Afltk2+%z)ZIDckJ<^;v{VL#iSpf?^kKHTx+M-=}kM6pVCT_ F neighbours_pos_map; static int timer_step=0; +static int robot_id=0; /*Refresh neighbours Position for every ten step*/ void maintain_pos(int tim_step){ @@ -188,19 +187,38 @@ static void ctrlc_handler(int sig) { int main(int argc, char **argv) { - /*Compile the buzz code .bzz to .bo*/ - system("rm ../catkin_ws/src/rosbuzz/src/out.basm ../catkin_ws/src/rosbuzz/src/out.bo ../catkin_ws/src/rosbuzz/src/out.bdbg"); - system("bzzparse ../catkin_ws/src/rosbuzz/src/test.bzz ../catkin_ws/src/rosbuzz/src/out.basm"); - system("bzzasm ../catkin_ws/src/rosbuzz/src/out.basm ../catkin_ws/src/rosbuzz/src/out.bo ../catkin_ws/src/rosbuzz/src/out.bdbg"); - + ros::ServiceServer service; /*initiate rosBuzz*/ ros::init(argc, argv, "rosBuzz"); ROS_INFO("Buzz_node"); - + /*Create node Handler*/ ros::NodeHandle n_c; + std::string bzzfile_name, fcclient_name, rcservice_name; //, rcclient; + bool rcclient; + /*Obtain .bzz file name from parameter server*/ + if(ros::param::get("/rosbuzz_node/bzzfile_name", bzzfile_name)); + else {ROS_ERROR("Provide a .bzz file to run in Launch file"); system("rosnode kill rosbuzz_node");} + + /*Obtain rc service option from parameter server*/ + if(ros::param::get("/rosbuzz_node/rcclient", rcclient)){ + if(rcclient==true){ + /*Service*/ + if(ros::param::get("/rosbuzz_node/rcservice_name", rcservice_name)){ + service = n_c.advertiseService(rcservice_name, rc_callback); + ROS_INFO("Ready to receive Mav Commands from RC client"); + } + else{ROS_ERROR("Provide a name topic name for rc service in Launch file"); system("rosnode kill rosbuzz_node");} + } + else if(rcclient==false){ROS_INFO("RC service is disabled");} + } + else{ROS_ERROR("Provide a rc client option: yes or no in Launch file"); system("rosnode kill rosbuzz_node");} + /*Obtain fc client name from parameter server*/ + if(ros::param::get("/rosbuzz_node/fcclient_name", fcclient_name)); + else {ROS_ERROR("Provide a fc client name in Launch file"); system("rosnode kill rosbuzz_node");} + /*Obtain robot_id from parameter server*/ + ros::param::get("/rosbuzz_node/robot_id", robot_id); - /*subscribers*/ ros::Subscriber current_position_sub = n_c.subscribe("current_pos", 1000, current_pos); @@ -213,16 +231,20 @@ int main(int argc, char **argv) ros::Publisher payload_pub = n_c.advertise("outMavlink", 1000); /* Clients*/ - ros::ServiceClient mav_client = n_c.serviceClient("djicmd"); + ros::ServiceClient mav_client = n_c.serviceClient(fcclient_name); + cout<< " rc client name"<