Skip to content

Commit

Permalink
Remove nrc DriveCommand for nrc Motors
Browse files Browse the repository at this point in the history
  • Loading branch information
noahzemlin committed Feb 12, 2020
1 parent a63e9db commit d552972
Show file tree
Hide file tree
Showing 13 changed files with 80 additions and 49 deletions.
32 changes: 0 additions & 32 deletions Assets/ROSSharp Modules/DriveCommandSubscriber.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace RosSharp.RosBridgeClient.MessageTypes.Igvc
{
public class MotorsSubscriber : UnitySubscriber<Motors>
public class IGVCMotorsSubscriber : UnitySubscriber<Motors>
{
private SimpleCarController car;

Expand Down
24 changes: 24 additions & 0 deletions Assets/ROSSharp Modules/NRCMotorsSubscriber.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace RosSharp.RosBridgeClient.MessageTypes.Nrc
{
public class NRCMotorsSubscriber : UnitySubscriber<Motors>
{
private SimpleCarController car;

protected override void Start()
{
base.Start();
car = GetComponent<SimpleCarController>();
}

protected override void ReceiveMessage(Motors motors)
{
car.leftControl = motors.left;
car.rightControl = motors.right;
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Assets/Robots/NRC_Robot.asset
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ MonoBehaviour:
defaultValue: /nrc/camera/compressed
- name: Drive Status Topic
defaultValue: /nrc/sensor_data
- name: Drive Command Topic
defaultValue: /nrc/cmd
- name: Motors Topic
defaultValue: /nrc/motors
- name: ROS Bridge IP
defaultValue: localhost:9090
- name: Autonomous
Expand Down
3 changes: 1 addition & 2 deletions Assets/Robots/NRC_Robot.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -519,12 +519,11 @@ MonoBehaviour:
m_GameObject: {fileID: 3740033819105132858}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d2b35ee3f3eea854085dc8ffc433382a, type: 3}
m_Script: {fileID: 11500000, guid: c4e82c4c4431d734caf9c4489410979e, type: 3}
m_Name:
m_EditorClassIdentifier:
Topic:
TimeStep: 0
tf: {fileID: 3740033819105132855}
--- !u!1 &3740033819154644750
GameObject:
m_ObjectHideFlags: 0
Expand Down
34 changes: 34 additions & 0 deletions Assets/RosSharpMessages/Nrc/msg/Motors.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* This message is auto generated by ROS#. Please DO NOT modify.
* Note:
* - Comments from the original code will be written in their own line
* - Variable sized arrays will be initialized to array of size 0
* Please report any issues at
* <https://github.com/siemens/ros-sharp>
*/

using Newtonsoft.Json;

namespace RosSharp.RosBridgeClient.MessageTypes.Nrc
{
public class Motors : Message
{
[JsonIgnore]
public const string RosMessageName = "nrc_msgs/motors";

public float left;
public float right;

public Motors()
{
this.left = 0.0f;
this.right = 0.0f;
}

public Motors(float left, float right)
{
this.left = left;
this.right = right;
}
}
}
11 changes: 11 additions & 0 deletions Assets/RosSharpMessages/Nrc/msg/Motors.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Assets/Scripts/IGVCConfigLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class IGVCConfigLoader : MonoBehaviour
private IMUPublisher iMUPublisher;
private VelocityPublisher velocityPublisher;
private GPSPublisher gPSPublisher;
private MotorsSubscriber motorsSubscriber;
private IGVCMotorsSubscriber motorsSubscriber;

void Awake()
{
Expand All @@ -28,7 +28,7 @@ void Awake()
iMUPublisher = this.GetComponent<IMUPublisher>();
velocityPublisher = this.GetComponent<VelocityPublisher>();
gPSPublisher = this.GetComponent<GPSPublisher>();
motorsSubscriber = this.GetComponent<MotorsSubscriber>();
motorsSubscriber = this.GetComponent<IGVCMotorsSubscriber>();

simpleCarController.useController = !RobotOptions.GetValue(robotName + "Autonomous").Equals("True");
rosConnector.RosBridgeServerUrl = "ws://" + RobotOptions.GetValue(robotName + "ROS Bridge IP");
Expand Down
6 changes: 3 additions & 3 deletions Assets/Scripts/NRCConfigLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,21 @@ public class NRCConfigLoader : MonoBehaviour
private RosConnector rosConnector;
private ImagePublisher imagePublisher;
private DriveStatusPublisher driveStatusPublisher;
private DriveCommandSubscriber driveCommandSubscriber;
private NRCMotorsSubscriber motorsSubscriber;

void Awake()
{
simpleCarController = this.GetComponent<SimpleCarController>();
rosConnector = this.GetComponent<RosConnector>();
imagePublisher = this.GetComponent<ImagePublisher>();
driveStatusPublisher = this.GetComponent<DriveStatusPublisher>();
driveCommandSubscriber = this.GetComponent<DriveCommandSubscriber>();
motorsSubscriber = this.GetComponent<NRCMotorsSubscriber>();

simpleCarController.useController = !RobotOptions.GetValue(robotName + "Autonomous").Equals("True");
rosConnector.RosBridgeServerUrl = "ws://" + RobotOptions.GetValue(robotName + "ROS Bridge IP");
imagePublisher.Topic = RobotOptions.GetValue(robotName + "Camera Topic");
driveStatusPublisher.Topic = RobotOptions.GetValue(robotName + "Drive Status Topic");
driveCommandSubscriber.Topic = RobotOptions.GetValue(robotName + "Drive Command Topic");
motorsSubscriber.Topic = RobotOptions.GetValue(robotName + "Motors Topic");
}
}
}
5 changes: 0 additions & 5 deletions Assets/Scripts/SimpleCarController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,8 @@ public class SimpleCarController : MonoBehaviour

public bool useController = false;

private Rigidbody rb;
private MotorsSubscriber ms;

public void Start()
{
this.rb = this.GetComponent<Rigidbody>();
this.ms = this.GetComponent<MotorsSubscriber>();
}

public void FixedUpdate()
Expand Down
2 changes: 1 addition & 1 deletion Assets/StreamingAssets/build_info
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Build from DESKTOP-QVE6E0N at 2/3/2020 8:52:14 PM
Build from DESKTOP-D8RUH2C at 2/11/2020 7:25:10 PM

0 comments on commit d552972

Please sign in to comment.