Network issue: messages not received from rqt
I made a simple sub node with roscpp using ros kinetic on ubuntu 16.04. I have 2 computers on my network :
192.168.1.234 : Raspberry PI
ROS net config :
export ROS_IP=192.168.1.234
Result of ifconfig
:
can0 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
UP RUNNING NOARP MTU:16 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:10
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
enxb827eb71bd25 Link encap:Ethernet HWaddr b8:27:eb:71:bd:25
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:345 errors:0 dropped:0 overruns:0 frame:0
TX packets:345 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1
RX bytes:23349 (23.3 KB) TX bytes:23349 (23.3 KB)
wlan0 Link encap:Ethernet HWaddr b8:27:eb:24:e8:70
inet addr:192.168.1.234 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::ee4b:a2a1:2c41:573b/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:197 errors:0 dropped:38 overruns:0 frame:0
TX packets:173 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:27509 (27.5 KB) TX bytes:24228 (24.2 KB)
_Running node : _
roscore &
rosrun ros-ws Test
192.168.1.102 : Laptop
_ROS net config : _
export ROS_IP=192.168.1.102
export ROS_MASTER_URI="http://192.168.1.234:11311"
_Result of ifconfig
: _
eno1 Link encap:Ethernet HWaddr 3c:52:82:62:c9:0f
inet adr:192.168.1.102 Bcast:192.168.1.255 Masque:255.255.255.0
adr inet6: fe80::303c:5b78:aff2:99b0/64 Scope:Lien
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
Packets reçus:289050 erreurs:0 :9 overruns:0 frame:0
TX packets:595541 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 lg file transmission:1000
Octets reçus:80850321 (80.8 MB) Octets transmis:671744125 (671.7 MB)
Interruption:20 Mémoire:f3100000-f3120000
lo Link encap:Boucle locale
inet adr:127.0.0.1 Masque:255.0.0.0
adr inet6: ::1/128 Scope:Hôte
UP LOOPBACK RUNNING MTU:65536 Metric:1
Packets reçus:441028 erreurs:0 :0 overruns:0 frame:0
TX packets:441028 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 lg file transmission:1000
Octets reçus:255498349 (255.4 MB) Octets transmis:255498349 (255.4 MB)
_Running node : _
rqt
The node run on the raspberry Pi and is launched through ssh by the laptop. I use RQT to debug this node.
After building and launching, it's impossible for this node to receive messages from rqt.
I got the following warning at runtime on both terminals (PC and PI):
Couldn't find an AF_INET address for [my_hostname]
Just after launch I can send messages from the terminal on the Pi using rostopic pub
and the node receive it.
But if I try to execute rqt and send messages on the same topic, the error appears. After that, messages from rostopic
or rqt never reach the node. However rqt graph still show my node connected to the topic.
Here is my c++ sub code:
#include "ros/ros.h"
#include "std_msgs/String.h"
class Test
{
public:
Test(){
test_subscriber = node.subscribe("/testSub", 1, &Test::testFunction, this);
}
void testFunction(const std_msgs::String::ConstPtr& msg) {
ROS_INFO("test");
}
private:
// Node
ros::NodeHandle node;
// Subscriber
ros::Subscriber test_subscriber;
// Internal variables
std_msgs::String testMsgPub;
int i;
};
int main(int argc, char **argv)
{
// Node initialization
ros::init(argc, argv, "test_node");
// Balancing class Initialization
Test testClass;
// infinite loop starting
ros::spin();
return 0;
}
My CMakeLists.txt:
cmake_minimum_required(VERSION 2.8.3)
project(test_pkg)
find_package(catkin REQUIRED
std_msgs
roscpp
)
catkin_package(
CATKIN_DEPENDS roscpp
)
include_directories(
include
${catkin_INCLUDE_DIRS}
/lib:/usr/lib
/usr/local/lib
)
add_executable(Test src/test.cpp)
## Specify libraries to link a library or executable target against
target_link_libraries(Test
${catkin_LIBRARIES}
)
and my package.xml:
<?xml version="1.0"?>
<package format="2">
<name>test_pkg</name>
<version>0.0.0</version>
<description>The test_pkg package</description>
<maintainer email="body@todo.todo">body</maintainer>
<license>TODO</license>
<buildtool_depend>catkin</buildtool_depend>
<build_depend>roscpp</build_depend>
<build_depend>roslaunch</build_depend>
<build_depend>std_msgs</build_depend>
<build_export_depend>roscpp</build_export_depend>
<build_export_depend>std_msgs</build_export_depend>
<exec_depend>roscpp</exec_depend>
<exec_depend>std_msgs</exec_depend>
<export>
</export>
</package>
Asked by simchanu on 2018-06-08 09:54:35 UTC
Answers
I am the asker of the question.
My issue is solved. I tested this morning, this test package now works fine. Since everything seemed fine codewise, I suspect a hardware issue on networking. The only thing that changed in the code was to change a printf
to a ROS_INFO
.
Anyway, for anyone having this issue, the question should hold all the information for solving a common AF_INET
error.
Asked by simchanu on 2018-06-11 02:23:27 UTC
Comments
So you set these variables to some values, started your nodes and nothing happened? That seems highly unlikely.
Please be more specific (ie: tell us which values you used). Otherwise we cannot help you.
Asked by gvdhoorn on 2018-06-09 05:55:18 UTC
I added, more informations about the network configuration and clarified the description. It seems it's a network configuration issue but I can't find where I got wrong.
Asked by simchanu on 2018-06-11 01:51:21 UTC