Skip to content
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

CommsBroker unregister being called? #270

Open
osrf-migration opened this issue Nov 12, 2019 · 10 comments
Open

CommsBroker unregister being called? #270

osrf-migration opened this issue Nov 12, 2019 · 10 comments
Assignees
Labels
enhancement New feature or request minor

Comments

@osrf-migration
Copy link

Original report (archived issue) by Steven Gray (Bitbucket: stgray).


This looks very much like #33. I’m working on my comms node and would like to restart it multiple times without restarting the sim.

To recreate - repeated running of the subt_example_node without also restarting the sim also results in this failure:

Broker::Register() warning: ID [X1] already exists
Broker::Bind() error: Address [X1] already used in a previous Bind()

Produced with the following – including killing and restarting subt_example_node once.

ign launch -v 4 urban_circuit.ign worldName:=urban_qual robotName1:=X1 robotConfig1:=X2_SENSOR_CONFIG_6
rosrun subt_example subt_example_node X1

@osrf-migration
Copy link
Author

Original comment by Steven Gray (Bitbucket: stgray).


  • Edited issue description

@osrf-migration
Copy link
Author

Original comment by Alfredo Bencomo (Bitbucket: bencomo).


I can also see the warning message, but it seems to be harmless since it still works. What is this a problem for you?

You should also try the subt_seed example: #!/osrf/subt_seed/src/default/src/subt_seed_node.cc


@osrf-migration
Copy link
Author

Original comment by Alfredo Bencomo (Bitbucket: bencomo).


  • set assignee_account_id to "5cf75629ff02b50ea27b2817"
  • set assignee to "bencomo (Bitbucket: bencomo)"

@osrf-migration
Copy link
Author

Original comment by Steven Gray (Bitbucket: stgray).


The error message about bindBroker::Bind() error: Address [X1] already used in a previous Bind() does seem to break things. The beacon still seems to work, but the callbacks will no longer trigger.

For example, I start with 2 robots, R1 and R2 and just have each robot send something to the other. This is great the first time, but the callbacks are never triggered again after restarting the comms nodes.

Here’s the code I’m using for simple comms nodes - I did start with subt_seed_node.cc and pruned away. I do pass in a robot name as an argument. Video is here

#include <chrono>
#include <geometry_msgs/Twist.h>
#include <subt_msgs/PoseFromArtifact.h>
#include <ros/ros.h>
#include <std_srvs/SetBool.h>
#include <rosgraph_msgs/Clock.h>

#include <string>

#include <subt_communication_broker/subt_communication_client.h>
#include <subt_ign/CommonTypes.hh>
#include <subt_ign/protobuf/artifact.pb.h>

/// \brief Communication client.
std::unique_ptr<subt::CommsClient> client_;

/// \brief Name of this robot.
std::string robot_name_;

void ChatterCallback(const std::string &_srcAddress,
                                    const std::string &_dstAddress,
                                    const uint32_t _dstPort,
                                    const std::string &_data)
{
  // Add code to handle communication callbacks.
  ROS_INFO("Message from [%s] to [%s] on port [%u]:\n [%s]", _srcAddress.c_str(),
      _dstAddress.c_str(), _dstPort, _data.c_str());
}

void CommsInit()
{
  // Create subt communication client
  ROS_INFO("Starting comms on %s", robot_name_.c_str());
  client_.reset(new subt::CommsClient(robot_name_, false, false));
  client_->Bind(&ChatterCallback, robot_name_, 1001);  // port is last argument
  client_->StartBeaconInterval(ros::Duration(1.0));  
}

void PingForNeighbors()
{
  client_->SendTo("Hello from " + robot_name_, "R1", 1001);
  client_->SendTo("Hello from " + robot_name_, "R2", 1001);
}


void PrintNeighbors()
{
  auto neighbors = client_->Neighbors();

  //for (auto neighbor_info : neighbors)
  for (auto kvp : client_->Neighbors())
  {
    std::string address = kvp.first;
    double stamp = kvp.second.first;
    double rssi = kvp.second.second;

    ROS_INFO("%s has neighbor %s: stamp %f, rssi %f>", robot_name_.c_str(),
        address.c_str(), stamp, rssi);
  }
}

/////////////////////////////////////////////////
int main(int argc, char** argv)
{
  // Initialize ros
  ros::init(argc, argv, "robot_comms", ros::init_options::AnonymousName);

  /// \brief ROS node handler.
  ros::NodeHandle nh_;

  robot_name_ = argv[1];
  CommsInit();

  ros::Rate loop_rate(1);
  while (ros::ok())
  {
    PrintNeighbors();
    PingForNeighbors();
    ros::spinOnce();
    loop_rate.sleep();
  }

  return 0;
}

@osrf-migration
Copy link
Author

Original comment by Alfredo Bencomo (Bitbucket: bencomo).


  • changed priority from "major" to "minor"
  • changed kind from "bug" to "proposal"

@osrf-migration
Copy link
Author

Original comment by Alfredo Bencomo (Bitbucket: bencomo).


We will revisit this after Urban.

@osrf-migration
Copy link
Author

Original comment by Nate Koenig (Bitbucket: Nathan Koenig).


  • changed assignee_account_id from "5cf75629ff02b50ea27b2817" to "557058:095b1e12-74ed-4e20-b44f-2f0745b616e0"
  • changed assignee from "bencomo (Bitbucket: bencomo)" to "nkoenig (Bitbucket: nkoenig, GitHub: nkoenig)"

@nkoenig nkoenig added enhancement New feature or request and removed proposal labels Aug 17, 2020
@tpet
Copy link

tpet commented Sep 11, 2020

We have same problems - after restarting the comms client, it cannot bind to the same address and transmitting messages over subt comms doesn't work anymore.

Maybe a hint - couldn't subscribing to multiple ports cause the problems (e.g., that only one port is unregistered when the client is destroyed)?

I would also propose to re-label this as a major bug instead of minor proposal.

@nkoenig
Copy link
Contributor

nkoenig commented Sep 11, 2020

Thank you for the suggestion. A bug is an issue that prevents the SubT Simulator from operating correctly or blocks development. Restarting robot code without restarting simulation is not a supported use case at this time. Therefore this issue is an enhancement.

@peci1
Copy link
Collaborator

peci1 commented Feb 1, 2021

Solution proposed in #772.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request minor
Projects
None yet
Development

No branches or pull requests

5 participants