Skip to content

Commit ac3dc6d

Browse files
committed
- OpenCR control table item name changed. (torque_enable -> dynamixel_power)
- fixed to not update update_time_stamp_ if bulk read fails.
1 parent 35af44b commit ac3dc6d

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

robotis_controller/src/robotis_controller/robotis_controller.cpp

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ void RobotisController::initializeSyncWrite()
6161
if (gazebo_mode_ == true)
6262
return;
6363

64-
ROS_INFO("FIRST BULKREAD");
64+
//ROS_INFO("FIRST BULKREAD");
6565
for (auto& it : port_to_bulk_read_)
6666
it.second->txRxPacket();
6767
for(auto& it : port_to_bulk_read_)
@@ -72,15 +72,15 @@ void RobotisController::initializeSyncWrite()
7272
{
7373
if (++error_count > 10)
7474
{
75-
ROS_ERROR("[RobotisController] bulk read fail!!");
75+
ROS_ERROR("[RobotisController] first bulk read fail!!");
7676
exit(-1);
7777
}
7878
usleep(10 * 1000);
7979
result = it.second->txRxPacket();
8080
} while (result != COMM_SUCCESS);
8181
}
8282
init_pose_loaded_ = true;
83-
ROS_INFO("FIRST BULKREAD END");
83+
//ROS_INFO("FIRST BULKREAD END");
8484

8585
// clear syncwrite param setting
8686
for (auto& it : port_to_sync_write_position_)
@@ -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
}

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)