38 #include <boost/shared_ptr.hpp> 41 #include <kdl/tree.hpp> 56 urdf::LinkConstSharedPtr link;
62 ROS_ERROR(
"Could not find link with name %s",link_name.c_str());
68 ROS_ERROR(
"Link %s does not have collision description. Add collision description for link to urdf.",link_name.c_str());
71 if(!link->collision->geometry)
73 ROS_ERROR(
"Link %s does not have collision geometry description. Add collision geometry description for link to urdf.",link_name.c_str());
76 if(link->collision->geometry->type != urdf::Geometry::CYLINDER)
78 ROS_ERROR(
"Link %s does not have cylinder geometry",link_name.c_str());
81 wheel_radius_ = (
dynamic_cast<urdf::Cylinder*
>(link->collision->geometry.get()))->radius;
92 urdf::Vector3
offset = link->parent_joint->parent_to_joint_origin_transform.position;
97 ROS_DEBUG(
"Loading wheel: %s",link_name_.c_str());
106 caster_speed_filtered_ = 0;
107 caster_speed_error_ = 0;
108 caster_position_error_ = 0;
109 steer_angle_stored_ = 0;
110 steer_velocity_desired_ = 0;
111 steer_angle_actual_ = 0;
114 #if URDFDOM_1_0_0_API 115 urdf::LinkConstSharedPtr link;
121 ROS_ERROR(
"Could not find link with name %s",link_name.c_str());
124 ROS_DEBUG(
"caster name: %s",link_name.c_str());
133 urdf::Vector3
offset = link->parent_joint->parent_to_joint_origin_transform.position;
138 for(
unsigned int i=0;
i < link->child_links.size();
i++)
140 #if URDFDOM_1_0_0_API 141 urdf::LinkSharedPtr child = link->child_links[
i];
146 parent_->wheel_.push_back(tmp);
149 ROS_ERROR(
"Could not initialize caster %s",link_name.c_str());
160 std::string caster_names_string;
161 std::vector<std::string> caster_names;
168 robot_state_ = robot_state;
170 node.
param<std::string> (
"caster_names",caster_names_string,
"");
171 std::stringstream ss(caster_names_string);
175 caster_names.push_back(tmp);
178 for(
unsigned int i=0;
i < caster_names.size();
i++)
181 caster_.push_back(tmp);
182 caster_[num_casters_].
parent_ =
this;
183 ROS_DEBUG(
"caster name: %s",caster_names[
i].c_str());
185 if(!caster_[num_casters_].
init(robot_state, n, caster_names[
i]))
187 ROS_ERROR(
"Could not initialize base kinematics");
195 node.
param<
double> (
"wheel_radius_multiplier", multiplier, 1.0);
196 int wheel_counter = 0;
197 for(
int j = 0; j < num_casters_; j++)
199 for(
int i = 0;
i < caster_[j].num_children_;
i++)
201 wheel_[wheel_counter].parent_ = &(caster_[j]);
202 wheel_[wheel_counter].wheel_radius_*=multiplier;
222 for(
int i = 0;
i < num_wheels_;
i++)
224 wheel_[
i].updatePosition();
231 geometry_msgs::Twist result;
232 result.linear.x = vel.linear.x - pos.y * vel.angular.z;
233 result.linear.y = vel.linear.y + pos.x * vel.angular.z;
234 result.angular.z = 0;
double wheel_speed_cmd_
desired wheel speed
pr2_mechanism_model::JointState * joint_
JointState for this caster joint.
std::string link_name_
name of the link
double wheel_radius_
wheel radius scale (based on the default wheel radius in Basekinematics)
geometry_msgs::Point offset_
offset from the center of the base
bool init(pr2_mechanism_model::RobotState *robot_state, ros::NodeHandle &node, std::string link_name)
bool init(pr2_mechanism_model::RobotState *robot_state, ros::NodeHandle &node, std::string link_name)
Loads wheel's information from the xml description file and param server.
std::string joint_name_
name of the joint
geometry_msgs::Point offset_
default offset from the parent caster before any transformations
geometry_msgs::Point position_
offset_ after rotation transformation from the parent caster's position
int wheel_stuck_
remembers if the wheel is stalled
Caster * parent_
the caster on which this wheel is mounted
geometry_msgs::Twist pointVel2D(const geometry_msgs::Point &pos, const geometry_msgs::Twist &vel)
Computes 2d velocity of a point at relative distance pos to another point with velocity (and rotation...
bool param(const std::string ¶m_name, T ¶m_val, const T &default_val) const
double wheel_speed_actual_
actual wheel speeds
int direction_multiplier_
specifies the default direction of the wheel
BaseKinematics * parent_
BaseKinematics to which this caster belongs.
pr2_mechanism_model::JointState * joint_
JointState for this wheel joint.
JointState * getJointState(const std::string &name)
double wheel_speed_filtered_
wheel speed filtered with alpha
bool init(pr2_mechanism_model::RobotState *robot_state, ros::NodeHandle &node)
Loads BaseKinematic's information from the xml description file and param server. ...
const std::string & getNamespace() const
INLINE Rall1d< T, V, S > cos(const Rall1d< T, V, S > &arg)
void computeWheelPositions()
Computes 2d postion of every wheel relative to the center of the base.
INLINE Rall1d< T, V, S > sin(const Rall1d< T, V, S > &arg)
double wheel_speed_error_
difference between desired and actual speed
void updatePosition()
Computes 2d postion of the wheel relative to the center of the base.