|
|
|
|
@ -0,0 +1,37 @@ |
|
|
|
|
using RobotLib.Communication; |
|
|
|
|
using System.Collections.Generic; |
|
|
|
|
using System.Text.Json; |
|
|
|
|
|
|
|
|
|
namespace RobotLib.RobotControl |
|
|
|
|
{ |
|
|
|
|
public class DevRobot : DevBase |
|
|
|
|
{ |
|
|
|
|
private const string TOPIC_MOBILE_MODE = "/mobile/cmd/mode/"; |
|
|
|
|
private const string TOPIC_MOBILE_NAV_TURN = "/mobile/cmd/nav/turn/"; |
|
|
|
|
private const string TOPIC_MOBILE_NAV_MOVE = "/mobile/cmd/nav/move/"; |
|
|
|
|
private const string TOPIC_MOBILE_NAV_STOP = "/mobile/cmd/nav/stop/"; |
|
|
|
|
|
|
|
|
|
public DevRobot(IPublisherSubscriber com) : base(com, new List<string>() { }) { } |
|
|
|
|
|
|
|
|
|
public void SetMobilityMode(bool automatic) |
|
|
|
|
{ |
|
|
|
|
string payload = JsonSerializer.Serialize(new Dictionary<string, bool>() { { "automatic", automatic } }); |
|
|
|
|
base.SendMessage(TOPIC_MOBILE_MODE, payload); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void Turn(int angle) |
|
|
|
|
{ |
|
|
|
|
base.SendMessage(TOPIC_MOBILE_NAV_TURN, angle.ToString()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void SetSpeed(int speed) |
|
|
|
|
{ |
|
|
|
|
base.SendMessage(TOPIC_MOBILE_NAV_MOVE, speed.ToString()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void StopMovement() |
|
|
|
|
{ |
|
|
|
|
base.SendMessage(TOPIC_MOBILE_NAV_STOP, true.ToString()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |