You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
965 B
C#
39 lines
965 B
C#
using UnityEngine;
|
|
using Unity.Robotics.Core;
|
|
using Unity.Robotics.ROSTCPConnector;
|
|
using RosMessageTypes.Std;
|
|
|
|
public class ROSCollissionDetectionPublisher : MonoBehaviour
|
|
{
|
|
public string topicName = "/collision_detection";
|
|
public bool useNamespace = true;
|
|
public BoolMsg result;
|
|
|
|
|
|
protected string _namespace;
|
|
|
|
ROSConnection ros;
|
|
|
|
private void Awake()
|
|
{
|
|
if (useNamespace)
|
|
{
|
|
_namespace = "/" + gameObject.name;
|
|
topicName = topicName[0] == '/' ? _namespace + topicName : _namespace + "/" + topicName;
|
|
}
|
|
}
|
|
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
|
void Start()
|
|
{
|
|
ros = ROSConnection.GetOrCreateInstance();
|
|
ros.RegisterPublisher<BoolMsg>(topicName);
|
|
result = new BoolMsg(false);
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
ros.Publish(topicName, result);
|
|
}
|
|
}
|