Ejemplo n.º 1
0
// wrapper around MessageManager::spin() that can be passed to
// pthread_create()
void*
spinFunc(void* arg)
{
  MessageManager* mgr = (MessageManager*)arg;
  mgr->spin();
  return NULL;
}
int main(int argc, char** argv)
{
  // Initialize ROS node "sm_talker"
  ros::init(argc, argv, "sm_listener");

  // Required to start timers for non-node ROS use.
  ros::Time::init();

  // Little message to know she's started
  ROS_INFO_STREAM("STARTING SM_MANAGER");

  // Create and execute manager
  // * Create a TCP server connection on TCP_PORT (see common.h)
  // * Initialize manager using server connection
  // * Initialize handler using server connection
  // * Add handler to manager
  // * Execute manager spin loop
  TcpServer server;
  server.init(TCP_PORT);

  MessageManager manager;
  MyHandler handler;

  manager.init(&server);

  // Handler initilaized with reply connection (typically the same as
  // incoming connection but now always)
  handler.init(&server);
  manager.add(&handler);
  manager.spin();

  return 0;
}
Ejemplo n.º 3
0
int main(int argc, char** argv)
{
    char ip[1024] = "192.168.0.50"; // Robot IP address
    TcpClient connection;
    MessageManager manager;

    ros::init(argc, argv, "state_interface");
    ros::NodeHandle n;

    JointRelayHandler jr_handler(n);

    ROS_INFO("Setting up client");
    connection.init(ip, StandardSocketPorts::STATE);
    connection.makeConnect();

    jr_handler.init(&connection);

    manager.init(&connection);
    manager.add(&jr_handler);

    manager.spin();
}