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

Leonardo_610's profile - activity

2017-07-27 08:17:07 -0500 received badge  Famous Question (source)
2017-02-25 09:21:55 -0500 received badge  Notable Question (source)
2017-02-25 08:58:04 -0500 commented answer Having trouble sending a message to ROS

Yes I fixed that. Thanks! Now it works :D

2017-02-24 15:46:56 -0500 received badge  Popular Question (source)
2017-02-24 11:45:20 -0500 received badge  Scholar (source)
2017-02-24 11:45:14 -0500 received badge  Scholar (source)
2017-02-24 11:45:11 -0500 received badge  Supporter (source)
2017-02-24 11:44:28 -0500 answered a question Having trouble sending a message to ROS

Thanks for the clarity.

So I have modified my code in this way:

#include "stdafx.h"
#include "ros.h"
#include <string>
#include <stdio.h>
#include <Windows.h>
#include <std_msgs\String.h>

int _tmain(int argc, _TCHAR * argv[])
{
    ros::NodeHandle nh;
    char *ros_master = "*.*.*.*";

    printf("Connecting to server at %s\n", ros_master);
    nh.initNode(ros_master);

    printf("Advertising cmd_vel message\n");
    std_msgs::String sent;
    ros::Publisher cmd_vel_pub("try", &sent);
    nh.advertise(cmd_vel_pub);
    while (1) {
        sent.data = "Hello robot";
        cmd_vel_pub.publish(&sent);
        nh.spinOnce();
        Sleep(10);
    }
    printf("All done!\n");
    return 0;
}

But it has not builded yet. Now I have errors related to Windows socket or stuff like that.

1>------ Build started: Project: LeapMotion, Configuration: Debug Win32 ------
1>  LeapMotion.cpp
1>LeapMotion.obj : error LNK2019: unresolved external symbol "public: __thiscall WindowsSocket::WindowsSocket(void)" (??0WindowsSocket@@QAE@XZ) referenced in function "public: __thiscall ros::NodeHandle_<class WindowsSocket,25,25,512,512>::NodeHandle_<class WindowsSocket,25,25,512,512>(void)" (??0?$NodeHandle_@VWindowsSocket@@$0BJ@$0BJ@$0CAA@$0CAA@@ros@@QAE@XZ)
1>LeapMotion.obj : error LNK2019: unresolved external symbol "public: void __thiscall WindowsSocket::init(char *)" (?init@WindowsSocket@@QAEXPAD@Z) referenced in function "public: void __thiscall ros::NodeHandle_<class WindowsSocket,25,25,512,512>::initNode(char *)" (?initNode@?$NodeHandle_@VWindowsSocket@@$0BJ@$0BJ@$0CAA@$0CAA@@ros@@QAEXPAD@Z)
1>LeapMotion.obj : error LNK2019: unresolved external symbol "public: int __thiscall WindowsSocket::read(void)" (?read@WindowsSocket@@QAEHXZ) referenced in function "public: virtual int __thiscall ros::NodeHandle_<class WindowsSocket,25,25,512,512>::spinOnce(void)" (?spinOnce@?$NodeHandle_@VWindowsSocket@@$0BJ@$0BJ@$0CAA@$0CAA@@ros@@UAEHXZ)
1>LeapMotion.obj : error LNK2019: unresolved external symbol "public: void __thiscall WindowsSocket::write(unsigned char const *,int)" (?write@WindowsSocket@@QAEXPBEH@Z) referenced in function "public: virtual int __thiscall ros::NodeHandle_<class WindowsSocket,25,25,512,512>::publish(int,class ros::Msg const *)" (?publish@?$NodeHandle_@VWindowsSocket@@$0BJ@$0BJ@$0CAA@$0CAA@@ros@@UAEHHPBVMsg@2@@Z)
1>LeapMotion.obj : error LNK2019: unresolved external symbol "public: unsigned long __thiscall WindowsSocket::time(void)" (?time@WindowsSocket@@QAEKXZ) referenced in function "public: void __thiscall ros::NodeHandle_<class WindowsSocket,25,25,512,512>::requestSyncTime(void)" (?requestSyncTime@?$NodeHandle_@VWindowsSocket@@$0BJ@$0BJ@$0CAA@$0CAA@@ros@@QAEXXZ)
1>LeapMotion.obj : error LNK2019: unresolved external symbol "void __cdecl ros::normalizeSecNSec(unsigned int &,unsigned int &)" (?normalizeSecNSec@ros@@YAXAAI0@Z) referenced in function "public: void __thiscall ros::NodeHandle_<class WindowsSocket,25,25,512,512>::setNow(class ros::Time &)" (?setNow@?$NodeHandle_@VWindowsSocket@@$0BJ@$0BJ@$0CAA@$0CAA@@ros@@QAEXAAVTime@2@@Z)
1>C:\Users\Vive-VR-PC\Documents\Visual Studio 2015\Projects\LeapMotion\Debug\LeapMotion.exe : fatal error LNK1120: 6 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Can't understand why. I have included all the libraries I need to.

2017-02-24 11:36:54 -0500 commented question Having trouble sending a message to ROS

I am sorry, didn't know exactly how works ROS, that's why.

