Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix bug noetic windows #344

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@
// SYNC_READ_HANDLER(Only for Protocol 2.0)
#define SYNC_READ_HANDLER_FOR_PRESENT_POSITION_VELOCITY_CURRENT 0

// #define DEBUG
//#define DEBUG

#define MY_DEBUG

typedef struct
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ bool DynamixelController::getPresentPosition(std::vector<std::string> dxl_name)
{
result = dxl_wb_->syncRead(SYNC_READ_HANDLER_FOR_PRESENT_POSITION_VELOCITY_CURRENT,
id_array.data(),
dxl_name.size(),
(uint8_t)dxl_name.size(),
&log);
if (result == false)
{
Expand Down Expand Up @@ -365,7 +365,7 @@ void DynamixelController::readCallback(const ros::TimerEvent&)
{
result = dxl_wb_->syncRead(SYNC_READ_HANDLER_FOR_PRESENT_POSITION_VELOCITY_CURRENT,
id_array.data(),
dynamixel_.size(),
(uint8_t)dynamixel_.size(),
&log);
if (result == false)
{
Expand Down Expand Up @@ -567,7 +567,7 @@ void DynamixelController::commandVelocityCallback(const geometry_msgs::Twist::Co
else if (wheel_velocity[RIGHT] > 0.0f) dynamixel_velocity[RIGHT] = (wheel_velocity[RIGHT] * velocity_constant_value);
}

result = dxl_wb_->syncWrite(SYNC_WRITE_HANDLER_FOR_GOAL_VELOCITY, id_array.data(), dynamixel_.size(), dynamixel_velocity.data(), 1, &log);
result = dxl_wb_->syncWrite(SYNC_WRITE_HANDLER_FOR_GOAL_VELOCITY, id_array.data(), (uint8_t)dynamixel_.size(), dynamixel_velocity.data(), 1, &log);
if (result == false)
{
ROS_ERROR("%s", log);
Expand Down Expand Up @@ -596,16 +596,34 @@ void DynamixelController::writeCallback(const ros::TimerEvent&)
id_cnt++;
}




if (is_moving_ == true)
{
for (uint8_t index = 0; index < id_cnt; index++)
for (uint8_t index = 0; index < id_cnt; index++){
dynamixel_position[index] = dxl_wb_->convertRadian2Value(id_array[index], jnt_tra_msg_->points[point_cnt].positions.at(index));

#ifdef MY_DEBUG
printf("new join pos. %d %d %f\n", id_array[index], dynamixel_position[index], jnt_tra_msg_->points[point_cnt].positions.at(index));
#endif
}

#ifdef MY_DEBUG
printf("end \n");
#endif

result = dxl_wb_->syncWrite(SYNC_WRITE_HANDLER_FOR_GOAL_POSITION, id_array.data(), id_cnt, dynamixel_position.data(), 1, &log);
if (result == false)
{
ROS_ERROR("%s", log);
}
else
#ifdef DEBUG
ROS_DEBUG("[syncWrite] result %s", log);
#endif



position_cnt++;
if (position_cnt >= jnt_tra_msg_->points[point_cnt].positions.size())
Expand Down Expand Up @@ -670,6 +688,9 @@ void DynamixelController::trajectoryMsgCallback(const trajectory_msgs::JointTraj
else wp.acceleration = 0.0f;

goal.push_back(wp);

ROS_INFO("New Goal Pos.: %s %f", jnt_tra_msg_->joint_names[id_num], wp.position);

}

if (use_moveit_ == true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1040,7 +1040,13 @@ bool DynamixelDriver::syncWrite(uint8_t index, uint8_t *id, uint8_t id_num, int3
}
}

sdk_error.dxl_addparam_result = syncWriteHandler_[index].groupSyncWrite->addParam(id[i], (uint8_t *)&multi_parameter);
#ifdef DEBUG

printf("'%u' '%u' ", id[i], data[cnt-1]);
printf("'%#02x' '%#02x' '%#02x' '%#02x' \n", parameter[0], parameter[1],parameter[2],parameter[3]);
#endif

sdk_error.dxl_addparam_result = syncWriteHandler_[index].groupSyncWrite->addParam(id[i], multi_parameter.data());
if (sdk_error.dxl_addparam_result != true)
{
if (log != NULL) *log = "groupSyncWrite addparam failed";
Expand Down