ros-industrial-consortium / packml

ROS packml (https://en.wikipedia.org/wiki/PackML) support package
Apache License 2.0
9 stars 14 forks source link

Ros wrapper #3

Closed shaun-edwards closed 7 years ago

shaun-edwards commented 7 years ago

This depends on PR #2. (There are fewer changes than the diff suggests, DO NOT MERGE until PR #2 has been merged)

This PR implements the packml_ros package (along with minor changes to supporting package as required). This package wraps the PackML state machine defined in packml_sm in a ROS node. The ros node spins up a PackML status publisher and a transition request service server. This enables basic state control and reporting of the state machine. A PackML ROS node can be started similar to a regular ROS node.


#include <ros/ros.h>
#include <packml_ros/packml_ros.h>

int myExecuteMethod()
{
  ROS_INFO_STREAM("This is my execute method(begin)");
  ros::Duration(1.0).sleep();
  ROS_INFO_STREAM("This is my execute method(end)");
  return 0;  //returning zero indicates non-failure
}

int main(int argc, char* argv[]) {

    ros::init(argc, argv, "packml_node");
    packml_sm::init(argc, argv);

    auto sm = packml_sm::StateMachine::continuousCycleSM();
    sm->setExecute(std::bind(myExecuteMethod));
    sm->activate();

    packml_ros::PackmlRos sm_node(ros::NodeHandle(), ros::NodeHandle("~"), sm);
    sm_node.spin();

    return 0;
}
shaun-edwards commented 7 years ago

FYI... @gavanderhoorn, @AmyMingli, @BrettHemes, @Jmeyer1292, @minlingc. No need to review (unless you want to), but here is my latest progress.

Next I will implement a simple packml_gui that allow a user to initiate state changes via button pushes and monitor the current state. This will be achieved using the ROS API in PR #1. This means that the GUI should be useful to others as well, assuming they utilize the ROS API.