@@ -911,12 +911,14 @@ void RobotisController::process()
911
911
912
912
if (dxl->bulk_read_items_ .size () > 0 )
913
913
{
914
- uint32_t data = 0 ;
914
+ bool updated = false ;
915
+ uint32_t data = 0 ;
915
916
for (int i = 0 ; i < dxl->bulk_read_items_ .size (); i++)
916
917
{
917
918
ControlTableItem *item = dxl->bulk_read_items_ [i];
918
919
if (port_to_bulk_read_[port_name]->isAvailable (dxl->id_ , item->address_ , item->data_length_ ) == true )
919
920
{
921
+ updated = true ;
920
922
data = port_to_bulk_read_[port_name]->getData (dxl->id_ , item->address_ , item->data_length_ );
921
923
922
924
// change dxl_state
@@ -938,7 +940,8 @@ void RobotisController::process()
938
940
}
939
941
940
942
// -> update time stamp to Robot->dxls[]->dynamixel_state.update_time_stamp
941
- dxl->dxl_state_ ->update_time_stamp_ = TimeStamp (present_state.header .stamp .sec , present_state.header .stamp .nsec );
943
+ if (updated == true )
944
+ dxl->dxl_state_ ->update_time_stamp_ = TimeStamp (present_state.header .stamp .sec , present_state.header .stamp .nsec );
942
945
}
943
946
}
944
947
}
@@ -954,12 +957,14 @@ void RobotisController::process()
954
957
955
958
if (sensor->bulk_read_items_ .size () > 0 )
956
959
{
957
- uint32_t data = 0 ;
960
+ bool updated = false ;
961
+ uint32_t data = 0 ;
958
962
for (int i = 0 ; i < sensor->bulk_read_items_ .size (); i++)
959
963
{
960
964
ControlTableItem *item = sensor->bulk_read_items_ [i];
961
965
if (port_to_bulk_read_[port_name]->isAvailable (sensor->id_ , item->address_ , item->data_length_ ) == true )
962
966
{
967
+ updated = true ;
963
968
data = port_to_bulk_read_[port_name]->getData (sensor->id_ , item->address_ , item->data_length_ );
964
969
965
970
// change sensor_state
@@ -968,7 +973,8 @@ void RobotisController::process()
968
973
}
969
974
970
975
// -> update time stamp to Robot->dxls[]->dynamixel_state.update_time_stamp
971
- sensor->sensor_state_ ->update_time_stamp_ = TimeStamp (present_state.header .stamp .sec , present_state.header .stamp .nsec );
976
+ if (updated == true )
977
+ sensor->sensor_state_ ->update_time_stamp_ = TimeStamp (present_state.header .stamp .sec , present_state.header .stamp .nsec );
972
978
}
973
979
}
974
980
}
@@ -1463,9 +1469,11 @@ void RobotisController::removeSensorModule(SensorModule *module)
1463
1469
1464
1470
void RobotisController::writeControlTableCallback (const robotis_controller_msgs::WriteControlTable::ConstPtr &msg)
1465
1471
{
1466
- fprintf (stderr, " [WriteControlTable] led control msg received\n " );
1467
1472
Device *device = NULL ;
1468
1473
1474
+ if (DEBUG_PRINT)
1475
+ fprintf (stderr, " [WriteControlTable] led control msg received\n " );
1476
+
1469
1477
auto dev_it1 = robot_->dxls_ .find (msg->joint_name );
1470
1478
if (dev_it1 != robot_->dxls_ .end ())
1471
1479
{
@@ -1484,7 +1492,7 @@ void RobotisController::writeControlTableCallback(const robotis_controller_msgs:
1484
1492
return ;
1485
1493
}
1486
1494
}
1487
- fprintf (stderr, " #1 " );
1495
+
1488
1496
ControlTableItem *item = NULL ;
1489
1497
auto item_it = device->ctrl_table_ .find (msg->start_item_name );
1490
1498
if (item_it != device->ctrl_table_ .end ())
@@ -1493,11 +1501,10 @@ void RobotisController::writeControlTableCallback(const robotis_controller_msgs:
1493
1501
}
1494
1502
else
1495
1503
{
1496
- 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 ());
1497
1505
return ;
1498
1506
}
1499
1507
1500
- fprintf (stderr, " #2 " );
1501
1508
dynamixel::PortHandler *port = robot_->ports_ [device->port_name_ ];
1502
1509
dynamixel::PacketHandler *packet_handler = dynamixel::PacketHandler::getPacketHandler (device->protocol_version_ );
1503
1510
@@ -1506,17 +1513,13 @@ void RobotisController::writeControlTableCallback(const robotis_controller_msgs:
1506
1513
1507
1514
queue_mutex_.lock ();
1508
1515
1509
-
1510
1516
direct_sync_write_.push_back (new dynamixel::GroupSyncWrite (port, packet_handler, item->address_ , msg->data_length ));
1511
-
1512
- fprintf (stderr, " #3 \n " );
1513
-
1514
1517
direct_sync_write_[direct_sync_write_.size () - 1 ]->addParam (device->id_ , (uint8_t *)(msg->data .data ()));
1515
1518
1516
- fprintf (stderr, " [WriteControlTable] %s -> %s : " , msg->joint_name .c_str (), msg->start_item_name .c_str ());
1517
- for (auto &dt : msg->data )
1518
- fprintf (stderr, " %02X " , dt);
1519
- 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");
1520
1523
1521
1524
queue_mutex_.unlock ();
1522
1525
@@ -1566,6 +1569,8 @@ void RobotisController::syncWriteItemCallback(const robotis_controller_msgs::Syn
1566
1569
if (item->access_type_ == Read)
1567
1570
continue ;
1568
1571
1572
+ queue_mutex_.lock ();
1573
+
1569
1574
int idx = 0 ;
1570
1575
if (direct_sync_write_.size () == 0 )
1571
1576
{
@@ -1601,6 +1606,8 @@ void RobotisController::syncWriteItemCallback(const robotis_controller_msgs::Syn
1601
1606
}
1602
1607
direct_sync_write_[idx]->addParam (device->id_ , data);
1603
1608
delete[] data;
1609
+
1610
+ queue_mutex_.unlock ();
1604
1611
}
1605
1612
}
1606
1613
0 commit comments