Skip to content

Commit 6b2faa3

Browse files
committed
Merge pull request #22 in OSHC/syropod_highlevel_controller from feature/joint_offset_param to master
* commit '467f7a806a6f08bf73e3aa613e74bade0112c072': Added param to add joint position offset to input and output joint state/command to/from SHC
2 parents d5e3adf + 467f7a8 commit 6b2faa3

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

include/syropod_highlevel_controller/model.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -627,6 +627,7 @@ class Joint
627627

628628
const double min_position_ = 0.0; ///< The minimum position allowed for this joint
629629
const double max_position_ = 0.0; ///< The maximum position allowed for this joint
630+
const double offset_ = 0.0; ///< The position offset applied at output of SHC
630631
std::vector<double> packed_positions_ ; ///< The defined position of this joint in a 'packed' state
631632
const double unpacked_position_ = 0.0; ///< The defined position of this joint in an 'unpacked' state
632633
const double max_angular_speed_ = 0.0; ///< The maximum angular speed of this joint

src/model.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1031,6 +1031,7 @@ Joint::Joint(std::shared_ptr<Leg> leg, std::shared_ptr<Link> reference_link,
10311031
, id_name_(leg->getIDName() + "_" + params.joint_id.data[id_number_ - 1] + "_joint")
10321032
, min_position_(params.joint_parameters[leg->getIDNumber()][id_number_ - 1].data.at("min"))
10331033
, max_position_(params.joint_parameters[leg->getIDNumber()][id_number_ - 1].data.at("max"))
1034+
, offset_(params.joint_parameters[leg->getIDNumber()][id_number_ - 1].data.at("offset"))
10341035
, unpacked_position_(params.joint_parameters[leg->getIDNumber()][id_number_ - 1].data.at("unpacked"))
10351036
, max_angular_speed_(params.joint_parameters[leg->getIDNumber()][id_number_ - 1].data.at("max_vel"))
10361037
{
@@ -1080,6 +1081,7 @@ Joint::Joint(std::shared_ptr<Joint> joint)
10801081
, id_name_(joint->id_name_)
10811082
, min_position_(joint->min_position_)
10821083
, max_position_(joint->max_position_)
1084+
, offset_(joint->offset_)
10831085
, packed_positions_(joint->packed_positions_)
10841086
, unpacked_position_(joint->unpacked_position_)
10851087
, max_angular_speed_(joint->max_angular_speed_)

src/state_controller.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -792,7 +792,7 @@ void StateController::publishDesiredJointState(void)
792792
{
793793
std::shared_ptr<Joint> joint = joint_it->second;
794794
std_msgs::Float64 position_command_msg;
795-
position_command_msg.data = joint->desired_position_;
795+
position_command_msg.data = joint->desired_position_ + joint->offset_;
796796
joint->desired_position_publisher_.publish(position_command_msg);
797797
}
798798
}
@@ -1579,7 +1579,7 @@ void StateController::jointStatesCallback(const sensor_msgs::JointState &joint_s
15791579
ROS_ASSERT(leg != NULL);
15801580
std::shared_ptr<Joint> joint = leg->getJointByIDName(joint_name);
15811581
ROS_ASSERT(joint != NULL);
1582-
joint->current_position_ = joint_states.position[i];
1582+
joint->current_position_ = joint_states.position[i] - joint->offset_;
15831583
if (get_velocity_values)
15841584
{
15851585
joint->current_velocity_ = joint_states.velocity[i];

0 commit comments

Comments
 (0)