Skip to content

Commit

Permalink
Merge pull request #174 from liyixin135/enter-rate
Browse files Browse the repository at this point in the history
Initialize odom2gimbal_des
  • Loading branch information
d0h0s authored Jul 29, 2024
2 parents 2f23f4b + 087fd99 commit d46ab52
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
9 changes: 6 additions & 3 deletions rm_chassis_controllers/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ find_package(catkin REQUIRED
controller_interface
effort_controllers
tf2_geometry_msgs
nav_msgs
angles
)
)

find_package(Eigen3 REQUIRED)

Expand All @@ -45,6 +46,8 @@ catkin_package(

effort_controllers
tf2_geometry_msgs
nav_msgs
angles
LIBRARIES ${PROJECT_NAME}
)

Expand All @@ -66,12 +69,12 @@ add_library(${PROJECT_NAME}
src/sentry.cpp
src/swerve.cpp
src/balance.cpp
)
)

## Specify libraries to link executable targets against
target_link_libraries(${PROJECT_NAME}
${catkin_LIBRARIES}
)
)

#############
## Install ##
Expand Down
17 changes: 13 additions & 4 deletions rm_gimbal_controllers/src/gimbal_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,22 @@ bool Controller::init(hardware_interface::RobotHW* robot_hw, ros::NodeHandle& ro
return true;
}

void Controller::starting(const ros::Time& /*unused*/)
void Controller::starting(const ros::Time& time)
{
state_ = RATE;
state_changed_ = true;
try
{
odom2pitch_ = robot_state_handle_.lookupTransform("odom", pitch_joint_urdf_->child_link_name, time);
}
catch (tf2::TransformException& ex)
{
ROS_WARN("%s", ex.what());
return;
}
odom2gimbal_des_.transform.rotation = odom2pitch_.transform.rotation;
odom2gimbal_des_.header.stamp = time;
robot_state_handle_.setTransform(odom2gimbal_des_, "rm_gimbal_controllers");
}

void Controller::update(const ros::Time& time, const ros::Duration& period)
Expand Down Expand Up @@ -254,9 +266,6 @@ void Controller::rate(const ros::Time& time, const ros::Duration& period)
{ // on enter
state_changed_ = false;
ROS_INFO("[Gimbal] Enter RATE");
odom2gimbal_des_.transform.rotation = odom2pitch_.transform.rotation;
odom2gimbal_des_.header.stamp = time;
robot_state_handle_.setTransform(odom2gimbal_des_, "rm_gimbal_controllers");
}
else
{
Expand Down

0 comments on commit d46ab52

Please sign in to comment.