New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
service complete version commit #30
Conversation
Now that we have completed the implementation of the service, we have closed this draft PR and created a new PR. |
I closed this by mistake, so I will reopen it. |
Thank you for the contribution, it would prove very valuable indeed! |
@pijaro if you could, please review today |
@miyakoshi-dev Thanks for the nice PR! I'm currently looking into the code. I will finish my review tomorrow 👍 |
src/ros2cs/ros2cs_core/Client.cs
Outdated
/// <summary> Service a message </summary> | ||
/// <see cref="IService.SendAndRecv"/> | ||
public IntPtr SendAndRecv(T msg) | ||
///public long SendAndRecv(T msg) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe we can remove unnecessary devel comments 👍
/// <description> Services are created through INode.CreateClient </description> | ||
public class Client<T>: IClient<T> where T : Message, new () | ||
{ | ||
public string Topic { get { return topic; } } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could use some code formatting here 😃 Please group private/public and explicitly denote the accessibility of the members.
src/ros2cs/ros2cs_core/Client.cs
Outdated
|
||
/// send request | ||
Utils.CheckReturnEnum(NativeRcl.rcl_send_request(ref serviceHandle, msgInternals.Handle, ref sequence_number)); | ||
System.Threading.Thread.Sleep(1000); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is a synchronous send and receive, then the 1sec wait is not enough for most use cases. Maybe some wait loop here?
Additionally, I think that async send and receive would make more sense - but this may be added later 👍
src/ros2cs/ros2cs_core/Ros2cs.cs
Outdated
@@ -231,6 +247,11 @@ public static void SpinOnce(List<INode> nodes, double timeoutSec = 0.1) | |||
{ | |||
subscription.TakeMessage(); | |||
} | |||
///WaitSet.Wait(global_context, allServices, timeoutSec); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Devel comment to remove
/// <description> Can only be called in an initialized Ros2cs state. </description> | ||
/// <param name="topic"> Topic for the service. Naming restrictions of ros2 apply and violation results in an exception </param> | ||
/// <param name="qos"> Quality of Service settings. Not passing this parameter will result in default settings </param> | ||
/// <returns> Service for the topic, which can be used to service messages </returns> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Returns client (copy paste error 😃 )
/// <returns> Service for the topic, which can be used to service messages </returns> | ||
Client<T> CreateClient<T>(string topic, QualityOfServiceProfile qos = null) where T : Message, new(); | ||
|
||
/// <summary> Remove a service </summary> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Remove a client"
@@ -179,6 +297,9 @@ internal static PublishType | |||
"rcl_publish"), | |||
typeof(PublishType)); | |||
|
|||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unnecessary lines
message(STATUS "Generating C# code for ROS interfaces ${_generated_msg_cs_files}") | ||
|
||
set(ros2_distro "$ENV{ROS_DISTRO}") | ||
if(ros2_distro STREQUAL "foxy" OR ros2_distro STREQUAL "galactic") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if that is still the case, but it was important for Humble setups
Did you try this PR with all supported ROS2 versions? (foxy, galactic, humble)
My quick test on humble failed to build. Most probably, this is one of the causes.
@@ -223,15 +235,116 @@ foreach(_generated_msg_c_ts_file ${_generated_msg_c_ts_files}) | |||
${PROJECT_NAME}__rosidl_generator_c | |||
) | |||
|
|||
set(ros2_distro "$ENV{ROS_DISTRO}") | |||
rosidl_target_interfaces(${_target_name} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rosidl_target_interfaces
is deprecated since Humble: https://docs.ros.org/en/humble/Releases/Release-Humble-Hawksbill.html#deprecation-of-rosidl-target-interfaces
It is a good idea to keep humble and up in check.
|
||
if(ros2_distro STREQUAL "humble" OR ros2_distro STREQUAL "rolling") | ||
rosidl_get_typesupport_target(c_typesupport_target "${PROJECT_NAME}" "rosidl_typesupport_c") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use new API for humble and up (https://docs.ros.org/en/humble/Releases/Release-Humble-Hawksbill.html#deprecation-of-rosidl-target-interfaces)
I've added some feedback 👍 Thanks again for such an important PR 👍 I also did a quick test on galactic and humble (u20) - it worked for galactic but failed for humble. It would be nice to keep the compatibility between ROS2 releases as well. |
Thank you for your review. |
Addressed non-Humble related review comments. |
・Improve typing of service response ・remove unused references to example_interfaces (2) Finished checking with humble/galactic under ubuntu/windows environment
I will close this PR since the work is being continued on #36 by @Deric-W 👍 |
@adamdbrw
I have implemented the service.
When you have time, could you please check it for me?