public void ServiceCallTest() { RosSocket.CallService <rosapi.GetParamRequest, rosapi.GetParamResponse>("/rosapi/get_param", ServiceCallHandler, new rosapi.GetParamRequest("/rosdistro", "default")); OnServiceReceived.WaitOne(); OnServiceReceived.Reset(); Assert.IsTrue(true); }
private string CallStringService(string topic) { Console.WriteLine("Calling service " + topic); var t = new ServiceResponseHandler <RosSharp.RosBridgeClient.MessageTypes.Std.String>((o) => { Console.WriteLine(o.data); }); return(rosSocket.CallService <RosSharp.RosBridgeClient.MessageTypes.Std.String, RosSharp.RosBridgeClient.MessageTypes.Std.String>(topic, t, null)); }
public static void Main(string[] args) { //RosSocket rosSocket = new RosSocket(new RosBridgeClient.Protocols.WebSocketSharpProtocol(uri)); RosSocket rosSocket = new RosSocket(new RosBridgeClient.Protocols.WebSocketNetProtocol(uri)); // Publication: std_msgs.String message = new std_msgs.String("publication test message data"); string publication_id = rosSocket.Advertise <std_msgs.String>("publication_test"); rosSocket.Publish(publication_id, message); // Subscription: string subscription_id = rosSocket.Subscribe <std_msgs.String>("/subscription_test", SubscriptionHandler); subscription_id = rosSocket.Subscribe <std_msgs.String>("/subscription_test", SubscriptionHandler); // Service Call: rosSocket.CallService <rosapi.GetParamRequest, rosapi.GetParamResponse>("/rosapi/get_param", ServiceCallHandler, new rosapi.GetParamRequest("/rosdistro", "default")); // Service Response: string service_id = rosSocket.AdvertiseService <std_srvs.TriggerRequest, std_srvs.TriggerResponse>("/service_response_test", ServiceResponseHandler); Console.WriteLine("Press any key to unsubscribe..."); Console.ReadKey(true); rosSocket.Unadvertise(publication_id); rosSocket.Unsubscribe(subscription_id); rosSocket.UnadvertiseService(service_id); Console.WriteLine("Press any key to close..."); Console.ReadKey(true); rosSocket.Close(); }
public void addDetectedObject() { AddDetectedObjectRequest adr = new AddDetectedObjectRequest(); RosSocket.CallService <AddDetectedObjectRequest, AddDetectedObjectResponse>(this.ServiceEndpoint, responseHandler, adr); Debug.Log($"sent AddDetectedObjectRequest to {ServiceEndpoint}"); }
public ServiceReceiver(RosSocket rosSocket, string service, object parameter, object handlerParameter, Type responseType) { ServiceName = service; ServiceParameter = parameter; HandlerParameter = handlerParameter; rosSocket.CallService(ServiceName, responseType, receive, ServiceParameter); }
public void deleteModels(List <string> modelNames) { foreach (String modelName in modelNames) { Debug.Log($"Sending Request to delete Model {modelName} via {ServiceEndpoint}"); string responseValue = RosSocket.CallService <DeleteModelRequest, DeleteModelResponse>(ServiceEndpoint, serviceResponseHandler, new DeleteModelRequest(modelName)); } }
public void AsaRosWrapperFindAnchorServiceCall(string anchorId) { var t = new ServiceResponseHandler <RosSharp.RosBridgeClient.MessageTypes.Std.String>((o) => { Debug.Log(o.data); }); rosSocket.CallService("/asa_ros/find_anchor", t, new FindAnchorMsg(anchorId) ); }
public bool Import(int maxTimeOut = int.MaxValue) { rosSocket.CallService("/rosapi/get_param", typeof(ParamValueString), receiveRobotName, new ParamName("/robot/name")); ServiceReceiver robotDescriptionReceiver = new ServiceReceiver(rosSocket, "/rosapi/get_param", new ParamName("/robot_description"), Path.DirectorySeparatorChar + "robot_description.urdf", typeof(ParamValueString)); robotDescriptionReceiver.ReceiveEventHandler += receiveRobotDescription; return(WaitHandle.WaitAll(Status.Values.ToArray(), maxTimeOut)); }
private void SendFileToRos(string rosPackagePath, byte[] fileContents) { RosSocket.CallService <file_server.SaveBinaryFileRequest, file_server.SaveBinaryFileResponse>( "/file_server/save_file", SaveFileResponseHandler, new file_server.SaveBinaryFileRequest(rosPackagePath, fileContents)); FilesBeingProcessed.Add(rosPackagePath, false); }
public string getStringParam(string paramName) { rosSocket.CallService <rosapi.GetParamRequest, rosapi.GetParamResponse>( "/rosapi/get_param", handleStringParam, new rosapi.GetParamRequest(paramName, "default") ); return(stringParamTempValue); }
public override void Transfer() { //Publish robot name param RosSocket.CallService <rosapi.SetParamRequest, rosapi.SetParamResponse>("/rosapi/set_param", SetRobotNameHandler, new rosapi.SetParamRequest("/robot/name", JsonConvert.SerializeObject(RobotName))); PublishRobotDescription(); PublishResourceFiles(); }
public override void Transfer() { RosSocket.CallService <rosapi.GetParamRequest, rosapi.GetParamResponse>("/rosapi/get_param", ReceiveRobotName, new rosapi.GetParamRequest("/robot/name", "default")); var robotDescriptionReceiver = new ServiceReceiver <rosapi.GetParamRequest, rosapi.GetParamResponse>(RosSocket, "/rosapi/get_param", new rosapi.GetParamRequest(urdfParameter, "default"), Path.DirectorySeparatorChar + urdfParameter + ".urdf"); robotDescriptionReceiver.ReceiveEventHandler += ReceiveRobotDescription; }
public void setEndEffectorSuctionCup(bool enabled) { byte enableCtrl = Convert.ToByte(enabled); byte suck = Convert.ToByte(enabled); bool isQueued = true; SetEndEffectorSuctionCupRequest request = new SetEndEffectorSuctionCupRequest(enableCtrl, suck, isQueued); string responseValue = RosSocket.CallService <SetEndEffectorSuctionCupRequest, SetEndEffectorSuctionCupResponse>(ServiceEndpoint, serviceResponseHandler, request); if (enabled) { flickering_enabled = true; StartCoroutine(Flicker(Sucker)); } else { flickering_enabled = false; } }
private void PublishRobotDescription() { XDocument urdfXDoc = XDocument.Load(urdfFilePath); FixPackagePaths(urdfXDoc); //Publish /robot_description param RosSocket.CallService <rosapi.SetParamRequest, rosapi.SetParamResponse>("/rosapi/set_param", SetRobotDescriptionHandler, new rosapi.SetParamRequest("/robot_description", JsonConvert.SerializeObject(urdfXDoc.ToString()))); //Send URDF file to ROS package string urdfPackagePath = "package://" + rosPackage + "/" + Path.GetFileName(urdfFilePath); string urdfFileContents = "<?xml version='1.0' encoding='utf-8'?>\n" + urdfXDoc.ToString(); byte[] urdfBytes = System.Text.Encoding.UTF8.GetBytes(urdfFileContents); SendFileToRos(urdfPackagePath, urdfBytes); }
public void transferParam(string endpoint, string paramName, string paramValue) { RosSocket.CallService <SetParamRequest, SetParamResponse>(endpoint, SetParamHandler, new SetParamRequest(paramName, JsonConvert.SerializeObject(paramValue))); }
public ServiceReceiver(RosSocket rosSocket, string service, Tin parameter, object handlerParameter) { ServiceParameter = parameter; HandlerParameter = handlerParameter; rosSocket.CallService <Tin, Tout>(service, Receive, ServiceParameter); }
public void getParam(string endpoint, string paramName) { string responseValue = RosSocket.CallService <GetParamRequest, GetParamResponse>(endpoint, GetParamHandler, new GetParamRequest(paramName, JsonConvert.SerializeObject(""))); }
public void enableStiffness() { socket.CallService <enableStiffnessRequest, enableStiffnessResponse>("/body_stiffness/enable", ServiceCallHandler, new enableStiffnessRequest()); stiffness = true; speech.say("stiffnes Enabled"); }