add collision detection
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user