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

Multiplatform-dotNet-ROS workflow / redistribution issues

asked 2012-10-06 16:18:29 -0500

TiagoRibeiro gravatar image

Hi all,

I have been looking into ROS during the last couple of weeks, understanding how it works. I've ran it in Ubuntu (the pre-installed VirtualBox), then got it installed in OSX (Mountain Lion) and Windows 7. So for so good, things seem to work as described, and ROS looks promising.

My interest in ROS is to use it as a communication layer between several things we've been developing at my research lab (and yes, those 'things' include robots :)

However, we are not a robotics team, but an intelligent agents and synthetic characters groups, so we are used to develop on high-level platforms.

So the thing is, we develop everything in dotNet, both in Windows and OSX, and now we would like to try to link everything using ROS, because ROS offers exactly the communication mechanisms that we need. We have actually nearly built our own communication layer with the same kind of subscribe/publish mechanisms for independent 'plug-in-play' modules until we found out ROS does this and much more (like all the tools you have, and also modules for the NAO robot, which we also use)

So what I ask is suggestions for a workflow on this - making several libraries that were developed in C# to communicate over ROS.

My first bet was that I could use IronPython to get my dotnet classes to communicate with the python script that launches the ros node. The python script would add a callback to the dotnet class' events in order to publish ros messages when a certain dotnet event was launched, and would run a method on the same class with the msg information whenever a subscribed message was received.

So issue #1: I have failed to load roslib into IronPython. Does anyone know if this can be solved? Here is my execution. I first run it with python, so you see it works, things are set up correctly. However, with ipy it doesn't find roslib.

Tiago-Ribeiros-MacBook-Pro:~ tiagoribeiro$ roscd SimplePerception/

Tiago-Ribeiros-MacBook-Pro:SimplePerception tiagoribeiro$ python nodes/SimplePerceptionEffector.py

/opt/ros/fuerte/lib/python2.7/site-packages/ros_comm-1.8.12-py2.7.egg/rospy/topics.py:758: UserWarning: '\Perception\SimplePerception' is not a legal ROS graph resource name. This may cause problems with other ROS tools

[INFO] [WallTime: 1349574242.992873] hello world 1349574242.99

[INFO] [WallTime: 1349574243.994326] hello world 1349574243.99

^C

Tiago-Ribeiros-MacBook-Pro:SimplePerception tiagoribeiro$ ipy nodes/SimplePerctionEffector.py

Traceback (most recent call last):

File "nodes/SimplePerceptionEffector.py", line 5, in <module>

ImportError: No module named roslib

Tiago-Ribeiros-MacBook-Pro:SimplePerception tiagoribeiro$

Issue #2: Even if I got this running, the WinRos Sdk is not working with python, as ROS doesn't find my package.

