diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 0000000..8d62ad9 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -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. diff --git a/README.md b/README.md index 41a4b4d..69dba64 100644 --- a/README.md +++ b/README.md @@ -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--rosbridge-suite +foo@bar:~$ source /opt/ros//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 @@ -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. @@ -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 @@ -63,7 +72,7 @@ using SimpleJSON; using ROSBridgeLib.geometry_msgs; -public class BallPoseSubscriber : MonoBehaviour +public class BallPoseSubscriber : ROSBridgeSubscriber { static GameObject ball; @@ -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; } @@ -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() { @@ -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; @@ -142,7 +153,7 @@ using UnityEngine; using ROSBridgeLib; using ROSBridgeLib.geometry_msgs; -public class DataManager : MonoBehaviour +public class DataController : MonoBehaviour { Rigidbody rb; GameObject rosObj; @@ -174,7 +185,7 @@ public class DataManager : MonoBehaviour rb.angularVelocity.z ); msg=new TwistMsg(linearVel,angularVel); - rosobj.GetComponent().ros.Publish( + rosObj.GetComponent().ros.Publish( BallTwistPublisher.GetMessageTopic(),msg ); }