void World::load_robot_joints()

in roboschool/cpp-household/physics-bullet.cpp [206:251]


void World::load_robot_joints(const shared_ptr<Robot>& robot, const std::string& original_fn)
{
	b3BodyInfo root;
	b3GetBodyInfo(client, robot->bullet_handle, &root);
	robot->root_part.reset(new Thingy);
	robot->root_part->name = root.m_baseName;
	robot->original_urdf_name = original_fn + ":" + root.m_baseName;

	int cnt = b3GetNumJoints(client, robot->bullet_handle);
	robot->joints.resize(cnt);
	robot->robot_parts.resize(cnt);
	for (int c=0; c<cnt; c++) {
		struct b3JointInfo info;
		b3GetJointInfo(client, robot->bullet_handle, c, &info);
		//enum JointType {
		//eRevoluteType = 0,
		//ePrismaticType = 1,
		//eSphericalType = 2,
		//ePlanarType = 3,
		//eFixedType = 4,
		//ePoint2PointType = 5,
		if (info.m_jointType==eRevoluteType || info.m_jointType==ePrismaticType) {
			shared_ptr<Joint>& j = robot->joints[c];
			j.reset(new Joint);
			j->wref = shared_from_this();
			j->robot = robot;
			j->joint_name = info.m_jointName;
			j->joint_type = info.m_jointType==eRevoluteType ? Joint::ROTATIONAL_MOTOR : Joint::LINEAR_MOTOR;
			j->bullet_qindex = info.m_qIndex;
			j->bullet_uindex = info.m_uIndex;
			j->bullet_joint_n = c;
			j->joint_has_limits = info.m_jointLowerLimit < info.m_jointUpperLimit;
			j->joint_limit1 = info.m_jointLowerLimit;
			j->joint_limit2 = info.m_jointUpperLimit;
			j->joint_max_force = info.m_jointMaxForce;
			j->joint_max_velocity = info.m_jointMaxVelocity;
		}

		shared_ptr<Thingy> part = robot->robot_parts[c];
		part.reset(new Thingy);
		part->bullet_handle = robot->bullet_handle;
		part->bullet_link_n = c;
		part->name = info.m_linkName;
		robot->robot_parts[c] = part;
	}
}