Skip to content

Commit 963f502

Browse files
authored
Merge pull request #51 from ROBOTIS-GIT/master
merge for sync kinetic-devel and master branch
2 parents f08d522 + da6ed0e commit 963f502

File tree

2 files changed

+24
-17
lines changed

2 files changed

+24
-17
lines changed

robotis_controller/src/robotis_controller/robotis_controller.cpp

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -911,12 +911,14 @@ void RobotisController::process()
911911

912912
if (dxl->bulk_read_items_.size() > 0)
913913
{
914-
uint32_t data = 0;
914+
bool updated = false;
915+
uint32_t data = 0;
915916
for (int i = 0; i < dxl->bulk_read_items_.size(); i++)
916917
{
917918
ControlTableItem *item = dxl->bulk_read_items_[i];
918919
if (port_to_bulk_read_[port_name]->isAvailable(dxl->id_, item->address_, item->data_length_) == true)
919920
{
921+
updated = true;
920922
data = port_to_bulk_read_[port_name]->getData(dxl->id_, item->address_, item->data_length_);
921923

922924
// change dxl_state
@@ -938,7 +940,8 @@ void RobotisController::process()
938940
}
939941

940942
// -> 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);
942945
}
943946
}
944947
}
@@ -954,12 +957,14 @@ void RobotisController::process()
954957

955958
if (sensor->bulk_read_items_.size() > 0)
956959
{
957-
uint32_t data = 0;
960+
bool updated = false;
961+
uint32_t data = 0;
958962
for (int i = 0; i < sensor->bulk_read_items_.size(); i++)
959963
{
960964
ControlTableItem *item = sensor->bulk_read_items_[i];
961965
if (port_to_bulk_read_[port_name]->isAvailable(sensor->id_, item->address_, item->data_length_) == true)
962966
{
967+
updated = true;
963968
data = port_to_bulk_read_[port_name]->getData(sensor->id_, item->address_, item->data_length_);
964969

965970
// change sensor_state
@@ -968,7 +973,8 @@ void RobotisController::process()
968973
}
969974

970975
// -> 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);
972978
}
973979
}
974980
}
@@ -1463,9 +1469,11 @@ void RobotisController::removeSensorModule(SensorModule *module)
14631469

14641470
void RobotisController::writeControlTableCallback(const robotis_controller_msgs::WriteControlTable::ConstPtr &msg)
14651471
{
1466-
fprintf(stderr, "[WriteControlTable] led control msg received\n");
14671472
Device *device = NULL;
14681473

1474+
if (DEBUG_PRINT)
1475+
fprintf(stderr, "[WriteControlTable] led control msg received\n");
1476+
14691477
auto dev_it1 = robot_->dxls_.find(msg->joint_name);
14701478
if(dev_it1 != robot_->dxls_.end())
14711479
{
@@ -1484,7 +1492,7 @@ void RobotisController::writeControlTableCallback(const robotis_controller_msgs:
14841492
return;
14851493
}
14861494
}
1487-
fprintf(stderr, " #1 ");
1495+
14881496
ControlTableItem *item = NULL;
14891497
auto item_it = device->ctrl_table_.find(msg->start_item_name);
14901498
if(item_it != device->ctrl_table_.end())
@@ -1493,11 +1501,10 @@ void RobotisController::writeControlTableCallback(const robotis_controller_msgs:
14931501
}
14941502
else
14951503
{
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());
14971505
return;
14981506
}
14991507

1500-
fprintf(stderr, " #2 ");
15011508
dynamixel::PortHandler *port = robot_->ports_[device->port_name_];
15021509
dynamixel::PacketHandler *packet_handler = dynamixel::PacketHandler::getPacketHandler(device->protocol_version_);
15031510

@@ -1506,17 +1513,13 @@ void RobotisController::writeControlTableCallback(const robotis_controller_msgs:
15061513

15071514
queue_mutex_.lock();
15081515

1509-
15101516
direct_sync_write_.push_back(new dynamixel::GroupSyncWrite(port, packet_handler, item->address_, msg->data_length));
1511-
1512-
fprintf(stderr, " #3 \n");
1513-
15141517
direct_sync_write_[direct_sync_write_.size() - 1]->addParam(device->id_, (uint8_t *)(msg->data.data()));
15151518

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");
15201523

15211524
queue_mutex_.unlock();
15221525

@@ -1566,6 +1569,8 @@ void RobotisController::syncWriteItemCallback(const robotis_controller_msgs::Syn
15661569
if (item->access_type_ == Read)
15671570
continue;
15681571

1572+
queue_mutex_.lock();
1573+
15691574
int idx = 0;
15701575
if (direct_sync_write_.size() == 0)
15711576
{
@@ -1601,6 +1606,8 @@ void RobotisController::syncWriteItemCallback(const robotis_controller_msgs::Syn
16011606
}
16021607
direct_sync_write_[idx]->addParam(device->id_, data);
16031608
delete[] data;
1609+
1610+
queue_mutex_.unlock();
16041611
}
16051612
}
16061613

robotis_device/devices/sensor/OPEN-CR.device

100644100755
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ device_type = sensor
1010
4 | baudrate | 1 | RW | EEPROM | 0 | 252 | N
1111
5 | return_delay_time | 1 | RW | EEPROM | 0 | 254 | N
1212
16 | status_return_level | 1 | RW | EEPROM | 0 | 2 | N
13-
24 | torque_enable | 1 | RW | RAM | 0 | 1 | N
13+
24 | dynamixel_power | 1 | RW | RAM | 0 | 1 | N
1414
25 | LED | 1 | RW | RAM | 0 | 7 | N
1515
26 | LED_RGB | 2 | RW | RAM | 0 | 32767 | N
1616
28 | buzzer | 2 | RW | RAM | 0 | 65535 | N

0 commit comments

Comments
 (0)