gestom / CosPhi

Artificial pheromone system
31 stars 14 forks source link

CosPhi ROS support #7

Closed gemad closed 8 years ago

gemad commented 8 years ago

This ROS python node will listen to the TCP Socket 6666 -which used by the CosPhi- to publish the result of the localization and parsing it then publish ROS topic for each robot with Pose2D stranded geometry msgs the topic name "/2D_RobotID"

to use the ros interface 1) add the folder CosPhi_ros_bridge to "catkin_ws/src" 2) catkin_make 3)run the main program as illustrated at the main tutorial 4) rosrun CosPhi_ros_bridge CosPhi_ros_bridge_node.py 5)rostopic list and you will find topic for each robot detected

gestom commented 8 years ago

Thank you! I am quite busy now, but I will have a look at your pull request during the following week.

gemad commented 8 years ago

Thanks for your help ! okay take your time

gestom commented 8 years ago

There are two issues to be resolved:

1) Naming convention: catkin_make complains that: WARNING: Package name "CosPhi_ros_bridge" does not follow the naming conventions. It should start with a lower case letter and only contain lower case letters, digits and underscores.

2) When I try to run "rosrun CosPhi_ros_bridge CosPhi_ros_bridge_node.py", I get:

/home/gestom/svn/projects/CosPhi/src/CosPhi_ros_bridge/scripts/CosPhi_ros_bridge_node.py:17: SyntaxWarning: The publisher should be created with an explicit keyword argument 'queue_size'. Please see http://wiki.ros.org/rospy/Overview/Publishers%20and%20Subscribers for more information. pub = rospy.Publisher('poses', String) /opt/ros/indigo/lib/python2.7/dist-packages/rospy/topics.py:803: UserWarning: '2D_000' is not a legal ROS graph resource name. This may cause problems with other ROS tools super(Publisher, self).init(name, data_class, Registration.PUB) /home/gestom/svn/projects/CosPhi/src/CosPhi_ros_bridge/scripts/CosPhi_ros_bridge_node.py:29: SyntaxWarning: The publisher should be created with an explicit keyword argument 'queue_size'. Please see http://wiki.ros.org/rospy/Overview/Publishers%20and%20Subscribers for more information. pub1 = rospy.Publisher(Topic_Name, Pose2D) /opt/ros/indigo/lib/python2.7/dist-packages/rospy/topics.py:803: UserWarning: '2D_0' is not a legal ROS graph resource name. This may cause problems with other ROS tools super(Publisher, self).init(name, data_class, Registration.PUB) Traceback (most recent call last): File "/home/gestom/svn/projects/CosPhi/src/CosPhi_ros_bridge/scripts/CosPhi_ros_bridge_node.py", line 45, in main()
File "/home/gestom/svn/projects/CosPhi/src/CosPhi_ros_bridge/scripts/CosPhi_ros_bridge_node.py", line 30, in main

The output of the swarmcon socket 6666 looks like this:

Detected 0 of 1 at 1459225221907963. Robot 000 0.000 0.000 0.000 1459225221907963 Detected 0 of 1 at 1459225221964419. Robot 000 0.000 0.000 0.000 1459225221964419 Detected 0 of 1 at 1459225222020333. Robot 000 0.000 0.000 0.000 1459225222020333 Detected 0 of 1 at 1459225222076999.

I am using ROS version 1.11.13 'indigo' and Python 2.7.6.

gemad commented 8 years ago

all the mention warnings been handled i will update them , thanks

gemad commented 8 years ago

remove the old package add the new one and re catkin_make and let me know your comments , thanks

gestom commented 8 years ago

thanks, the naming convention etc is fixed. However, I still get this when running the node by:

rosrun cosphi_ros_bridge cosphi_ros_bridge_node.py

/opt/ros/indigo/lib/python2.7/dist-packages/rospy/topics.py:803: UserWarning: 'cosphi_ros_bridge/2D-01' is not a legal ROS graph resource name. This may cause problems with other ROS tools super(Publisher, self).init(name, data_class, Registration.PUB) Traceback (most recent call last): File "/home/gestom/svn/projects/CosPhi/src/cosphi_ros_bridge/scripts/cosphi_ros_bridge_node.py", line 47, in main()
File "/home/gestom/svn/projects/CosPhi/src/cosphi_ros_bridge/scripts/cosphi_ros_bridge_node.py", line 32, in main X = float(Array_All[2]) ValueError: could not convert string to float:

gemad commented 8 years ago

just run it again, make sure to run the CosPhi for few seconds before running the node , I added some small updates to the python code

gestom commented 8 years ago

IMHO the problem is caused by parsing one of the messages that comes over the socket. It seems that the 'Detected m of n at ....' is parsed in the same way as 'Robot ID ...' and thus, it tries to interpret the 'of' as a float, which causes the node to crash for me. Let me fix it.

gemad commented 8 years ago

but the first line is neglected and the parsing starts from the second line index[1] how does that happen ? and the same code run smoothly for me , so what do you think is the problem ?

gestom commented 8 years ago

IMHO you cannot be 100% sure that the 'Detected ...' line is the first one, because the TCP stack can divide the packets arbitrarily - at least it seems like that on my system.

gemad commented 8 years ago

does letting the buffer equal to the number of line will solve it , or block the receiving until the current buffer is empty ? but i dont know how to do that

gemad commented 8 years ago

@gestom did you fixed this sync error as am getting it now ?