本文整理汇总了C#中ServiceClient.call方法的典型用法代码示例。如果您正苦于以下问题:C# ServiceClient.call方法的具体用法?C# ServiceClient.call怎么用?C# ServiceClient.call使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ServiceClient
的用法示例。
在下文中一共展示了ServiceClient.call方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Window_Loaded
private void Window_Loaded(object sender, RoutedEventArgs e)
{
ROS.ROS_MASTER_URI = "http://10.0.2.88:11311";
ROS.ROS_HOSTNAME = "10.0.2.152";
ROS.Init(new string[0], NODE_NAME);
nodeHandle = new NodeHandle();
//server = nodeHandle.advertiseService<Messages.roscpp_tutorials.TwoInts, Messages.roscpp_tutorials.TwoInts.Request, Messages.roscpp_tutorials.TwoInts.Response>("/add_two_ints", addition);
client = nodeHandle.serviceClient<Messages.roscpp_tutorials.TwoInts.Request, Messages.roscpp_tutorials.TwoInts.Response>("/add_two_ints");
new Thread(new ThreadStart(() =>
{
Random r = new Random();
while (!ROS.shutting_down)
{
TwoInts.Request req = new TwoInts.Request() { a = r.Next(100), b = r.Next(100) };
TwoInts.Response resp = new TwoInts.Response();
if (client.call(req, ref resp))
Dispatcher.Invoke(new Action(() =>
{
math.Content = "" + req.a + " + " + req.b + " = " + resp.sum;
}));
Thread.Sleep(500);
}
})).Start();
}