Skip to content

Commit

Permalink
Get poistion and veliocity callbacks fixed
Browse files Browse the repository at this point in the history
The two methods did not take into consideration the joint type when
converting the obtained data to radians
  • Loading branch information
elandini84 committed Sep 8, 2023
1 parent c429228 commit 39d6ad3
Showing 1 changed file with 26 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -516,10 +516,20 @@ void ControlBoard_nws_ros2::getPositionCallback(const std::shared_ptr<rmw_reques
return;
}

double posRad;
double position;
JointTypeEnum jType;
for (size_t i=0; i<forLimit; i++){
posRad = convertDegreesToRadians(tempPos[noJoints ? i : m_quickJointRef[request->names[i]]]);
positionsToSend.push_back(posRad);
size_t index = noJoints ? i : m_quickJointRef[request->names[i]];
m_iAxisInfo->getJointType(index, jType);
if(jType == VOCAB_JOINTTYPE_REVOLUTE)
{
position = convertDegreesToRadians(tempPos[index]);
}
else
{
position = tempPos[index];
}
positionsToSend.push_back(position);
}
response->positions = positionsToSend;
response->response = "OK";
Expand Down Expand Up @@ -565,10 +575,20 @@ void ControlBoard_nws_ros2::getVelocityCallback(const std::shared_ptr<rmw_reques
return;
}

double velRad;
double velocity;
JointTypeEnum jType;
for (size_t i=0; i<forLimit; i++){
velRad = convertDegreesToRadians(tempVel[noJoints ? i : m_quickJointRef[request->names[i]]]);
velocitiesToSend.push_back(velRad);
size_t index = noJoints ? i : m_quickJointRef[request->names[i]];
m_iAxisInfo->getJointType(index, jType);
if(jType == VOCAB_JOINTTYPE_REVOLUTE)
{
velocity = convertDegreesToRadians(tempVel[index]);
}
else
{
velocity = tempVel[index];
}
velocitiesToSend.push_back(velocity);
}
response->velocities = velocitiesToSend;
response->response = "OK";
Expand Down

0 comments on commit 39d6ad3

Please sign in to comment.