auto compile of buzz script

This commit is contained in:
Vivek 2016-09-20 12:37:33 -04:00
parent 9045ed49f2
commit f8dc591efc
6 changed files with 121 additions and 19 deletions

View File

@ -25,10 +25,10 @@ int buzzros_print(buzzvm_t vm) {
ROS_INFO("BUZZ - [nil]");
break;
case BUZZTYPE_INT:
//fprintf(stdout, "%d", o->i.value);
fprintf(stdout, "%d", o->i.value);
break;
case BUZZTYPE_FLOAT:
//fprintf(stdout, "%f", o->f.value);
fprintf(stdout, "%f", o->f.value);
break;
case BUZZTYPE_TABLE:
//fprintf(stdout, "[table with %d elems]", (buzzdict_size(o->t.value)));
@ -42,7 +42,7 @@ int buzzros_print(buzzvm_t vm) {
//fprintf(stdout, "[c-closure @%d]", o->c.value.ref);
break;
case BUZZTYPE_STRING:
//fprintf(stdout, "%s", o->s.value.str);
fprintf(stdout, "%s", o->s.value.str);
break;
case BUZZTYPE_USERDATA:
//fprintf(stdout, "[userdata @%p]", o->u.value);

View File

@ -1,20 +1,31 @@
!4
!15
'init
'id
'mydist
'neighbors
'listen
'dist_to_source
'math
'min
'get
'distance
'step
'broadcast
'print
'reset
'destroy
pushs 0
pushcn @__label_1
gstore
pushs 1
pushcn @__label_2
pushs 10
pushcn @__label_5
gstore
pushs 2
pushcn @__label_3
pushs 13
pushcn @__label_6
gstore
pushs 3
pushcn @__label_4
pushs 14
pushcn @__label_7
gstore
nop
@ -24,13 +35,74 @@
done
@__label_1
ret0 |3,1,/home/vivek/BuzzKH4/build/test.bzz
@__label_2
ret0 |7,1,/home/vivek/BuzzKH4/build/test.bzz
@__label_3
ret0 |11,1,/home/vivek/BuzzKH4/build/test.bzz
pushs 1 |3,6,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz
gload |3,6,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz
pushi 0 |3,9,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz
eq |3,10,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz
jumpz @__label_2 |3,12,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz
pushs 2 |5,11,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz
pushf 0. |5,13,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz
gstore |5,15,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz
jump @__label_3 |7,7,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz
@__label_2 |7,7,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz
pushs 2 |9,11,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz
pushf 1000. |9,13,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz
gstore |9,18,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz
pushs 3 |11,13,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz
gload |11,13,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz
pushs 4 |11,14,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz
tget |11,20,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz
pushs 5 |11,21,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz
pushl @__label_4 |12,6,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz
pushi 2 |16,8,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz
callc |16,8,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz
@__label_3 |17,3,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz
ret0 |18,1,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz
@__label_4
ret0 |15,1,/home/vivek/BuzzKH4/build/test.bzz
pushs 2 |13,15,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz
pushs 6 |13,21,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz
gload |13,21,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz
pushs 7 |13,22,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz
tget |13,25,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz
pushs 2 |14,16,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz
gload |14,16,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz
pushs 3 |15,19,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz
gload |15,19,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz
pushs 8 |15,20,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz
tget |15,23,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz
lload 3 |15,32,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz
pushi 1 |15,33,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz
callc |15,33,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz
pushs 9 |15,34,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz
tget |15,43,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz
lload 2 |15,50,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz
add |15,50,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz
pushi 2 |15,51,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz
callc |15,51,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz
gstore |15,51,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz
ret0 |16,7,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz
@__label_5
pushs 3 |22,9,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz
gload |22,9,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz
pushs 11 |22,10,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz
tget |22,19,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz
pushs 5 |22,20,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz
pushs 2 |22,44,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz
gload |22,44,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz
pushi 2 |22,45,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz
callc |22,45,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz
pushs 12 |23,5,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz
gload |23,5,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz
pushs 2 |23,12,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz
gload |23,12,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz
pushi 1 |23,13,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz
callc |23,13,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz
ret0 |26,1,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz
@__label_6
ret0 |30,1,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz
@__label_7
ret0 |34,1,/home/vivek/catkin_ws/src/rosbuzz/src/test.bzz

Binary file not shown.

Binary file not shown.

View File

@ -28,6 +28,10 @@
#include <math.h>
#include <signal.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
static int done = 0;
static double cur_pos [3];
@ -35,6 +39,7 @@ double distance;
double azimuth;
double elevation;
/**
* This tutorial demonstrates simple sending of messages over the ROS system.
*/
@ -122,6 +127,10 @@ static void ctrlc_handler(int sig) {
int main(int argc, char **argv)
{
system("bzzparse /home/vivek/catkin_ws/src/rosbuzz/src/test.bzz /home/vivek/catkin_ws/src/rosbuzz/src/out.basm");
system("bzzasm /home/vivek/catkin_ws/src/rosbuzz/src/out.basm /home/vivek/catkin_ws/src/rosbuzz/src/out.bo /home/vivek/catkin_ws/src/rosbuzz/src/out.bdbg");
// %Tag(INIT)%
ros::init(argc, argv, "rosBuzz");
// %EndTag(INIT)%
@ -175,6 +184,7 @@ int main(int argc, char **argv)
fprintf(stderr, "%s: invalid value %d for message size\n", argv[0], msg_sz);
return 0;
} */
/* The bytecode filename */
char* bcfname = "/home/vivek/catkin_ws/src/rosbuzz/src/out.bo"; //argv[1];
/* The debugging information file name */

View File

@ -1,9 +1,28 @@
# Executed once at init time.
function init() {
if(id == 0) {
# Source robot
mydist = 0.
}
else {
# Other robots
mydist = 1000.
# Listen to other robots' distances
neighbors.listen("dist_to_source",
function(value_id, value, robot_id) {
mydist = math.min(
mydist,
neighbors.get(robot_id).distance + value)
})
}
}
# Executed at each time step.
function step() {
neighbors.broadcast("dist_to_source", mydist)
print(mydist)
}
# Executed once when the robot (or the simulator) is reset.
@ -13,3 +32,4 @@ function reset() {
# Executed once at the end of experiment.
function destroy() {
}