ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Thanks! that's exactly what I was looking for. In brief the twist message should be converted into velocity using this function

void OnTwistMsg(const geometry_msgs::TwistConstPtr &_msg) { auto yaw = (float)model->WorldPose().Rot().Yaw(); model->SetLinearVel(ignition::math::Vector3d( _msg->linear.x * cosf(yaw) - _msg->linear.y * sinf(yaw), _msg->linear.y * cosf(yaw) + _msg->linear.x * sinf(yaw), 0)); model->SetAngularVel(ignition::math::Vector3d(0, 0, _msg->angular.z)); }

Thanks! that's exactly what I was looking for. In brief the twist message should be converted into velocity using this function

void OnTwistMsg(const geometry_msgs::TwistConstPtr &_msg) {
            auto yaw = (float)model->WorldPose().Rot().Yaw();
            model->SetLinearVel(ignition::math::Vector3d(
                    _msg->linear.x * cosf(yaw) - _msg->linear.y * sinf(yaw),
                    _msg->linear.y  * cosf(yaw) + _msg->linear.x * sinf(yaw),
                    0));
            model->SetAngularVel(ignition::math::Vector3d(0, 0, _msg->angular.z));
}

}