ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

ChrisBecken's profile - activity

2018-07-20 11:36:14 -0500 received badge  Famous Question (source)
2018-01-11 09:48:05 -0500 received badge  Famous Question (source)
2018-01-10 09:04:49 -0500 edited answer rosserial-windows sync with device lost

I solved it by calling spinOnce periodically on the windows side before any messages is send Edit: Here a code snippet(

2018-01-10 09:02:05 -0500 commented answer rosserial-windows sync with device lost

You are right. Changed it

2018-01-10 09:00:52 -0500 edited answer rosserial-windows sync with device lost

I solved it by calling spinOnce periodically on the windows side before any messages is send Edit: Here a code snippet(

2018-01-10 08:52:55 -0500 commented answer rosserial-windows sync with device lost

No it isn't. I toke a radom number

2018-01-10 08:52:29 -0500 commented answer rosserial-windows sync with device lost

No it isn't. I toke radom number

2018-01-10 08:25:01 -0500 marked best answer rosserial-windows sync with device lost

Hi everyone,

I am using rosserial for windows and followed the instruction. This works fine, I even build a dll of that, quite similiar to this post . I can send the tutorial message Hello World in my vb.Net program by using this DLL. Now I am trying to send a message with some IMU data, by using a timer in my vb.Net program which calls a function in my DLL. Unfortunately on the Linux side the following message appears "Sync with device lost"

The same message without the timer but with a loop works. Here is the working code of my DLL

extern "C" __declspec(dllexport) void __stdcall PublishData_Something( double x, double y) {
ros::NodeHandle nh;
char *ros_master = "100.111.0.222:11411";//
//printf("Connecting to server at %s\n", ros_master);
nh.initNode(ros_master);
powerball_msgs::ExtPoseInput extPoseInput_msg;
ros::Publisher cmd_vel_pub("cmd_vel", &extPoseInput_msg);
nh.advertise(cmd_vel_pub);
while (1)
{
    extPoseInput_msg.robot.translation.x = x;
    extPoseInput_msg.robot.translation.y = y;
    extPoseInput_msg.robot.translation.z = 0;
    extPoseInput_msg.robot.rotation.x = x;
    extPoseInput_msg.robot.rotation.y = y;
    extPoseInput_msg.robot.rotation.z = 0;
    extPoseInput_msg.gripper.movement = 0;
    extPoseInput_msg.gripper.rel_acceleration = 0;
    extPoseInput_msg.gripper.rel_velocity = 0;
    cmd_vel_pub.publish(&extPoseInput_msg);
    nh.spinOnce();
    Sleep(100);
}

}

this works, the message is send to the Linux computer, but as mentioned I want to use a timer in my vb.net application, so the message can be updated. So I changed the function above Here is the code of the message which throws the error "Sync with device lost"

extern "C" __declspec(dllexport) void __stdcall PublishData_GripperNeu(double rel_vy, double y) {
ros::NodeHandle nh;
char *ros_master = "100.111.0.222:11411";//'
nh.initNode(ros_master);
//printf("Advertising cmd_vel message\n");
powerball_msgs::ExtPoseInput extPoseInput_msg;
ros::Publisher cmd_vel_pub("cmd_vel", &extPoseInput_msg);
nh.advertise(cmd_vel_pub);
extPoseInput_msg.robot.rel_velocity = 0; 
extPoseInput_msg.robot.rel_acceleration = 1;
extPoseInput_msg.gripper.rel_acceleration = 1;
extPoseInput_msg.gripper.rel_velocity = (float)rel_vy;
extPoseInput_msg.gripper.movement = y;
extPoseInput_msg.robot.translation.z = 0;//Setzen der nicht veränderten Werte auf null
extPoseInput_msg.robot.translation.x = 0;
extPoseInput_msg.robot.translation.y = 0;
extPoseInput_msg.robot.rotation.w = 0;
extPoseInput_msg.robot.rotation.x = 0;
extPoseInput_msg.robot.rotation.y = 0;
extPoseInput_msg.robot.rotation.z = 0;
//Publish Message
cmd_vel_pub.publish(&extPoseInput_msg);
nh.spinOnce();

} Now the warning on the Linux side appears "Sync with device lost" every time this message is published. The Biggest difference between this two messages are that the second one do not use a loop because the loop is the timer in my vb.net application. That is wrong with my second message?


Edit: Thank you gvdhoorn

First I make a declaration and then the first function is InitialRos()

ros::NodeHandle nh;
char *ros_master = "100.111.0.222:11411";//
powerball_msgs::ExtPoseInput extPoseInput_msg;
ros::Publisher cmd_vel_pub("cmd_vel", &extPoseInput_msg);

extern "C" __declspec(dllexport) void __stdcall InitialROS() { 
  nh.initNode(ros_master);
  nh.advertise(cmd_vel_pub);}

which I call only once.

and other function, which I call by a timer

extern "C" __declspec(dllexport) void __stdcall PublishData_Gripper(double rel_vy, double y) {

  ros::Publisher cmd_vel_pub("cmd_vel", &extPoseInput_msg);
  nh.advertise(cmd_vel_pub);
  extPoseInput_msg.robot.rel_velocity = 0; //
  extPoseInput_msg.robot.rel_acceleration = 1 ...
(more)
2018-01-10 08:25:00 -0500 received badge  Self-Learner (source)
2018-01-10 08:25:00 -0500 received badge  Teacher (source)
2018-01-10 08:09:44 -0500 commented answer rosserial-windows sync with device lost

I hope that it is much better.

2018-01-10 08:09:16 -0500 edited answer rosserial-windows sync with device lost

I solved it by calling spinOnce periodically on the windows side before any messages is send Edit: Here a code snippet(

2018-01-10 07:17:37 -0500 edited answer rosserial-windows sync with device lost

I solved it by calling spinOnce periodically on the windows side before any messages is send Edit: Here a code snippet(

2018-01-10 07:17:22 -0500 commented answer rosserial-windows sync with device lost

Thank you gvdhooorn. This is a code snippet from a dll. What do you mean by should it all be a single block?

2018-01-10 07:15:09 -0500 commented answer rosserial-windows sync with device lost

Thank you gvdhooorn. What do you mean by should it all be a single block? This is a code snippet from a dll.

2018-01-10 05:34:49 -0500 edited answer rosserial-windows sync with device lost

I solved it by calling spinOnce periodically on the windows side before any messages is send Edit: Here a code snippet(

2018-01-10 04:39:05 -0500 commented question rosserial-windows sync with device lost

I solved it by calling spinOnce periodically

2018-01-10 04:38:14 -0500 received badge  Notable Question (source)
2017-12-20 10:09:37 -0500 received badge  Popular Question (source)
2017-12-20 09:22:30 -0500 commented question rosserial-windows sync with device lost

I didn't see that, I will correct this. Thank you very much But do anyone know what "sync with device lost" mean? Can it

2017-12-20 09:15:15 -0500 commented question rosserial-windows sync with device lost

I didn't see that, I will correct this. Thank you very much But do anyone know what "sync with device lost" mean?

2017-12-20 08:12:50 -0500 edited answer rosserial-windows sync with device lost

Thank you gvdhoorn First I make a declaration and then the first function is InitialRos() ros::NodeHandle nh; char *ro

2017-12-20 07:58:54 -0500 answered a question rosserial-windows sync with device lost

Thank you gvdhoorn One function is InitialRos() extern "C" __declspec(dllexport) void __stdcall InitialROS() { ros::N

2017-12-20 06:40:54 -0500 commented question rosserial-windows sync with device lost

only the topic was advertised by nh.advertide(cmd_vel_pub);

2017-12-20 06:40:15 -0500 commented question rosserial-windows sync with device lost

First I splited the function PublishData_GripperNeu into two parts. Initialisation and PublishData But then I got the er

2017-12-20 04:46:34 -0500 asked a question rosserial-windows sync with device lost

rosserial-windows sync with device lost Hi everyone, I am using rosserial for windows and followed the instruction. Th

2017-08-08 01:52:01 -0500 received badge  Famous Question (source)
2017-07-27 06:06:09 -0500 received badge  Notable Question (source)
2017-07-27 05:28:38 -0500 answered a question Why is 'ros::Publisher': no appropriate default constructor available ?

Thank you very much Wolf!! It works.

2017-07-27 05:28:11 -0500 marked best answer Why is 'ros::Publisher': no appropriate default constructor available ?

Hi,

I want to send some IMU-data form my application ( vb.net ) to Ros on another pc. Therefore I use rosserial_windows. In my application you can choose which data you want to send. The best way is to build a dll. So I can publish the data I wish to. Unfortunately I get two errors with ros::Publisher. Here is piece of my code:

class Connect2ROS {
public:
    ros::NodeHandle nh;
    powerball_msgs::ExtPoseInput extPoseInput_msg;
    //ros::Publisher cmd_vel_pub("cmd_vel", extPoseInput_msg);
    ros::Publisher cmd_vel_pub ;//
    char *ros_master;
    Connect2ROS() {//here an error appears C2512 'ros::Publisher': no appropriate default constructor avialable
        ros::Publisher cmd_vel_pub("cmd_vel", &extPoseInput_msg);
    }

    void InitRosPublish(char *ros_master, std::string topic) { 
        this->ros_master = ros_master;
        printf("Connecting to server at %s\n", ros_master);
        nh.initNode(ros_master);
        printf("Advertising cmd_vel message\n");
        this->cmd_vel_pub = this->nh.advertise< powerball_msgs::ExtPoseInput>("cmd_vel", 1);
//here an error appears C2275 'powerball_msgs::ExtPoseInput':illegal use of this type in expression
        //ros::Publisher cmd_vel_pub("cmd_vel", &extPoseInput_msg);
        /*this->cmd_vel_pub = cmd_vel_pub;*/
        nh.advertise(this->cmd_vel_pub);
    }
    void PublishImuData_Rotation(double rel_vx, double rel_vy, double rel_vz, double x, double y, double z){...}
};

What is wrong? The error appears also when I use e.g. geometry_msgs::Twist as a message. I didn't find any help in the internet. I hope somebody can help me.

Thanks in advance!

2017-07-27 05:28:11 -0500 received badge  Scholar (source)
2017-07-27 00:01:59 -0500 received badge  Popular Question (source)
2017-07-26 07:34:47 -0500 asked a question Why is 'ros::Publisher': no appropriate default constructor available ?

Why is 'ros::Publisher': no appropriate default constructor available ? Hi, I want to send some IMU-data form my applic

2017-05-09 06:43:23 -0500 answered a question publishing a node by using a dll in Visual Basic 2015(Windows)

Hi there, I solved my problem, I comment out the #include "stdafx.h" and then it works. In addition to that I add __cde

2017-05-09 06:12:48 -0500 received badge  Notable Question (source)
2017-04-12 04:52:35 -0500 edited question 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!