Skip to content

Commit 9f22d6e

Browse files
authored
add Service and Client methods (#58)
Service and client methods
1 parent 3db60e0 commit 9f22d6e

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

src/Ros2ForUnity/Scripts/ROS2Node.cs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,38 @@ public bool RemovePublisher<T>(IPublisherBase publisher)
114114
ThrowIfUninitialized("remove publisher");
115115
return node.RemovePublisher(publisher);
116116
}
117+
118+
/// <inheritdoc cref="INode.CreateService"/>
119+
public Service<I, O> CreateService<I, O>(string topic, Func<I, O> callback, QualityOfServiceProfile qos = null)
120+
where I : Message, new()
121+
where O : Message, new()
122+
{
123+
ThrowIfUninitialized("create service");
124+
return node.CreateService<I, O>(topic, callback, qos);
125+
}
126+
127+
/// <inheritdoc cref="INode.RemoveService"/>
128+
public bool RemoveService(IServiceBase service)
129+
{
130+
ThrowIfUninitialized("remove service");
131+
return node.RemoveService(service);
132+
}
133+
134+
/// <inheritdoc cref="INode.CreateClient"/>
135+
public Client<I, O> CreateClient<I, O>(string topic, QualityOfServiceProfile qos = null)
136+
where I : Message, new()
137+
where O : Message, new()
138+
{
139+
ThrowIfUninitialized(callContext: "create client");
140+
return node.CreateClient<I, O>(topic, qos);
141+
}
142+
143+
/// <inheritdoc cref="INode.RemoveClient"/>
144+
public bool RemoveClient(IClientBase client)
145+
{
146+
ThrowIfUninitialized(callContext: "remove client");
147+
return node.RemoveClient(client);
148+
}
117149
}
118150

119151
} // namespace ROS2

0 commit comments

Comments
 (0)