# check if the robot is on rack and update the pinocchio model accordingif self.base_type=="fixed": self.pin_model = pin.buildModelFromUrdf(urdf_file) self.pin_data = self.pin_model.createData() # here i assume that the robot has an actuate and an underactuated part # get the number of actuated joints self.n_b = 0 # floating base dof (x y z [0 0 0 1]) self.n_bdot = 0 # floating base velocity dof (x_dot y_dot z_dot roll_dot yaw_dot pitch_dot) self.n_q = self.pin_model.nq # joint dof self.n_qdot = self.pin_model.nv # joint velocity dof self.n = self.n_q self.n_dot = self.n_qdotelse: # TODO add the case for on_rack (only CoM position is fixed orientation is free) # Load the urdf model for pinocchio with floating base self.pin_model = pin.buildModelFromUrdf(urdf_file,pin.JointModelFreeFlyer()) self.pin_data = self.pin_model.createData() self.n_b = 7 # floating base dof (x y z [0 0 0 1]) self.n_bdot = 6 # floating base velocity dof (x_dot y_dot z_dot omega_x omega_y omega_z) base frame self.n_q = self.pin_model.nq - 7 # joint dof self.n_qdot = self.pin_model.nv - 6 # joint velocity dof self.n = self.n_q + self.n_b self.n_dot = self.n_qdot + self.n_bdot
for name in control_group_names: joint_names_in_group = self.control_groups[name] cur_joint_id = [] for joint_name in joint_names_in_group: cur_joint_id.append(self.pin_model.getJointId(joint_name)) self.control_group_id[name] = cur_joint_id