addition of robots variable inside BVM and for updates barrier

This commit is contained in:
vivek-shankar 2017-04-02 15:06:36 -04:00
parent 29b234cd9d
commit 4c1c3dff43
5 changed files with 23 additions and 4 deletions

View File

@ -73,7 +73,7 @@ void update_routine(const char* bcfname,
/************************************************/
/*Initalizes the updater */
/************************************************/
void init_update_monitor(const char* bo_filename,const char* stand_by_script,int barrier);
void init_update_monitor(const char* bo_filename,const char* stand_by_script);
/*********************************************************/
@ -129,4 +129,6 @@ int get_update_status();
void set_read_update_status();
void updates_set_robots(int robots);
#endif

View File

@ -52,4 +52,6 @@ int update_step_test();
uint16_t get_robotid();
buzzvm_t get_vm();
void set_robot_var(int ROBOTS);
}

View File

@ -27,7 +27,7 @@ static int neigh=-1;
static int updater_msg_ready ;
static int updated=0;
void init_update_monitor(const char* bo_filename, const char* stand_by_script,int barrier){
void init_update_monitor(const char* bo_filename, const char* stand_by_script){
fprintf(stdout,"intiialized file monitor.\n");
fd=inotify_init1(IN_NONBLOCK);
if ( fd < 0 ) {
@ -91,7 +91,7 @@ void init_update_monitor(const char* bo_filename, const char* stand_by_script,in
*(size_t*)(updater->standby_bcode_size)=stdby_bcode_size;
updater->mode=(int*)malloc(sizeof(int));
*(int*)(updater->mode)=CODE_RUNNING;
no_of_robot=barrier;
//no_of_robot=barrier;
updater_msg_ready=0;
//neigh = 0;
//updater->outmsg_queue=
@ -444,6 +444,11 @@ close(fd);
void set_bzz_file(const char* in_bzz_file){
bzz_file=in_bzz_file;
}
void updates_set_robots(int robots){
no_of_robot=robots;
}
void collect_data(){
//fprintf(stdout,"start and end time in data collection Info : %f,%f",(double)begin,(double)end);
double time_spent = (t2.tv_sec - t1.tv_sec) * 1000.0; //(double)(end - begin) / CLOCKS_PER_SEC;

View File

@ -548,6 +548,11 @@ buzzvm_t get_vm(){
return VM;
}
void set_robot_var(int ROBOTS){
buzzvm_pushs(VM, buzzvm_string_register(VM, "ROBOTS", 1));
buzzvm_pushi(VM, ROBOTS);
buzzvm_gstore(VM);
}
}

View File

@ -52,7 +52,7 @@ namespace rosbzz_node{
/* Set the Buzz bytecode */
if(buzz_utility::buzz_script_set(bcfname.c_str(), dbgfname.c_str(),robot_id)) {
fprintf(stdout, "Bytecode file found and set\n");
init_update_monitor(bcfname.c_str(),stand_by.c_str(),barrier);
init_update_monitor(bcfname.c_str(),stand_by.c_str());
while (ros::ok() && !buzz_utility::buzz_script_done())
{
/*Update neighbors position inside Buzz*/
@ -72,6 +72,10 @@ namespace rosbzz_node{
set_read_update_status();
multi_msg=true;
}
/*Set ROBOTS variable for barrier in .bzz from neighbours count*/
buzz_utility::set_robot_var(neighbours_pos_map.size());
/*Set no of robots for updates*/
updates_set_robots(neighbours_pos_map.size());
/*run once*/
ros::spinOnce();
/*loop rate of ros*/
@ -81,6 +85,7 @@ namespace rosbzz_node{
timer_step+=1;
maintain_pos(timer_step);
}
/* Destroy updater and Cleanup */
//update_routine(bcfname.c_str(), dbgfname.c_str(),1);