Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Creating a new ros type #12

Open
hermonir opened this issue Jan 16, 2018 · 1 comment
Open

Creating a new ros type #12

hermonir opened this issue Jan 16, 2018 · 1 comment

Comments

@hermonir
Copy link

Hi,

I need to subscribe to a new type of message, LogMsg.
I wrote the msg as follows. It's located under Assets/ROSBridgeLib/tevel_msgs

/////////////////////////////////////////////////////////////////////
using System.Collections;
using System.Text;
using SimpleJSON;
using ROSBridgeLib.tevel_msgs;


namespace ROSBridgeLib {
namespace tevel_msgs {
	public class LogMsg : ROSBridgeMsg {
		private string _module_name;
		private string _text;

		public LogMsg(JSONNode msg) {
			_module_name 	= msg ["module_name"].Value;
			_text 		= msg ["text"].Value;
		}

		public LogMsg(string moduleName, string text) {
			_module_name	= moduleName;
			_text 		= text;
		}

		public static string GetMessageType() {
			return "tevel_msgs/Log";
		}

		public string GetText() {
			return _text;
		}

		public string GetModule() {
			return _module_name;
		}

		public override string ToString() {
			return "text =" + _text;
		}

		public override string ToYAMLString() {
			return "{\"text\" : " + _text + "}";
		}
	}
}
}
//////////////////////////////////////////////////////

The subscriber is this:

////////////////////////////////////////////////////////////
using ROSBridgeLib;
using ROSBridgeLib.tevel_msgs;
using System.Collections;
using SimpleJSON;
using UnityEngine;

public class TevelInfo : ROSBridgeSubscriber {

public delegate void NewLogMessageDelegate (string module, string text);//, int type);
public static event NewLogMessageDelegate newLogMessageEvent;

public static int lastCounter = -1;

public new static string GetMessageTopic() {
	return "/tevel/info";
}  

public new static string GetMessageType() {
	return "tevel_msgs/Log";
}


public new static ROSBridgeMsg ParseMessage(JSONNode msg) {
	LogMsg newMsg = new LogMsg(msg);
	if (newLogMessageEvent != null)
		newLogMessageEvent (newMsg.GetModule (), newMsg.GetText ());

	return new LogMsg(msg);
}

public new static void CallBack(ROSBridgeMsg msg) {
	
}
}
///////////////////////////////////////////////////////////////////

I use this line of code:
ros.AddSubscriber (typeof(TevelInfo));
And on RosBridge on Ubuntu, I get this error message:
subscribe: Unable to load the manifest for package tevel_msgs. Caused by: tevel_msgs

Why can't I subscribe to any topic / message type I want?

Thanks :-)

@michaeljenkin
Copy link
Owner

It sounds as though ROS does not know the level_msg msg. Are the messages properly built into ROS? That is, if you run runsmg do you get all the data about it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants