实习Day2

URDF接口

/legged_common/scripts/generate_urdf.sh

bash 复制代码
#!/usr/bin/env sh
mkdir -p /tmp/legged_control/
rosrun xacro xacro $1 robot_type:=$2 > /tmp/legged_control/$2.urdf

/legged_controllers/launch/load_controller.launch

xml 复制代码
<param name="urdfFile" value="/tmp/legged_control/$(arg robot_type).urdf"/>

/legged_controllers/src/LeggedController.cpp

cpp 复制代码
bool LeggedController::init(hardware_interface::RobotHW* robot_hw, ros::NodeHandle& controller_nh)
{
	// Initialize OCS2
  	std::string urdfFile;
  	controller_nh.getParam("/urdfFile", urdfFile);
	setupLeggedInterface(taskFile, urdfFile, referenceFile, verbose);
	// Visualization
    // Hardware interface
}

void LeggedController::setupLeggedInterface(const std::string& taskFile, const std::string& urdfFile, const std::string& referenceFile,
                                            bool verbose) {
  	leggedInterface_ = std::make_shared<LeggedInterface>(taskFile, urdfFile, referenceFile);
  	leggedInterface_->setupOptimalControlProblem(taskFile, urdfFile, referenceFile, verbose);
}

/legged_control/legged_examples/legged_unitree/legged_unitree_description/launch/empty_world.launch

xml 复制代码
<param name="legged_robot_description" command="$(find xacro)/xacro $(find legged_unitree_description)/urdf/robot.xacro
       robot_type:=$(arg robot_type)"/>
<node name="generate_urdf" pkg="legged_common" type="generate_urdf.sh" output="screen"
      args="$(find legged_unitree_description)/urdf/robot.xacro $(arg robot_type)"/>
<!-- push robot_description to factory and spawn robot in gazebo -->
<node name="spawn_urdf" pkg="gazebo_ros" type="spawn_model" clear_params="true"
      args="-z 0.5 -param legged_robot_description -urdf -model $(arg robot_type)" output="screen"/> 

/legged_control/legged_examples/legged_unitree/legged_unitree_hw/launch/legged_unitree_hw.launch

xml 复制代码
<launch>
    <arg name="robot_type" default="$(env ROBOT_TYPE)" doc="Robot type: [a1, aliengo, go1, laikago]"/>

    <param name="legged_robot_description" command="$(find xacro)/xacro $(find legged_unitree_description)/urdf/robot.xacro
       robot_type:=$(arg robot_type)
    "/>
    <node name="generate_urdf" pkg="legged_common" type="generate_urdf.sh" output="screen"
          args="$(find legged_unitree_description)/urdf/robot.xacro $(arg robot_type)"/>

    <rosparam file="$(find legged_unitree_hw)/config/$(arg robot_type).yaml" command="load"/>

    <param name="robot_type" value="$(arg robot_type)"/>
    <include file="$(find legged_unitree_hw)/launch/$(arg robot_type).launch"/>
</launch>

/legged_control/legged_examples/legged_gazebo/src/LeggedHWSim.cpp

cpp 复制代码
bool LeggedHWSim::initSim(const std::string& robot_namespace, ros::NodeHandle model_nh, gazebo::physics::ModelPtr parent_model,
                          const urdf::Model* urdf_model, std::vector<transmission_interface::TransmissionInfo> transmissions) 

/home/bigdavid/legged_control/legged_hw

cpp 复制代码
//Get params from param server and check whether these params are set. Load urdf of robot
// param root_nh Root node-handle of a ROS node.
// param robot_hw_nh Node-handle for robot hardware.
bool init(ros::NodeHandle& root_nh, ros::NodeHandle& robot_hw_nh) override;

// URDF model of the robot
  std::shared_ptr<urdf::Model> urdfModel_;
  /** \brief Load urdf of robot from param server.
   *
   * Load urdf of robot from param server.
   *
   * @param rootNh Root node-handle of a ROS node
   * @return True if successful.
   */
  bool loadUrdf(ros::NodeHandle& rootNh);
