Example #1
0
 void PublishWindDirection()
 {
     if (ready)
     {
         RosInterface.Publish <Float32> ("/anemometer", new Float32(windDirection));
     }
 }
Example #2
0
 void PublishCurrentPos()
 {
     if (ready)
     {
         RosInterface.Publish <Point> ("/lps", new Point(boatPos));
     }
 }
Example #3
0
 void PublishWaypoints()
 {
     if (ready)
     {
         RosInterface.Publish <PointArray> ("/waypoints", new PointArray(waypoints));
     }
 }
Example #4
0
 void Awake()
 {
     if (!instance)
     {
         instance = this;
     }
     else
     {
         Debug.LogWarning("Please only have one instance of RosInterface script.");
     }
 }
Example #5
0
    //entry point
    public void InitSimulation(string ip)
    {
        //expect ip to be in format "192.168.0.29:9090"
        string fullUrl = "ws://" + ip;

        RosInterface.Connect(fullUrl);
        RosInterface.Subscribe <BoatState> ("/boat_state", "boat_msgs/BoatState").MessageReceived += OnBoatStateMsg;
        RosInterface.Subscribe <Float32> ("/target_heading", "std_msgs/Float32").MessageReceived  += OnHeadingMsg;
        RosInterface.Subscribe <Float32> ("/winch", "std_msgs/Int32").MessageReceived             += OnWinchMsg;
        RosInterface.Advertise("/lps", "boat_msgs/Point");
        RosInterface.Advertise("/waypoints", "boat_msgs/PointArray");
        RosInterface.Advertise("/anemometer", "std_msgs/Float32");
        ready = true;

        PublishWaypoints();
        PublishWindDirection();
        boatPos = boatVel = boatAccel = Vector2.zero;
        PublishCurrentPos();
    }