-
Notifications
You must be signed in to change notification settings - Fork 276
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
Add comms infrastructure #1416
Merged
Merged
Add comms infrastructure #1416
Changes from all commits
Commits
Show all changes
44 commits
Select commit
Hold shift + click to select a range
fd7a39a
Initial layout
caguero fbc954d
Testing broker
caguero 135ceef
Working version.
caguero 80678b3
Layout updates.
caguero 971efab
move comms files to comms dir and update namespace
iche033 4fe15bf
add unit tests
iche033 68628d8
add integration test
iche033 ca49142
refactor CommsModel class
iche033 b38f470
Updates.
caguero d3c7395
More updates.
caguero 9baf15e
Updates.
caguero 9d2e2e3
Tweak tests
caguero 72922d3
Merge branch 'ign-gazebo6' into comms
caguero 5363fca
Style.
caguero 714e136
Merge branch 'ign-gazebo6' into comms
caguero 5e7d4a8
switch to unordered_map
arjo129 aa7081e
Merge branch 'comms' of github.com:ignitionrobotics/ign-gazebo into c…
arjo129 beefb6b
Step size and doxygen.
caguero bfd3c7e
Merge branch 'ign-gazebo6' into comms
caguero 07f7f39
Merge branch 'ign-gazebo6' into comms
caguero c531b25
Style.
caguero 6ac5f9d
Rename
caguero 327eb47
Updates.
caguero 9e626e7
Missing include
caguero 5d3111c
Merge branch 'ign-gazebo6' into comms
caguero 5472d97
Tweaks
caguero 1140b56
Tweaks
caguero c56d177
Add ICommsModel.cc
caguero 9789e66
Experimental message.
caguero eb6350a
Merge branch 'ign-gazebo6' into comms
caguero cfb0b99
Explicit
caguero b7022e5
Merge branch 'comms' of github.com:ignitionrobotics/ign-gazebo into c…
caguero fdf7245
Win
caguero c8d3bd8
Test
caguero fdae1ab
Win
caguero 886a811
Merge branch 'ign-gazebo6' into comms
caguero 8636c29
Win
caguero 3d4ea64
Include
caguero 098bc96
Merge branch 'ign-gazebo6' into comms
caguero d6aa6ef
Windows
caguero 9bd38a1
Visibility
caguero e9ac2de
Windows
caguero 088a68c
Visibility
caguero 67a54f2
Warning
caguero File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
cmake_minimum_required(VERSION 3.10.2 FATAL_ERROR) | ||
|
||
project(ign-gazebo-comms) | ||
|
||
find_package(ignition-transport11 QUIET REQUIRED) | ||
set(IGN_TRANSPORT_VER ${ignition-transport11_VERSION_MAJOR}) | ||
|
||
add_executable(publisher publisher.cc) | ||
target_link_libraries(publisher | ||
ignition-transport${IGN_TRANSPORT_VER}::core) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
/* | ||
* Copyright (C) 2022 Open Source Robotics Foundation | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
|
||
// Example: ./publisher addr1 | ||
|
||
#include <atomic> | ||
#include <chrono> | ||
#include <csignal> | ||
#include <iostream> | ||
#include <string> | ||
#include <thread> | ||
|
||
#include <ignition/msgs.hh> | ||
#include <ignition/transport.hh> | ||
|
||
/// \brief Flag used to break the publisher loop and terminate the program. | ||
static std::atomic<bool> g_terminatePub(false); | ||
|
||
////////////////////////////////////////////////// | ||
/// \brief Usage function. | ||
void usage() | ||
{ | ||
std::cerr << "./publisher <dst_address>" << std::endl; | ||
} | ||
|
||
////////////////////////////////////////////////// | ||
/// \brief Function callback executed when a SIGINT or SIGTERM signals are | ||
/// captured. This is used to break the infinite loop that publishes messages | ||
/// and exit the program smoothly. | ||
void signal_handler(int _signal) | ||
{ | ||
if (_signal == SIGINT || _signal == SIGTERM) | ||
g_terminatePub = true; | ||
} | ||
|
||
////////////////////////////////////////////////// | ||
int main(int argc, char **argv) | ||
{ | ||
if (argc != 2) | ||
{ | ||
usage(); | ||
return -1; | ||
} | ||
|
||
// Install a signal handler for SIGINT and SIGTERM. | ||
std::signal(SIGINT, signal_handler); | ||
std::signal(SIGTERM, signal_handler); | ||
|
||
// Create a transport node and advertise a topic. | ||
ignition::transport::Node node; | ||
std::string topic = "/broker/msgs"; | ||
|
||
auto pub = node.Advertise<ignition::msgs::Dataframe>(topic); | ||
if (!pub) | ||
{ | ||
std::cerr << "Error advertising topic [" << topic << "]" << std::endl; | ||
return -1; | ||
} | ||
|
||
std::this_thread::sleep_for(std::chrono::milliseconds(100)); | ||
|
||
// Prepare the message. | ||
ignition::msgs::Dataframe msg; | ||
msg.set_src_address("addr1"); | ||
msg.set_dst_address(argv[1]); | ||
|
||
// Publish messages at 1Hz. | ||
int counter = 0; | ||
while (!g_terminatePub) | ||
{ | ||
// Prepare the payload. | ||
ignition::msgs::StringMsg payload; | ||
payload.set_data("hello world " + std::to_string(counter)); | ||
std::string serializedData; | ||
if (!payload.SerializeToString(&serializedData)) | ||
{ | ||
std::cerr << "Error serializing message\n" | ||
<< payload.DebugString() << std::endl; | ||
} | ||
msg.set_data(serializedData); | ||
|
||
if (!pub.Publish(msg)) | ||
break; | ||
|
||
++counter; | ||
|
||
std::cout << "Publishing hello on topic [" << topic << "]" << std::endl; | ||
std::this_thread::sleep_for(std::chrono::milliseconds(1000)); | ||
} | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,177 @@ | ||
<?xml version="1.0" ?> | ||
<!-- | ||
Ignition Gazebo comms plugin demo. | ||
|
||
Compile the comms publisher: | ||
cd ign-gazebo/examples/standalone/comms | ||
mkdir build | ||
cd build | ||
cmake .. | ||
make | ||
|
||
Try launching a comms subscriber: | ||
ign topic -e -t addr1/rx | ||
|
||
Try launching a comms publisher: | ||
./publisher addr1 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
--> | ||
<sdf version="1.6"> | ||
<world name="perfect_comms"> | ||
|
||
<physics name="1ms" type="ignored"> | ||
<max_step_size>0.001</max_step_size> | ||
<real_time_factor>1.0</real_time_factor> | ||
</physics> | ||
<plugin | ||
filename="ignition-gazebo-physics-system" | ||
name="ignition::gazebo::systems::Physics"> | ||
</plugin> | ||
<plugin | ||
filename="ignition-gazebo-user-commands-system" | ||
name="ignition::gazebo::systems::UserCommands"> | ||
</plugin> | ||
<plugin | ||
filename="ignition-gazebo-scene-broadcaster-system" | ||
name="ignition::gazebo::systems::SceneBroadcaster"> | ||
</plugin> | ||
<plugin | ||
filename="ignition-gazebo-perfect-comms-system" | ||
name="ignition::gazebo::systems::PerfectComms"> | ||
</plugin> | ||
|
||
<light type="directional" name="sun"> | ||
<cast_shadows>true</cast_shadows> | ||
<pose>0 0 10 0 0 0</pose> | ||
<diffuse>1 1 1 1</diffuse> | ||
<specular>0.5 0.5 0.5 1</specular> | ||
<attenuation> | ||
<range>1000</range> | ||
<constant>0.9</constant> | ||
<linear>0.01</linear> | ||
<quadratic>0.001</quadratic> | ||
</attenuation> | ||
<direction>-0.5 0.1 -0.9</direction> | ||
</light> | ||
|
||
<model name="ground_plane"> | ||
<static>true</static> | ||
<link name="link"> | ||
<collision name="collision"> | ||
<geometry> | ||
<plane> | ||
<normal>0 0 1</normal> | ||
<size>100 100</size> | ||
</plane> | ||
</geometry> | ||
</collision> | ||
<visual name="visual"> | ||
<geometry> | ||
<plane> | ||
<normal>0 0 1</normal> | ||
<size>100 100</size> | ||
</plane> | ||
</geometry> | ||
<material> | ||
<ambient>0.8 0.8 0.8 1</ambient> | ||
<diffuse>0.8 0.8 0.8 1</diffuse> | ||
<specular>0.8 0.8 0.8 1</specular> | ||
</material> | ||
</visual> | ||
</link> | ||
</model> | ||
|
||
<model name="box1"> | ||
<pose>2 0 0.5 0 0 0</pose> | ||
<link name="box_link"> | ||
<inertial> | ||
<inertia> | ||
<ixx>0.16666</ixx> | ||
<ixy>0</ixy> | ||
<ixz>0</ixz> | ||
<iyy>0.16666</iyy> | ||
<iyz>0</iyz> | ||
<izz>0.16666</izz> | ||
</inertia> | ||
<mass>1.0</mass> | ||
</inertial> | ||
<collision name="box_collision"> | ||
<geometry> | ||
<box> | ||
<size>1 1 1</size> | ||
</box> | ||
</geometry> | ||
</collision> | ||
|
||
<visual name="box_visual"> | ||
<geometry> | ||
<box> | ||
<size>1 1 1</size> | ||
</box> | ||
</geometry> | ||
<material> | ||
<ambient>1 0 0 1</ambient> | ||
<diffuse>1 0 0 1</diffuse> | ||
<specular>1 0 0 1</specular> | ||
</material> | ||
</visual> | ||
</link> | ||
|
||
<plugin | ||
filename="ignition-gazebo-comms-endpoint-system" | ||
name="ignition::gazebo::systems::CommsEndpoint"> | ||
<address>addr1</address> | ||
<topic>addr1/rx</topic> | ||
</plugin> | ||
</model> | ||
|
||
<model name="box2"> | ||
<pose>-2 0 0.5 0 0 0</pose> | ||
<link name="box_link"> | ||
<inertial> | ||
<inertia> | ||
<ixx>0.16666</ixx> | ||
<ixy>0</ixy> | ||
<ixz>0</ixz> | ||
<iyy>0.16666</iyy> | ||
<iyz>0</iyz> | ||
<izz>0.16666</izz> | ||
</inertia> | ||
<mass>1.0</mass> | ||
</inertial> | ||
<collision name="box_collision"> | ||
<geometry> | ||
<box> | ||
<size>1 1 1</size> | ||
</box> | ||
</geometry> | ||
</collision> | ||
|
||
<visual name="box_visual"> | ||
<geometry> | ||
<box> | ||
<size>1 1 1</size> | ||
</box> | ||
</geometry> | ||
<material> | ||
<ambient>0 0 1 1</ambient> | ||
<diffuse>0 0 1 1</diffuse> | ||
<specular>0 0 1 1</specular> | ||
</material> | ||
</visual> | ||
</link> | ||
|
||
<plugin | ||
filename="ignition-gazebo-comms-endpoint-system" | ||
name="ignition::gazebo::systems::CommsEndpoint"> | ||
<address>addr2</address> | ||
<topic>addr2/rx</topic> | ||
<broker> | ||
<bind_service>/broker/bind</bind_service> | ||
<unbind_service>/broker/unbind</unbind_service> | ||
</broker> | ||
</plugin> | ||
|
||
</model> | ||
|
||
</world> | ||
</sdf> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 think this should be
addr2
?