cpp 复制代码
bool LeggedHW::loadUrdf(ros::NodeHandle& rootNh) {
  std::string urdfString;
  if (urdfModel_ == nullptr) {
    urdfModel_ = std::make_shared<urdf::Model>();
  }
  // get the urdf param on param server
  rootNh.getParam("legged_robot_description", urdfString);
  return !urdfString.empty() && urdfModel_->initString(urdfString);
}

/home/bigdavid/legged_control/legged_hw/include/legged_hw/LeggedHWLoop.h

cpp 复制代码
LeggedHWLoop(ros::NodeHandle& nh, std::shared_ptr<LeggedHW> hardware_interface);
// Abstract Hardware Interface for your robot
  std::shared_ptr<LeggedHW> hardwareInterface_;

/home/bigdavid/legged_control/legged_interface/include/legged_interface/LeggedInterface.h

cpp 复制代码
LeggedInterface(const std::string& taskFile, const std::string& urdfFile, const std::string& referenceFile,
                  bool useHardFrictionConeConstraint = false);
virtual void setupOptimalControlProblem(const std::string& taskFile, const std::string& urdfFile, const std::string& referenceFile,
                                          bool verbose);
   

/home/bigdavid/legged_control/legged_interface/src/LeggedInterface.cpp

cpp 复制代码
// check that urdf file exists
  // 检查URDF文件是否存在
  boost::filesystem::path urdfFilePath(urdfFile);
  if (boost::filesystem::exists(urdfFilePath)) {
    std::cerr << "[LeggedInterface] Loading Pinocchio model from: " << urdfFilePath << std::endl;
  } else {
    throw std::invalid_argument("[LeggedInterface] URDF file not found: " + urdfFilePath.string());
  }

void LeggedInterface::setupModel(const std::string& taskFile, const std::string& urdfFile, const std::string& referenceFile,
                                 bool /*verbose*/) {
  // PinocchioInterface
  pinocchioInterfacePtr_ =
      std::make_unique<PinocchioInterface>(centroidal_model::createPinocchioInterface(urdfFile, modelSettings_.jointNames));

  // CentroidalModelInfo
  centroidalModelInfo_ = centroidal_model::createCentroidalModelInfo(
      *pinocchioInterfacePtr_, centroidal_model::loadCentroidalType(taskFile),
      centroidal_model::loadDefaultJointState(pinocchioInterfacePtr_->getModel().nq - 6, referenceFile), modelSettings_.contactNames3DoF,
      modelSettings_.contactNames6DoF);
}

void LeggedInterface::setupReferenceManager(const std::string& taskFile, const std::string& urdfFile, const std::string& referenceFile,
                                            bool verbose) {
  auto swingTrajectoryPlanner =
      std::make_unique<SwingTrajectoryPlanner>(loadSwingTrajectorySettings(taskFile, "swing_trajectory_config", verbose), 4);
  referenceManagerPtr_ =
      std::make_shared<SwitchedModelReferenceManager>(loadGaitSchedule(referenceFile, verbose), std::move(swingTrajectoryPlanner));
}
相关推荐
EAI-Robotics3 小时前
机器人打包物品研究现状简述
机器人
肥猪猪爸3 小时前
使用卡尔曼滤波器估计pybullet中的机器人位置
数据结构·人工智能·python·算法·机器人·卡尔曼滤波·pybullet
清安无别事7 小时前
闲聊?泳池清洁机器人?
机器人
zhd15306915625ff7 小时前
库卡机器人维护需要注意哪些事项
安全·机器人·自动化
宋1381027972011 小时前
Manus Xsens Metagloves虚拟现实手套
人工智能·机器人·vr·动作捕捉
禁默12 小时前
第六届机器人、智能控制与人工智能国际学术会议(RICAI 2024)
人工智能·机器人·智能控制
Robot2511 天前
Figure 02迎重大升级!!人形机器人独角兽[Figure AI]商业化加速
人工智能·机器人·微信公众平台
FreeIPCC1 天前
谈一下开源生态对 AI人工智能大模型的促进作用
大数据·人工智能·机器人·开源
施努卡机器视觉1 天前
电解车间铜业机器人剥片技术是现代铜冶炼过程中自动化和智能化的重要体现
运维·机器人·自动化
zhd15306915625ff2 天前
库卡机器人日常维护
网络·机器人·自动化·机器人备件