Skip to content
Snippets Groups Projects
Commit 8d85afd9 authored by Florent Lamiraux's avatar Florent Lamiraux Committed by Florent Lamiraux florent@laas.fr
Browse files

Make sure interpreter is started before advertizing run_command service.

  Launching an application in a roslaunch file may cause to send python
  command before the interpreter has read the prologue. This commit should fix
  this issue.
parent faf93101
No related branches found
No related tags found
No related merge requests found
......@@ -28,7 +28,10 @@ namespace dynamicgraph
/// \param Command string to execute, result, stdout, stderr strings.
void runCommand(const std::string & command, std::string &result,
std::string &out, std::string &err);
/// Initialize service run_command
void startRosService ();
protected:
/// \brief Run a Python command and return result, stderr and stdout.
bool runCommandCallback (dynamic_graph_bridge::RunCommand::Request& req,
......
......@@ -133,8 +133,14 @@ namespace dynamicgraph
sotNOSIGNAL,
MAKE_SIGNAL_STRING(name, true, "int", "trigger")),
rate_ (ROS_JOINT_STATE_PUBLISHER_RATE),
lastPublicated_ (ros::Time::now () - rate_ - rate_)
lastPublicated_ ()
{
try {
lastPublicated_ = ros::Time::now ();
} catch (const std::exception& exc) {
throw std::runtime_error ("Failed to call ros::Time::now ():" +
std::string (exc.what ()));
}
signalRegistration (trigger_);
trigger_.setNeedUpdateFromAllChildren (true);
......
......@@ -8,10 +8,13 @@ namespace dynamicgraph
: interpreter_ (),
nodeHandle_ (nodeHandle),
runCommandSrv_ ()
{
}
void Interpreter::startRosService ()
{
runCommandCallback_t runCommandCb =
boost::bind (&Interpreter::runCommandCallback, this, _1, _2);
runCommandSrv_ =
nodeHandle_.advertiseService ("run_command", runCommandCb);
}
......
......@@ -112,8 +112,14 @@ namespace dynamicgraph
sotNOSIGNAL,
MAKE_SIGNAL_STRING(name, true, "int", "trigger")),
rate_ (ROS_JOINT_STATE_PUBLISHER_RATE),
lastPublicated_ (ros::Time::now () - rate_ - rate_)
lastPublicated_ ()
{
try {
lastPublicated_ = ros::Time::now ();
} catch (const std::exception& exc) {
throw std::runtime_error ("Failed to call ros::Time::now ():" +
std::string (exc.what ()));
}
signalRegistration (state_ << trigger_);
trigger_.setNeedUpdateFromAllChildren (true);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment