Connecting to ROS using rosserial on Windows?

asked 2018-03-03 12:00:55 -0500

sdcguy gravatar image

updated 2018-03-03 12:32:48 -0500

I have ROS running on my Linux machine and I wanna connect to ROS using rosserial on Windows. So I have been following the tutorial on rosserial given here: http://wiki.ros.org/rosserial_windows... This is what my code looks like which is pretty much the same as the tutorial:

// ConsoleApplication1.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <string>
#include <stdio.h>
#include "ros.h"
#include <std_msgs/Float32.h>
#include <windows.h>


using std::string;



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

    printf("Connecting to server at %s\n", ros_master);
    nh.initNode (ros_master);
    printf("Advertising message\n");
    std_msgs::Float32 a;
    ros::Publisher cmd("", &a);
    nh.advertise(cmd);

    printf("Go Car!\n");

    while (1)
    {
        nh.spinOnce();
        Sleep(100);
    }

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

So, I am getting these errors with the code (the part where I am giving the IP of my Linux machine). I am doing it the same way it is done in the tutorial. Don't understand what is wrong with the way i am passing the IP address here

Severity    Code    Description Project File    Line    Suppression State
Error (active)  E0144   a value of type "const char *" cannot be used to initialize an entity of type "char *"  ConsoleApplication1 c:\Users\kaela\source\repos\ConsoleApplication1\ConsoleApplication1\ConsoleApplication1.cpp 19  

Severity    Code    Description Project File    Line    Suppression State
Error   C2664   'void ros::NodeHandle_<WindowsSocket,25,25,512,512>::initNode(char *)': cannot convert argument 1 from 'const char *' to 'char *'   ConsoleApplication1 c:\users\kaela\source\repos\consoleapplication1\consoleapplication1\consoleapplication1.cpp 22

Can't seem to figure out what the problem is.

edit retag flag offensive close merge delete

Comments

2

Can you clarify how this is related to #q284294?

gvdhoorn gravatar image gvdhoorn  ( 2018-03-03 13:42:47 -0500 )edit

These are just 2 different things i am having trouble with. But this is the more important one. I would like to establish the connection first. If I can do that I will most probably figure the rest out.

sdcguy gravatar image sdcguy  ( 2018-03-03 13:51:57 -0500 )edit