Advanced Distributed Systems module at HSLU
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

37 lines
1.2 KiB

using RobotLib.Communication;
using System.Collections.Generic;
using System.Text.Json;
namespace RobotLib.Movement
{
public class DevMovement : 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 DevMovement(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 AddSpeed(int speed)
{
base.SendMessage(TOPIC_MOBILE_NAV_MOVE, speed.ToString());
}
public void Stop()
{
base.SendMessage(TOPIC_MOBILE_NAV_STOP, true.ToString());
}
}
}