static void Main(string[] args) { #if (DEBUG) Environment.SetEnvironmentVariable("ROS_MASTER_URI", "http://localhost:11311/"); #endif Console.WriteLine("Start ROS"); ROS.Init(ref args, "ActionServerClientSlowDummy"); ICallbackQueue callbackQueue = new CallbackQueue(); var asyncSpinner = new AsyncSpinner(callbackQueue); asyncSpinner.Start(); NodeHandle nodeHandle = new NodeHandle(callbackQueue); ActionClient <Messages.actionlib.TestGoal, Messages.actionlib.TestResult, Messages.actionlib.TestFeedback> actionClient = null; // setup action server start Console.WriteLine("Create server"); var actionServer = new ActionServer <Messages.actionlib.TestGoal, Messages.actionlib.TestResult, Messages.actionlib.TestFeedback>(nodeHandle, "test_action"); Param.Set("status_list_timeout", 999.9); actionServer.RegisterGoalCallback((sgoalHandle) => { Thread thread = new Thread(() => serverGoalCallback(sgoalHandle, actionServer, actionClient)); thread.Start(); }); Console.WriteLine("Start Server"); actionServer.Start(); Console.WriteLine("Server Started"); // setup action server finish // setup client actionClient = new ActionClient <Messages.actionlib.TestGoal, Messages.actionlib.TestResult, Messages.actionlib.TestFeedback>("test_action_slow", nodeHandle); // send action request to serverslowdummy Console.WriteLine("Wait for client and server to negotiate connection"); bool started = actionClient.WaitForActionServerToStart(new TimeSpan(0, 0, 3)); if (!started) { Console.WriteLine("Negotiation with server failed!"); } Console.ReadLine(); actionServer.Shutdown(); nodeHandle.shutdown(); ROS.shutdown(); }
static void Main(string[] args) { #if (DEBUG) Environment.SetEnvironmentVariable("ROS_MASTER_URI", "http://192.168.200.32:11311/"); #endif Console.WriteLine("Start ROS"); ROS.Init(ref args, "ActionServer"); var asyncSpinner = new AsyncSpinner(); asyncSpinner.Start(); NodeHandle serverNodeHandle = new NodeHandle(); Console.WriteLine("Create server"); var actionServer = new ActionServer <Messages.actionlib.TestGoal, Messages.actionlib.TestResult, Messages.actionlib.TestFeedback>(serverNodeHandle, "test_action"); Console.WriteLine("Start Server"); actionServer.Start(); actionServer.RegisterGoalCallback((goalHandle) => { Console.WriteLine($"Goal registered callback. Goal: {goalHandle.Goal.goal}"); var fb = new Messages.actionlib.TestFeedback(); fb.feedback = 10; goalHandle.PublishFeedback(fb); Thread.Sleep(100); var result = new Messages.actionlib.TestResult(); result.result = 123; goalHandle.SetGoalStatus(Messages.actionlib_msgs.GoalStatus.SUCCEEDED, "done"); actionServer.PublishResult(goalHandle.GoalStatus, result); }); while (!Console.KeyAvailable) { Thread.Sleep(1); } actionServer.Shutdown(); serverNodeHandle.shutdown(); ROS.shutdown(); }
static void Main(string[] args) { Console.WriteLine("Start ROS"); ROS.Init(new string[0], "ActionServer"); var asyncSpinner = new AsyncSpinner(); asyncSpinner.Start(); NodeHandle serverNodeHandle = new NodeHandle(); Console.WriteLine("Create server"); var actionServer = new ActionServer <Messages.actionlib.TestGoal, Messages.actionlib.TestResult, Messages.actionlib.TestFeedback>(serverNodeHandle, "test_action"); Console.WriteLine("Start Server"); actionServer.Start(); actionServer.RegisterGoalCallback((goalHandle) => { Console.WriteLine($"Goal registered callback. Goal: {goalHandle.Goal.goal}"); var fb = new Messages.actionlib.TestFeedback(); fb.feedback = 10; goalHandle.PublishFeedback(fb); Thread.Sleep(100); var result = new Messages.actionlib.TestResult(); result.result = 123; goalHandle.SetGoalStatus(Messages.actionlib_msgs.GoalStatus.SUCCEEDED, "done"); actionServer.PublishResult(goalHandle.GoalStatus, result); }); while (!Console.KeyAvailable) { Thread.Sleep(1); } actionServer.Shutdown(); serverNodeHandle.Shutdown(); ROS.Shutdown(); }
static void Main(string[] args) { //#if (DEBUG) // Environment.SetEnvironmentVariable("ROS_HOSTNAME", ""); // Environment.SetEnvironmentVariable("ROS_IP", "192.168.200.32"); // Environment.SetEnvironmentVariable("ROS_MASTER_URI", "http://192.168.200.231:11311/"); //#endif Environment.SetEnvironmentVariable("ROS_HOSTNAME", "localhost"); Environment.SetEnvironmentVariable("ROS_IP", "127.0.0.1"); Environment.SetEnvironmentVariable("ROS_MASTER_URI", "http://localhost:11311/"); Console.WriteLine("Start ROS"); ROS.Init(ref args, "ActionServerSlowDummy"); ICallbackQueue callbackQueue = new CallbackQueue(); var asyncSpinner = new AsyncSpinner(callbackQueue); asyncSpinner.Start(); //var spinner = new SingleThreadSpinner(callbackQueue); NodeHandle serverNodeHandle = new NodeHandle(callbackQueue); Console.WriteLine("Create server"); var actionServer = new ActionServer <Messages.actionlib.TestGoal, Messages.actionlib.TestResult, Messages.actionlib.TestFeedback>(serverNodeHandle, "test_action_slow"); Console.WriteLine("Start Server"); Param.Set("status_list_timeout", 999.9); actionServer.Start(); actionServer.RegisterGoalCallback((goalHandle) => { Console.WriteLine($"Goal registered callback. Goal: {goalHandle.Goal.goal}"); goalHandle.SetAccepted("accepted"); new Thread(() => { for (int x = 0; x < 77; x++) { var fb = new Messages.actionlib.TestFeedback { feedback = x }; goalHandle.PublishFeedback(fb); Thread.Sleep(100); } var result = new Messages.actionlib.TestResult { result = 123 }; goalHandle.SetGoalStatus(Messages.actionlib_msgs.GoalStatus.SUCCEEDED, "done"); actionServer.PublishResult(goalHandle.GoalStatus, result); }).Start(); }); Console.ReadLine(); actionServer.Shutdown(); serverNodeHandle.shutdown(); ROS.shutdown(); }