Skip to content

Commit 09d97b2

Browse files
Merge pull request #96 from Unity-Technologies/ROS2dev
Ros2 Version 0.6.0
2 parents 344eac1 + 248e564 commit 09d97b2

File tree

10 files changed

+266
-97
lines changed

10 files changed

+266
-97
lines changed

.github/workflows/stale.yaml

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: 'Stale issue handler'
2+
on:
3+
workflow_dispatch:
4+
schedule:
5+
- cron: '0 17 * * *' # 17:00 UTC; 10:00 PDT
6+
7+
permissions:
8+
issues: write
9+
10+
jobs:
11+
stale:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/stale@v4.0.0
15+
id: stale
16+
with:
17+
stale-issue-label: 'stale'
18+
stale-issue-message: 'This issue has been marked stale because it has been open for 14 days with no activity. Please remove the stale label or comment on this issue, or the issue will be automatically closed in the next 14 days.'
19+
days-before-stale: 14
20+
days-before-pr-stale: -1
21+
days-before-close: 14
22+
days-before-pr-close: -1
23+
exempt-issue-labels: 'blocked,must,should,keep,pinned,work-in-progress,request,announcement'
24+
close-issue-message: 'This issue has been marked stale for 14 days and will now be closed. If this issue is still valid, please ping a maintainer.'
25+
- name: Print outputs
26+
run: echo ${{ join(steps.stale.outputs.*, ',') }}
27+

.yamato/yamato-config.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: Endpoint Unit Tests
22
agent:
33
type: Unity::VM
4-
image: robotics/ci-ubuntu20:latest
4+
image: robotics/ci-ubuntu20:v0.1.0-795910
55
flavor: i1.large
66
commands:
77
# run unit tests and save test results in /home/bokken/build/output/Unity-Technologies/ROS-TCP-Endpoint

CHANGELOG.md

+40
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,44 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
2020

2121
### Fixed
2222

