@@ -263,6 +263,7 @@ void JointControlWidget::SetModelName(const std::string &_modelName)
263
263
this ->jointPub .reset ();
264
264
265
265
msgs::Model modelMsg;
266
+ std::map<std::string, msgs::JointCmd> jointCmds;
266
267
267
268
this ->modelLabel ->setText (QString::fromStdString (std::string (" Model: " )));
268
269
@@ -282,12 +283,29 @@ void JointControlWidget::SetModelName(const std::string &_modelName)
282
283
{
283
284
modelMsg.ParseFromString (response.serialized_data ());
284
285
}
286
+
287
+ int i = 0 ;
288
+ for (; i < modelMsg.joint_size (); ++i)
289
+ {
290
+ std::string jointName = modelMsg.joint (i).name ();
291
+
292
+ this ->requestMsg = msgs::CreateRequest (" joint_controller" );
293
+ this ->requestMsg ->set_data (joint_name);
294
+
295
+ response = transport::request (" default" , *this ->requestMsg );
296
+
297
+ if (response.response () != " error" &&
298
+ response.type () == jointCmds.begin ()->second .GetTypeName ())
299
+ {
300
+ jointCmd_M[jointName].ParseFromString (response.serialized_data ());
301
+ }
302
+ }
285
303
}
286
304
287
305
this ->modelLabel ->setText (QString::fromStdString (
288
306
std::string (" Model: " ) + modelMsg.name ()));
289
307
290
- this ->LayoutForceTab (modelMsg );
308
+ this ->LayoutForceTab (&jointCmds );
291
309
292
310
this ->LayoutPositionTab (modelMsg);
293
311
@@ -547,7 +565,8 @@ void JointControlWidget::AddScrollTab(QTabWidget *_tabPane,
547
565
}
548
566
549
567
// ///////////////////////////////////////////////
550
- void JointControlWidget::LayoutForceTab (msgs::Model &_modelMsg)
568
+ void JointControlWidget::LayoutForceTab (
569
+ std::map<std::string, msgs::JointCmd> &_jointCmds);
551
570
{
552
571
// Remove the old widgets;
553
572
QLayoutItem *wItem;
@@ -560,19 +579,19 @@ void JointControlWidget::LayoutForceTab(msgs::Model &_modelMsg)
560
579
this ->sliders .clear ();
561
580
562
581
// Don't add any widget if there are no joints
563
- if (_modelMsg. joint_size () == 0 )
582
+ if (_jointCmds-> size () == 0 )
564
583
return ;
565
584
566
585
this ->forceGridLayout ->addItem (new QSpacerItem (10 , 20 , QSizePolicy::Expanding,
567
586
QSizePolicy::Minimum), 0 , 0 , 2 );
568
587
this ->forceGridLayout ->addWidget (new QLabel (" Newton-meter" , this ), 0 , 2 );
569
588
570
589
int i = 0 ;
571
- for (; i < _modelMsg.joint_size (); ++i)
590
+ for (std::map<std::string, msgs::JointCmd>::iterator iter =
591
+ _jointCmds->begin (), iter != jointCmds->end (); ++iter)
572
592
{
573
- std::string jointName = _modelMsg.joint (i).name ();
574
- // Do a request / response right here, make a request handler for
575
- // JointController
593
+ std::string jointName = iter->first ;
594
+ msgs::JointCmd jointCmd = iter->second ;
576
595
577
596
// Get the joint name minus the model name
578
597
int modelNameIndex = jointName.find (" ::" ) + 2 ;
@@ -583,12 +602,13 @@ void JointControlWidget::LayoutForceTab(msgs::Model &_modelMsg)
583
602
this ->forceGridLayout ->addItem (new QSpacerItem (10 , 20 ,
584
603
QSizePolicy::Expanding, QSizePolicy::Minimum), i+1 , 1 );
585
604
586
- JointForceControl *slider = new JointForceControl (jointName ,
605
+ JointForceControl *slider = new JointForceControl (&jointCmd ,
587
606
this ->forceGridLayout , this , i+1 );
588
607
589
608
this ->sliders [jointName] = slider;
590
609
connect (slider, SIGNAL (changed (double , const std::string &)),
591
610
this , SLOT (OnForceChanged (double , const std::string &)));
611
+ ++i;
592
612
}
593
613
594
614
// Add a space at the bottom of the grid layout to consume extra space.
0 commit comments