publishing a node by using a dll in Visual Basic 2015(Windows)
Hi there,
I have a similar problem as described here and here. I want to send same IMU data from a Visual Basic .NET Application (WIndows) to a ROSmaster (Linux).
Therefore I am using ros_lib from rosserial. The Tutorial you can find here . This tutorial works well, but my appilcation which communicates with my IMU is written in vb.net . So my idea is to write a dll which published a node. Unfortunately several syntax errors appeared then.
Here is my header:
//SendMsgToROS.h
#ifdef SENDMSGDLL_EXPORTS
#define SENDMSGDLL_API __declspec(dllexport)
#else
#define SENDMSGDLL_API __declspec(dllimport)
#endif
namespace SendMsg
{
class Message
{
public:
SENDMSGDLL_API int sendingMsg(int x, int y, int z);
};
}
Here is my main.cpp
#include "stdafx.h"
#include <string>
#include <stdio.h>
#include "ros.h"
#include <geometry_msgs/Twist.h>
#include <windows.h>
#include "SendMsgToROS.h" //Header-File where namespace SendMsg and class Message are defined
using std::string;
namespace SendMsg
{
int Message::sendingMsg(int x, int y, int z)
{
ros::NodeHandle nh;
char *ros_master = "1.1.3.1.1";//ID of ROS Masters'
printf("Connecting to server at %s\n", ros_master);
nh.initNode(ros_master);
printf("Advertising cmd_vel message\n");
geometry_msgs::Twist twist_msg;
ros::Publisher cmd_vel_pub("cmd_vel", &twist_msg);
nh.advertise(cmd_vel_pub);
printf("Go robot go!\n");
while (1)
{
twist_msg.linear.x = x;
twist_msg.linear.y = y;
twist_msg.linear.z = z;
twist_msg.angular.x = 0;
twist_msg.angular.y = 0;
twist_msg.angular.z = -1.8;
cmd_vel_pub.publish(&twist_msg);
nh.spinOnce();
Sleep(100);
}
printf("All done!\n");
return 0;
}
}
Do someone know that I did wrong? Most of the errors appears in the files log.h, node_handle.h . And then there is one warning Warning C4273 'SendMsg::Message::sendingMsg': inconsistent dll linkage
EDIT: I found the following interesting link
Here several errors like C2238, C2143, C2059 appeared during compiling just like at my program.
The best answer in that post was to start a empty project with just putting the include's in it. I did this and in addition to that I add ros_lib to my project as described.
The header which causes all the errors was ros.h. When I tested the tutorial Hello World, I used a WIN32 console application and eyerthing worked fine. So the problem is how to get a dll of that. What have to be done what it works ? Has someone an idea?
It seems that ros_lib is not compatible with VS2015. What do you think ?
I thank you in advance!