实习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));
}
相关推荐
深圳市青牛科技实业有限公司5 小时前
【青牛科技】应用方案|D2587A高压大电流DC-DC
人工智能·科技·单片机·嵌入式硬件·机器人·安防监控
道可云10 小时前
道可云人工智能&元宇宙每日资讯|2024国际虚拟现实创新大会将在青岛举办
大数据·人工智能·3d·机器人·ar·vr
微凉的衣柜11 小时前
Meta AI 推出机器人开源项目:推动触觉感知和人机交互的前沿研究
人工智能·机器人·人机交互
袁牛逼11 小时前
自动打电话机器人,好用吗?
机器人
资源补给站11 小时前
论文2—《基于柔顺控制的智能神经导航手术机器人系统设计》文献阅读分析报告
机器学习·机器人·手术机器人
袁牛逼11 小时前
ai外呼机器人的作用有哪些?
人工智能·机器人
云卓SKYDROID15 小时前
除草机器人算法以及技术详解!
算法·机器人·科普·高科技·云卓科技·算法技术
袁牛逼1 天前
电话语音机器人,是由哪些功能构成?
人工智能·自然语言处理·机器人·语音识别
TsingtaoAI1 天前
2024.10|AI/大模型在机器人/自动驾驶/智能驾舱领域的最新应用和深度洞察
机器人·自动驾驶·ai大模型·具身智能·智能驾舱
不是AI1 天前
【持续更新】【NLP项目】【自然语言处理】智能聊天机器人——“有问必答”【Chatbot】第2章、《模式一:问候模式》
人工智能·自然语言处理·机器人