Skip to content

Commit

Permalink
Add create3 rmw profile for discovery server
Browse files Browse the repository at this point in the history
  • Loading branch information
hilary-luo committed May 28, 2024
1 parent 9a03320 commit 3cfa3f9
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 0 deletions.
51 changes: 51 additions & 0 deletions etc/turtlebot4/fastdds_discovery_create3.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?xml version="1.0" encoding="UTF-8"?>
<dds xmlns="http://www.eprosima.com/XMLSchemas/fastRTPS_Profiles">
<profiles>
<!-- UDPv4 Transport profile -->
<transport_descriptors>
<transport_descriptor>
<transport_id>udp_transport</transport_id>
<type>UDPv4</type>
<!-- Reduce socket buffer size -->
<sendBufferSize>32768</sendBufferSize>
<receiveBufferSize>32768</receiveBufferSize>
<!-- Reduce max message size, otherwise the participant creation fails -->
<maxMessageSize>8192</maxMessageSize>
</transport_descriptor>
</transport_descriptors>

<!-- Domain Participant Profile -->
<participant profile_name="domainparticipant_profile_name" is_default_profile="true">
<rtps>
<!-- Use user defined UDPv4 transport -->
<userTransports>
<transport_id>udp_transport</transport_id>
</userTransports>
<!-- Disable builtin transports -->
<useBuiltinTransports>false</useBuiltinTransports>
</rtps>
</participant>

<!-- Default publisher profile -->
<data_writer profile_name="default_publisher_profile" is_default_profile="true">
<topic>
<!-- Tune initial allocations -->
<resourceLimitsQos>
<max_samples>0</max_samples>
<allocated_samples>0</allocated_samples>
</resourceLimitsQos>
</topic>
</data_writer>

<!-- Default subscriber profile -->
<data_reader profile_name="default_subscriber_profile" is_default_profile="true">
<topic>
<!-- Tune initial allocations -->
<resourceLimitsQos>
<max_samples>0</max_samples>
<allocated_samples>0</allocated_samples>
</resourceLimitsQos>
</topic>
</data_reader>
</profiles>
</dds>
13 changes: 13 additions & 0 deletions turtlebot4_setup/turtlebot4_setup
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,12 @@ class Turtlebot4Setup():

discovery_server = f'&fast_discovery_server_value={self.conf.get_create3_server_str()}'

create3_rmw_profile = 'config='
if self.conf.get(DiscoveryOptions.ENABLED):
discovery_server_enabled = '&fast_discovery_server_enabled'
create3_rmw_profile_file = os.path.join(self.conf.setup_dir, 'fastdds_discovery_create3.xml')
with open(create3_rmw_profile_file) as f:
create3_rmw_profile += f.read()
else:
discovery_server_enabled = ''

Expand All @@ -178,6 +182,15 @@ class Turtlebot4Setup():
if (result.returncode != 0):
return (result.returncode, "Error writing ROS settings to Create3\n\n" + result.stderr.decode("utf-8"))

# Set create3 rmw profile
command = shlex.split(f'curl -d {shlex.quote(create3_rmw_profile)} -X POST http://192.168.186.2/rmw-profile-override-save')

result = subprocess.run(command, capture_output=True)

# If the curl command fails then return and indicate the error.
if (result.returncode != 0):
return (result.returncode, "Error writing RMW XML Profile to Create3\n\n" + result.stderr.decode("utf-8"))

# Set time syncing to Raspberry PI
config = f'config=server 192.168.186.3 prefer iburst minpoll 4 maxpoll 6 # Use RPi4 server'
command = shlex.split(f'curl -d "{config}" -X POST http://192.168.186.2/beta-ntp-conf-save')
Expand Down

0 comments on commit 3cfa3f9

Please sign in to comment.