Skip to content

Commit c4b21d4

Browse files
Revert "Remove useless thread to start and stop dynamic graph"
This reverts commit 924c301.
1 parent 6dafe58 commit c4b21d4

File tree

2 files changed

+21
-15
lines changed

2 files changed

+21
-15
lines changed

include/dynamic_graph_bridge/sot_loader_basic.hh

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,6 @@ protected:
7272
/// \brief Coefficient between parallel joints and the state vector.
7373
std::vector<double> coefficient_parallel_joints_;
7474

75-
/// Advertises start_dynamic_graph services
76-
ros::ServiceServer service_start_;
77-
78-
/// Advertises stop_dynamic_graph services
79-
ros::ServiceServer service_stop_;
80-
8175
// Joint state publication.
8276
ros::Publisher joint_pub_;
8377

@@ -88,6 +82,7 @@ protected:
8882
int nbOfJoints_;
8983
parallel_joints_to_state_vector_t::size_type nbOfParallelJoints_;
9084

85+
9186
public:
9287
SotLoaderBasic();
9388
~SotLoaderBasic() {};

src/sot_loader_basic.cpp

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,24 @@ using namespace std;
3737
using namespace dynamicgraph::sot;
3838
namespace po = boost::program_options;
3939

40+
void createRosSpin(SotLoaderBasic *aSotLoaderBasic)
41+
{
42+
ROS_INFO("createRosSpin started\n");
43+
ros::NodeHandle n;
44+
45+
ros::ServiceServer service = n.advertiseService("start_dynamic_graph",
46+
&SotLoaderBasic::start_dg,
47+
aSotLoaderBasic);
48+
49+
ros::ServiceServer service2 = n.advertiseService("stop_dynamic_graph",
50+
&SotLoaderBasic::stop_dg,
51+
aSotLoaderBasic);
52+
53+
54+
ros::waitForShutdown();
55+
}
56+
57+
4058
SotLoaderBasic::SotLoaderBasic():
4159
dynamic_graph_stopped_(true),
4260
sotRobotControllerLibrary_(0)
@@ -60,15 +78,8 @@ int SotLoaderBasic::initPublication()
6078
void SotLoaderBasic::initializeRosNode(int , char *[])
6179
{
6280
ROS_INFO("Ready to start dynamic graph.");
63-
ros::NodeHandle n;
64-
65-
service_start_ = n.advertiseService("start_dynamic_graph",
66-
&SotLoaderBasic::start_dg,
67-
this);
68-
69-
service_stop_ = n.advertiseService("stop_dynamic_graph",
70-
&SotLoaderBasic::stop_dg,
71-
this);
81+
boost::unique_lock<boost::mutex> lock(mut);
82+
boost::thread thr2(createRosSpin,this);
7283

7384
}
7485

0 commit comments

Comments
 (0)