@@ -1469,9 +1469,11 @@ void RobotisController::removeSensorModule(SensorModule *module)
1469
1469
1470
1470
void RobotisController::writeControlTableCallback (const robotis_controller_msgs::WriteControlTable::ConstPtr &msg)
1471
1471
{
1472
- fprintf (stderr, " [WriteControlTable] led control msg received\n " );
1473
1472
Device *device = NULL ;
1474
1473
1474
+ if (DEBUG_PRINT)
1475
+ fprintf (stderr, " [WriteControlTable] led control msg received\n " );
1476
+
1475
1477
auto dev_it1 = robot_->dxls_ .find (msg->joint_name );
1476
1478
if (dev_it1 != robot_->dxls_ .end ())
1477
1479
{
@@ -1490,7 +1492,7 @@ void RobotisController::writeControlTableCallback(const robotis_controller_msgs:
1490
1492
return ;
1491
1493
}
1492
1494
}
1493
- fprintf (stderr, " #1 " );
1495
+
1494
1496
ControlTableItem *item = NULL ;
1495
1497
auto item_it = device->ctrl_table_ .find (msg->start_item_name );
1496
1498
if (item_it != device->ctrl_table_ .end ())
@@ -1499,11 +1501,10 @@ void RobotisController::writeControlTableCallback(const robotis_controller_msgs:
1499
1501
}
1500
1502
else
1501
1503
{
1502
- ROS_WARN (" WriteControlTable] Unknown item : %s" , msg->start_item_name .c_str ());
1504
+ ROS_WARN (" [ WriteControlTable] Unknown item : %s" , msg->start_item_name .c_str ());
1503
1505
return ;
1504
1506
}
1505
1507
1506
- fprintf (stderr, " #2 " );
1507
1508
dynamixel::PortHandler *port = robot_->ports_ [device->port_name_ ];
1508
1509
dynamixel::PacketHandler *packet_handler = dynamixel::PacketHandler::getPacketHandler (device->protocol_version_ );
1509
1510
@@ -1512,17 +1513,13 @@ void RobotisController::writeControlTableCallback(const robotis_controller_msgs:
1512
1513
1513
1514
queue_mutex_.lock ();
1514
1515
1515
-
1516
1516
direct_sync_write_.push_back (new dynamixel::GroupSyncWrite (port, packet_handler, item->address_ , msg->data_length ));
1517
-
1518
- fprintf (stderr, " #3 \n " );
1519
-
1520
1517
direct_sync_write_[direct_sync_write_.size () - 1 ]->addParam (device->id_ , (uint8_t *)(msg->data .data ()));
1521
1518
1522
- fprintf (stderr, " [WriteControlTable] %s -> %s : " , msg->joint_name .c_str (), msg->start_item_name .c_str ());
1523
- for (auto &dt : msg->data )
1524
- fprintf (stderr, " %02X " , dt);
1525
- fprintf (stderr, " \n " );
1519
+ // fprintf(stderr, "[WriteControlTable] %s -> %s : ", msg->joint_name.c_str(), msg->start_item_name.c_str());
1520
+ // for (auto &dt : msg->data)
1521
+ // fprintf(stderr, "%02X ", dt);
1522
+ // fprintf(stderr, "\n");
1526
1523
1527
1524
queue_mutex_.unlock ();
1528
1525
@@ -1572,6 +1569,8 @@ void RobotisController::syncWriteItemCallback(const robotis_controller_msgs::Syn
1572
1569
if (item->access_type_ == Read)
1573
1570
continue ;
1574
1571
1572
+ queue_mutex_.lock ();
1573
+
1575
1574
int idx = 0 ;
1576
1575
if (direct_sync_write_.size () == 0 )
1577
1576
{
@@ -1607,6 +1606,8 @@ void RobotisController::syncWriteItemCallback(const robotis_controller_msgs::Syn
1607
1606
}
1608
1607
direct_sync_write_[idx]->addParam (device->id_ , data);
1609
1608
delete[] data;
1609
+
1610
+ queue_mutex_.unlock ();
1610
1611
}
1611
1612
}
1612
1613
0 commit comments