Communication between ROS/Gazebo in Linux with Visual Studio App in Windows [closed]

asked 2016-08-26 03:02:38 -0600

imranz30 gravatar image

updated 2016-08-28 14:04:41 -0600

gvdhoorn gravatar image


Some background I am involved in a project that requires connection between a Visual Studio Application in Windows and ROS/Gazebo in Linux. I have successfully integrated the two applications together. In ROS/Gazebo I have a robot with a Laser Scanner attached which is publishing distance readings which I process and convert to two readings and send over to the Visual Studio Application where those distance readings will be processed further and give out velocity readings which will be sent to the ROS/Gazebo system at cmd_vel topic allowing the robot to move.

My Problem Now my problem is how to make the communication between the two applications run smoothly. I cannot have the following going on in the Visual Studio application to get the data:

ros::NodeHandle nh;
ros::Subscriber<std_msgs::Float64MultiArray> sensor_sub("msg", &sensor_callback);

The problem with the above code is that there is a while(1) loop which always blocks, so I cannot process the data once I get it because while(1) won't let me get out of it. That is problem number 1. My second problem is related with sending twist message to the robot in Gazebo from Visual Studio application which again runs into the same problem of while(1) keeps blocking. Something like the below code:

geometry_msgs::Twist twist_msg;
ros::Publisher cmd_vel_pub("cmd_vel", & twsit_msg);
   twist_msg.linear.x = x;
   twist.msg.linear.y = y;
   twist.msg.linear.z = z;
   twist.msg.angular.x = ax;
   twist.msg.angular.y = ay;
   twist.msg.angular.z = az;

The values x,y,z,ax,ay,az are computed inside the Visual Studio application. This is even a bigger problem since I am using rosserial_windows and it requires sometime to sync with the device in order to receive data packets, at least this is how its working with me.

Now this is a continuous process, I should keep getting new distances and process them and keep sending new velocities to see how the robot moves. The velocity values are computed through a genetic algorithm. So is there an effective way to solve this communication problem.

I will appreciate any pointers or referral links.


edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by imranz30
close date 2017-01-13 09:53:56.721753