Calico ROS
From IPRE Wiki
This page describes creating a ROS/Calico connection.
ROS
ROS is the Robot Operating System. Here we assume a standard ROS install.
RosCS
RosCS is a ROS package which creates a connection between Mono and ROS. It takes a C# file and dynamically builds all of the needed links into a set of dynamic link libraries (DLL).
First, we need a local copy of ROS. We are using the current version of ROS (called "fuerte"):
- source /opt/ros/fuerte/setup.bash
- mkdir ~/ros
- rosws init ~/ros /opt/ros/fuerte
- source ~/ros/setup.bash
- roscd
Next, we need to install the package RosCS:
- rosws set cn-roscs-ros-pkg --git https://code.google.com/p/cn-roscs-ros-pkg/
- source ~/ros/setup.sh
- rosws update cn-roscs-ros-pkg
- [remove <rosdep name="mono"> from ~/ros/cn-roscs-ros-pkg/roscs/manifest.xml]
- rosdep install roscs
Finally, we create a C# file and build the DLLs:
- rosws set ~/ros/sandbox
- source ~/ros/setup.sh
- cd sandbox
- roscreate-pkg ROS std_msgs rospy roscpp roscs
- Create a C# file in ROS/src/hello.cs
- Edit ROS/CMakeLists.txt
hello.cs:
using System; using System.Threading; using RosCS; public class RosCsExample { Node node; Publisher pub; public RosCsExample() { this.node = Node.MainNode; this.pub = new Publisher(this.node,"DummyTopic",RosCS.std_msgs.String.TypeId,1); this.node.Subscribe("DummyTopic",OnMessage,6); } public void OnMessage(RosCS.std_msgs.String msg) { Console.WriteLine("Got message: "+msg.Data); } public void Run() { int i = 0; while(RosSharp.Ok()) { RosCS.std_msgs.String msg = new RosCS.std_msgs.String(); msg.Data ="Hello "+i; this.pub.Send(msg); i++; Thread.Sleep(1000); } } public static void Main(string[] args) { RosSharp.Init("NodeName",args); RosCsExample rce = new RosCsExample(); rce.Run(); } }
Add to bottom of CMakeLists.txt:
rosbuild_include(roscs cncs) rosbuild_gen_cs_msg() rosbuild_gensrv() CSHARP_ADD_TARGET_DEPENDENCY(hello Mono.C5) CSHARP_ADD_EXE(hello src/hello.cs)