I failed to find a workflow on using ROS with python on windows - the tutorials point only to using cpp modules. So what should I run on windows to get ROS to find the package (assuming it's written in python)?

Issue #3: The previous issues make me realize that I might have to work with C++ and ... (more)

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
2

answered 2012-10-06 16:48:43 -0500

sam gravatar image

I suggest you can ask each simple question seperately to let the one who know ROS can focus.

Here is my own way to run C# program on Ubuntu with ROS nodes.

streamvis-wrappers-ros

  make c# so file
  create new package
  roscreate-pkg sam_wrappers_cs_basic roscpp topic_tools
  cd sam_wrappers_cs_basic/

  vim src/wrapper.cpp
  // Copyright c Julian Brunner 2009 - 2011

  // This file is part of Stream Visualizer (streamvis).
  // 
  // Stream Visualizer is free software: you can redistribute it and/or modify it
  // under the terms of the GNU General Public License as published by the Free
  // Software Foundation, either version 3 of the License, or (at your option) any
  // later version.
  // 
  // Stream Visualizer is distributed in the hope that it will be useful, but
  // WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  // details.
  // 
  // You should have received a copy of the GNU General Public License along with
  // Stream Visualizer. If not, see <http://www.gnu.org/licenses/>.

  #include "sam_wrappers_cs_basic/wrapper.h"

  #include <string>

  #include <ros/ros.h>
  #include <ros/serialization.h>
  #include <topic_tools/shape_shifter.h>

  //New
  #include "std_msgs/String.h"

  using namespace std;
  using namespace ros;
  using namespace ros::serialization;
  using namespace topic_tools;

  //New
  void chatterCallback(const std_msgs::String::ConstPtr& msg)
  {
        ROS_INFO("I heard: [%s]", msg->data.c_str());
  }

  extern "C" void InitializeRos(/*char* node*/)
  {
      int argc = 0;
      char** argv = NULL;

      //string nodeName(node);
      init(argc, argv, "IRA_CSharp_Node");
      NodeHandle n;
      Subscriber sub = n.subscribe("chatter", 1000, chatterCallback);
      spin();
  }

  void ShutdownRos()
  {
      shutdown();
  }
  void RosSpin()
  {
      spin();
  }

  //My subscriber
  extern "C" void InitializeSub(/*char* topic*/)
  {
      NodeHandle n;

      //string topicName(topic);
      Subscriber sub = n.subscribe("chatter", 1000, chatterCallback);
  }

  NodeHandle* CreateNode()
  {
      return new NodeHandle();
  }
  void DisposeNode(NodeHandle* node)
  {
      delete node;
  }

  Subscriber* CreateSubscriber(NodeHandle* node, const char* topicName, unsigned int queueLength, void (*callback)(ShapeShifter::ConstPtr))
  {
      return new Subscriber(node->subscribe<ShapeShifter>(topicName, queueLength, callback));
  }
  void DisposeSubscriber(Subscriber* subscriber)
  {
      delete subscriber;
  }

  // TODO: Memory leaks?
  const char* ShapeShifterGetDataType(const ShapeShifter::ConstPtr message)
  {
      string info = message->getDataType();

      char* result = new char[info.size() + 1];
      strcpy(result, info.c_str());
      return result;  
  }
  const char* ShapeShifterGetDefinition(const ShapeShifter::ConstPtr message)
  {
      string info = message->getMessageDefinition();

      char* result = new char[info.size() + 1];
      strcpy(result, info.c_str());
      return result;
  }
  unsigned char* ShapeShifterGetData(const ShapeShifter::ConstPtr message)
  {
      unsigned char* data = new unsigned char[message->size()];

      OStream stream(data, message->size());
      message->write(stream);

      return data;
  }
  unsigned int ShapeShifterGetDataLength(const ShapeShifter::ConstPtr message)
  {
      return message->size();
  }
  vim include/sam_wrappers_cs_basic/wrapper.h
  // Copyright c Julian Brunner 2009 - 2011

  // This file is part of Stream Visualizer (streamvis).
  // 
  // Stream Visualizer is free software: you can redistribute it and/or modify it
  // under the terms of the GNU General Public License as published by the Free
  // Software Foundation, either version 3 of the License, or (at your option) any
  // later version.
  // 
  // Stream Visualizer is distributed in the hope that it will be useful, but
  // WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  // details.
  // 
  // You ...
(more)
edit flag offensive delete link more
0

answered 2012-10-07 07:08:20 -0500

TiagoRibeiro gravatar image

updated 2012-10-07 08:58:32 -0500

Thanks so much!

Perfect answer.

I just read it and it looks exactly like what I was planning to try, so you just delivered it on a tray :) Still haven't tried it, but I can understand what it does, and that's what I want, so I'm flagging as correct. If I run into problems it's more likely related to compiling under OSX or windows, but I should be able to solve it.

As to your suggestion about asking each issue in seperate threads, that is also a good idea!

It kind of surprises me that no one has ran into the issue of using ROS with dotnet. Right now if you search for "dotnet", this is the only thread.

So I suspect that your answer will eventually also become useful for other people.

Thank you.

You're using a 64bit version of mono right? They currently don't give out a 64bit version for OSX (I can only build it myself) I haven't managed to get the c++ dylib loaded into the C# assembly, it always reports a DLLNotFound exception, and I just found out that the dylib is x86_64, whilst the distributed mono for OSX is 32bit only. So I'm just double-checking that this is the case.

edit flag offensive delete link more

Comments

This should be posted as a comment to sam's answer.. and you might also want to look at http://www.ros.org/wiki/roscs

SL Remy gravatar image SL Remy  ( 2012-10-09 14:33:01 -0500 )edit

Sorry about that, I'm not very used to participating in these forums, so I didn't notice it.. won't happen again :) As to roscs, its page states that it is for c# in linux, and no Windows extension it is planned. I am developing in Win7 and OSX, so I'm trying to do my own workaround Thanks anyway

TiagoRibeiro gravatar image TiagoRibeiro  ( 2012-11-02 09:33:34 -0500 )edit

No problem, we're all learning together!

SL Remy gravatar image SL Remy  ( 2012-11-02 10:09:11 -0500 )edit

Actually, I can't find any "add comment" button I can click in order to comment on his answer :) I fear I'm not understanding something here. Just looked at other threads I'm in, and I only have an "Add Comment" button on my own posts/answers, and not on any others' answers to my questions..

TiagoRibeiro gravatar image TiagoRibeiro  ( 2012-11-02 13:39:29 -0500 )edit

Not sure why.. this could possibly be a browser related issue... I'd suggest testing and then posting as a question i.e. "Why doesn't the 'post a comment link' (not button) show up for me in browser XYZ"

SL Remy gravatar image SL Remy  ( 2012-11-04 09:22:07 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2012-10-06 16:18:29 -0500

Seen: 676 times

Last updated: Oct 07 '12