2017-02-24 11:04:07 -0500 commented question Having trouble sending a message to ROS

Ok I will try... thanks for the help. But I would like to know why the code above doesn't work...

2017-02-24 09:27:56 -0500 commented question Having trouble sending a message to ROS

I need to send the coordinates of hands taken with LeapMotion and head taken with HTC Vive to the linux machine. Actually I don't need to use Visual Studio, it is just to start to understand ROS. I would use Unity and C# instead of C++.

2017-02-24 09:18:54 -0500 asked a question Having trouble sending a message to ROS

I am pretty new in ROS. I am just trying to publish a message to a node in a linux server with this code:

#include "stdafx.h"
#include "ros.h"
#include <string>
#include <stdio.h>
#include <Windows.h>

using std::string;

int _tmain(int argc, _TCHAR * argv[])
{
    ros::NodeHandle nh;
    char *ros_master = "*.*.*.*";

    printf("Connecting to server at %s\n", ros_master);
    nh.initNode(ros_master);

    printf("Advertising cmd_vel message\n");
    string sent = "Hello robot";
    ros::Publisher cmd_vel_pub("try", sent);
    nh.advertise(cmd_vel_pub);

    printf("All done!\n");
    return 0;
}

The compiler gives me these errors:

 Error  C2664 'ros::Publisher::Publisher(ros::Publisher &&)': cannot convert argument 2 from 'std::string' to 'ros::Msg *'  LeapMotion     c:\users\vive-vr-pc\documents\visual studio    2015\projects\leapmotion\leapmotion\leapmotion.cpp    22  
Error (active)  no instance of constructor "ros::Publisher::Publisher" matches the argument list    LeapMotion  c:\Users\Vive-VR-PC\Documents\Visual Studio 2015\Projects\LeapMotion\LeapMotion\LeapMotion.cpp  22

I am on Visual Studio 2015 and there aren't a lot of tutorial from windows to linux, so I am confused on what to do. Many thanks for the help! :D


Edit: Thanks for the clarity.

So I have modified my code in this way:

#include "stdafx.h"
#include "ros.h"
#include <string>
#include <stdio.h>
#include <Windows.h>
#include <std_msgs\String.h>

int _tmain(int argc, _TCHAR * argv[])
{
    ros::NodeHandle nh;
    char *ros_master = "*.*.*.*";

    printf("Connecting to server at %s\n", ros_master);
    nh.initNode(ros_master);

    printf("Advertising cmd_vel message\n");
    std_msgs::String sent;
    ros::Publisher cmd_vel_pub("try", &sent);
    nh.advertise(cmd_vel_pub);
    while (1) {
        sent.data = "Hello robot";
        cmd_vel_pub.publish(&sent);
        nh.spinOnce();
        Sleep(10);
    }
    printf("All done!\n");
    return 0;
}

But it has not builded yet. Now I have errors related to Windows socket or stuff like that.

1>------ Build started: Project: LeapMotion, Configuration: Debug Win32 ------
1>  LeapMotion.cpp
1>LeapMotion.obj : error LNK2019: unresolved external symbol "public: __thiscall WindowsSocket::WindowsSocket(void)" (??0WindowsSocket@@QAE@XZ) referenced in function "public: __thiscall ros::NodeHandle_<class WindowsSocket,25,25,512,512>::NodeHandle_<class WindowsSocket,25,25,512,512>(void)" (??0?$NodeHandle_@VWindowsSocket@@$0BJ@$0BJ@$0CAA@$0CAA@@ros@@QAE@XZ)
1>LeapMotion.obj : error LNK2019: unresolved external symbol "public: void __thiscall WindowsSocket::init(char *)" (?init@WindowsSocket@@QAEXPAD@Z) referenced in function "public: void __thiscall ros::NodeHandle_<class WindowsSocket,25,25,512,512>::initNode(char *)" (?initNode@?$NodeHandle_@VWindowsSocket@@$0BJ@$0BJ@$0CAA@$0CAA@@ros@@QAEXPAD@Z)
1>LeapMotion.obj : error LNK2019: unresolved external symbol "public: int __thiscall WindowsSocket::read(void)" (?read@WindowsSocket@@QAEHXZ) referenced in function "public: virtual int __thiscall ros::NodeHandle_<class WindowsSocket,25,25,512,512>::spinOnce(void)" (?spinOnce@?$NodeHandle_@VWindowsSocket@@$0BJ@$0BJ@$0CAA@$0CAA@@ros@@UAEHXZ)
1>LeapMotion.obj : error LNK2019: unresolved external symbol "public: void __thiscall WindowsSocket::write(unsigned char const *,int)" (?write@WindowsSocket@@QAEXPBEH@Z) referenced in function "public: virtual int __thiscall ros::NodeHandle_<class WindowsSocket,25,25,512,512>::publish(int,class ros::Msg const *)" (?publish@?$NodeHandle_@VWindowsSocket@@$0BJ@$0BJ@$0CAA@$0CAA@@ros@@UAEHHPBVMsg@2@@Z)
1>LeapMotion.obj : error LNK2019: unresolved external symbol "public: unsigned long __thiscall WindowsSocket ...
(more)