Skip to content

Commit

Permalink
Add support for running using sim time.
Browse files Browse the repository at this point in the history
  • Loading branch information
peci1 committed Mar 23, 2021
1 parent a691e6a commit 3e75026
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion champ/include/champ
9 changes: 7 additions & 2 deletions champ_base/src/quadruped_controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,14 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#include <quadruped_controller.h>

champ::PhaseGenerator::Time rosTimeToChampTime(const ros::Time& time)
{
return time.toNSec() / 1000ul;
}

QuadrupedController::QuadrupedController(ros::NodeHandle *nh, ros::NodeHandle *pnh):
body_controller_(base_),
leg_controller_(base_),
leg_controller_(base_, rosTimeToChampTime(ros::Time::now())),
kinematics_(base_)
{
std::string joint_control_topic = "joint_group_position_controller/command";
Expand Down Expand Up @@ -91,7 +96,7 @@ void QuadrupedController::controlLoop_(const ros::TimerEvent& event)
bool foot_contacts[4];

body_controller_.poseCommand(target_foot_positions, req_pose_);
leg_controller_.velocityCommand(target_foot_positions, req_vel_);
leg_controller_.velocityCommand(target_foot_positions, req_vel_, rosTimeToChampTime(ros::Time::now()));
kinematics_.inverse(target_joint_positions, target_foot_positions);

for(size_t i = 0; i < 4; i++)
Expand Down

0 comments on commit 3e75026

Please sign in to comment.