23+
## [0.6.0] - 2021-09-30
24+
25+
Add the [Close Stale Issues](https://github.com/marketplace/actions/close-stale-issues) action
26+
27+
### Upgrade Notes
28+
29+
### Known Issues
30+
31+
### Added
32+
33+
Support for queue_size and latch for publishers. (https://github.com/Unity-Technologies/ROS-TCP-Endpoint/issues/82)
34+
35+
### Changed
36+
37+
### Deprecated
38+
39+
### Removed
40+
41+
### Fixed
42+
43+
## [0.5.0] - 2021-07-15
44+
45+
### Upgrade Notes
46+
47+
Upgrade the ROS communication to support ROS2 with Unity
48+
49+
### Known Issues
50+
51+
### Added
52+
53+
### Changed
54+
55+
### Deprecated
56+
57+
### Removed
58+
59+
### Fixed
60+
2361
## [0.4.0] - 2021-05-27
2462

2563
Note: the logs only reflects the changes from version 0.3.0
@@ -38,6 +76,8 @@ Add linter, unit tests, and test coverage reporting
3876

3977
### Changed
4078

79+
Improving the performance of the read_message in client.py, This is done by receiving the entire message all at once instead of reading 1024 byte chunks and stitching them together as you go.
80+
4181
### Deprecated
4282

4383
### Removed

launch/endpoint.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
from launch import LaunchDescription
22
from launch_ros.actions import Node
33

4+
45
def generate_launch_description():
56
return LaunchDescription([
67
Node(
78
package='ros_tcp_endpoint',
89
executable='default_server_endpoint',
910
emulate_tty=True,
1011
parameters=[
11-
{'/ROS_IP': '0.0.0.0'},
12-
{'/ROS_TCP_PORT': 10000},
12+
{'ROS_IP': '0.0.0.0'},
13+
{'ROS_TCP_PORT': 10000},
1314
],
1415
),
1516
])

package.xml

+4-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
33
<package format="3">
44
<name>ros_tcp_endpoint</name>
5-
<version>0.0.1</version>
6-
<description>ROS TCP Endpoint Unity Integration (ROS2 version)</description>
5+
<version>0.6.0</version>
6+
<description>ROS TCP Endpoint Unity Integration (ROS2 version)
7+
Acts as the bridge between Unity messages sent via TCP socket and ROS messages.
8+
</description>
79
<maintainer email="unity-robotics@unity3d.com">Unity Robotics</maintainer>
810
<license>Apache 2.0</license>
911

ros_tcp_endpoint/client.py

+16-22
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ def __init__(self, conn, tcp_server, incoming_ip, incoming_port):
3535
Set class variables
3636
Args:
3737
conn:
38-
source_destination_dict: dictionary of destination name to RosCommunicator class
38+
tcp_server: server object
39+
incoming_ip: connected from this IP address
40+
incoming_port: connected from this port
3941
"""
4042
self.conn = conn
4143
self.tcp_server = tcp_server
@@ -96,16 +98,7 @@ def read_message(self, conn):
9698
destination = self.read_string()
9799
full_message_size = ClientThread.read_int32(conn)
98100

99-
while len(data) < full_message_size:
100-
# Only grabs max of 1024 bytes TODO: change to TCPServer's buffer_size
101-
grab = 1024 if full_message_size - len(data) > 1024 else full_message_size - len(data)
102-
packet = ClientThread.recvall(conn, grab)
103-
104-
if not packet:
105-
self.logerr("No packets...")
106-
break
107-
108-
data += packet
101+
data = ClientThread.recvall(conn, full_message_size)
109102

110103
if full_message_size > 0 and not data:
111104
self.logerr("No data for a message size of {}, breaking!".format(full_message_size))
@@ -150,16 +143,16 @@ def serialize_command(command, params):
150143
return cmd_info + json_info
151144

152145
def send_ros_service_request(self, srv_id, destination, data):
153-
if destination not in self.tcp_server.source_destination_dict.keys():
154-
error_msg = "Service destination '{}' is not registered! Known topics are: {} ".format(
155-
destination, self.tcp_server.source_destination_dict.keys()
146+
if destination not in self.tcp_server.ros_services_table.keys():
147+
error_msg = "Service destination '{}' is not registered! Known services are: {} ".format(
148+
destination, self.tcp_server.ros_services_table.keys()
156149
)
157150
self.tcp_server.send_unity_error(error_msg)
158151
self.logerr(error_msg)
159152
# TODO: send a response to Unity anyway?
160153
return
161154
else:
162-
ros_communicator = self.tcp_server.source_destination_dict[destination]
155+
ros_communicator = self.tcp_server.ros_services_table[destination]
163156
service_thread = threading.Thread(
164157
target=self.service_call_thread, args=(srv_id, destination, data, ros_communicator)
165158
)
@@ -186,8 +179,8 @@ def logerr(self, text):
186179

187180
def run(self):
188181
"""
189-
Read a message and determine where to send it based on the source_destination_dict
190-
and destination string. Then send the read message.
182+
Receive a message from Unity and determine where to send it based on the publishers table
183+
and topic string. Then send the read message.
191184
192185
If there is a response after sending the serialized data, assume it is a
193186
ROS service response.
@@ -206,6 +199,7 @@ def run(self):
206199
while not halt_event.is_set():
207200
destination, data = self.read_message(self.conn)
208201

202+
# Process this message that was sent from Unity
209203
if self.tcp_server.pending_srv_id is not None:
210204
# if we've been told that the next message will be a service request/response, process it as such
211205
if self.tcp_server.pending_srv_is_request:
@@ -223,12 +217,12 @@ def run(self):
223217
elif destination.startswith("__"):
224218
# handle a system command, such as registering new topics
225219
self.tcp_server.handle_syscommand(destination, data)
226-
elif destination in self.tcp_server.source_destination_dict:
227-
ros_communicator = self.tcp_server.source_destination_dict[destination]
228-
response = ros_communicator.send(data)
220+
elif destination in self.tcp_server.publishers_table:
221+
ros_communicator = self.tcp_server.publishers_table[destination]
222+
ros_communicator.send(data)
229223
else:
230-
error_msg = "Topic '{}' is not registered! Known topics are: {} ".format(
231-
destination, self.tcp_server.source_destination_dict.keys()
224+
error_msg = "Not registered to publish topic '{}'! Valid publish topics are: {} ".format(
225+
destination, self.tcp_server.publishers_table.keys()
232226
)
233227
self.tcp_server.send_unity_error(error_msg)
234228
self.logerr(error_msg)

ros_tcp_endpoint/publisher.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,18 @@ class RosPublisher(RosSender):
2424
"""
2525
Class to publish messages to a ROS topic
2626
"""
27+
2728
# TODO: surface latch functionality
28-
def __init__(self, topic, message_class, queue_size=10):
29+
def __init__(self, topic, message_class, queue_size=10, latch=False):
2930
"""
3031
3132
Args:
3233
topic: Topic name to publish messages to
3334
message_class: The message class in catkin workspace
3435
queue_size: Max number of entries to maintain in an outgoing queue
3536
"""
36-
strippedTopic = re.sub('[^A-Za-z0-9_]+', '', topic)
37-
node_name = f'{strippedTopic}_RosPublisher'
37+
strippedTopic = re.sub("[^A-Za-z0-9_]+", "", topic)
38+
node_name = f"{strippedTopic}_RosPublisher"
3839
RosSender.__init__(self, node_name)
3940
self.msg = message_class()
4041
self.pub = self.create_publisher(message_class, topic, queue_size)
@@ -50,8 +51,8 @@ def send(self, data):
5051
Returns:
5152
None: Explicitly return None so behaviour can be
5253
"""
53-
#message_type = type(self.msg)
54-
#message = deserialize_message(data, message_type)
54+
# message_type = type(self.msg)
55+
# message = deserialize_message(data, message_type)
5556

5657
self.pub.publish(data)
5758

0 commit comments

Comments
 (0)