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

README updated #9

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: bug
assignees: ''

---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:

**Expected behavior**
A clear and concise description of what you expected to happen.

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Desktop (please complete the following information):**
- OS: [e.g. Windows.Linux]
- Unity Version [e.g.2020.1.6f1]

**Additional context**
Add any other context about the problem here.
33 changes: 22 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# ROSBridgeLib
A Unity library for communication with ROS through [RosBridge](http://wiki.ros.org/rosbridge_suite)

```console
foo@bar:~$ sudo apt-get install ros-<rosdistro>-rosbridge-suite
foo@bar:~$ source /opt/ros/<rosdistro>/setup.bash
foo@bar:~$ roslaunch rosbridge_server rosbridge_websocket.launch
```
The first version of this I believe origins from [Michael Jenkin](https://github.com/michaeljenkin), in the repo [unityros](https://github.com/michaeljenkin/unityros). He made a sample unity project showing turtlesim, with good instructions on how to use this project. All honor goes to him. I created this project because there was no repository containing the barebone library.

## Included messages
Expand All @@ -10,6 +14,12 @@ This repository does not contain every ROS message. If you need to add one, plea
Documentation is in the code. I added some more in addition to what Michael Jenkin (original
author) did. The main file is ROSBridgeWebSocketConnection.cs, which sets up everything.

## Installation
Clone this repository in to the Assets folder of an Unity project:
```console
foo@bar:~$ git clone --recurse-submodules https://github.com/MathiasCiarlo/ROSBridgeLib.git
```

## Example usage
This is an example application where a ball is controlled. Basically, there are three important script types to notice.

Expand Down Expand Up @@ -49,7 +59,6 @@ public class ROSInitializer : MonoBehaviour
ros.Render ();
}
}

```
### **Subscriber**
Then, create a subscriber script, **BallPoseSubscriber.cs**, which will receive updates from a chosen ROS topic
Expand All @@ -63,7 +72,7 @@ using SimpleJSON;
using ROSBridgeLib.geometry_msgs;


public class BallPoseSubscriber : MonoBehaviour
public class BallPoseSubscriber : ROSBridgeSubscriber
{
static GameObject ball;

Expand All @@ -85,15 +94,16 @@ public class BallPoseSubscriber : MonoBehaviour
}

// This function should fire on each received ros message
public new static void CallBack(PoseMsg msg) {
public new static void CallBack(ROSBridgeMsg msg) {

Debug.Log("Recieved Message : "+msg.ToYAMLString());
// Update ball position, or whatever
PoseMsg PoseData=(PoseMsg)msg;
ball=GameObject.Find("ball");
Vector3 ballPos=ball.transform.position;
ballPos.x = msg.GetPosition().GetX();
ballPos.y = msg.GetPosition().GetY();
ballPos.z = msg.GetPosition().GetZ();
ballPos.x = PoseData.GetPosition().GetX();
ballPos.y = PoseData.GetPosition().GetY();
ballPos.z = PoseData.GetPosition().GetZ();
//Changing ball's position to the updated position vector
ball.transform.position=ballPos;
}
Expand All @@ -110,9 +120,10 @@ using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using SimpleJSON;
using ROSBridgeLib;
using ROSBridgeLib.geometry_msgs;

public class BallTwistPublisher : MonoBehaviour
public class BallTwistPublisher : ROSBridgePublisher
{
// The following three functions are important
public static string GetMessageTopic() {
Expand All @@ -133,7 +144,7 @@ public class BallTwistPublisher : MonoBehaviour
}
}
```
Above script defines the publisher. In order to call this publisher attach one script, **DataManager.cs**, to the gameobject ball.
Above script defines the publisher. In order to call this publisher attach one script, **DataController.cs**, to the gameobject ball.
```cs
using System.Collections;
using System.Collections.Generic;
Expand All @@ -142,7 +153,7 @@ using UnityEngine;
using ROSBridgeLib;
using ROSBridgeLib.geometry_msgs;

public class DataManager : MonoBehaviour
public class DataController : MonoBehaviour
{
Rigidbody rb;
GameObject rosObj;
Expand Down Expand Up @@ -174,7 +185,7 @@ public class DataManager : MonoBehaviour
rb.angularVelocity.z
);
msg=new TwistMsg(linearVel,angularVel);
rosobj.GetComponent<ROSInitialize>().ros.Publish(
rosObj.GetComponent<ROSInitializer>().ros.Publish(
BallTwistPublisher.GetMessageTopic(),msg
);
}
Expand Down