ros-industrial tutorial Training[melodic] demo代码补全记录(demo2)

Demo2 Descartes Planning and Excution

 

2.2 Load Parameters

src/tasks/load_parameters.cpp

Goal1:

/* Fill Code:

* Goal:

* - Create a private handle by passing the "~" string to its constructor

* Hint:

* - Replace the string in ph below with "~" to make it a private node.

*/

ros::NodeHandle ph("[ COMPLETE HERE ]");

代码:

ros::NodeHandle ph("~");

Goal2:

/* Fill Code:

* Goal:

* - Read missing parameters 'tip_link' and 'world_frame' from ros parameter server

*/

if(ph.getParam("group_name",config_.group_name) &&

 

ph.getParam("[ COMPLETE HERE ]",config_.tip_link) &&

 

ph.getParam("base_link",config_.base_link) &&

 

ph.getParam("[ COMPLETE HERE ]",config_.world_frame) &&

代码:将[ COMPLETE HERE ]分别替换为tip_link和world_frame。

2.3 Initialize ROS

src/tasks/init_ros.cpp

Goal1:

/* Fill Code:

* Goal:

* - Create a "moveit_msgs::ExecuteTrajectoryAction" client and assign it to the "moveit_run_path_client_ptr_"

* application variable.

* - Uncomment the action client initialization code.

* Hint:

* - Enter the action type moveit_msgs::ExecuteTrajectoryAction in between the "< >" arrow brackets of

* the client type definition, replacing the placeholder type.

*/

typedef actionlib::SimpleActionClient< bool /* [ COMPLETE_HERE ] */ > client_type;

moveit_run_path_client_ptr_; /* = std::make_shared<client_type>(EXECUTE_TRAJECTORY_ACTION,true); */

主要是创建一个moveit_msgs::ExecuteTrajectoryAction客户端,客户端变量是moveit_run_path_client_ptr_。提示是在<>中输入moveit_msgs::ExecuteTrajectoryAction。代码:

typedef actionlib::SimpleActionClient<moveit_msgs::ExecuteTrajectoryAction> client_type;

moveit_run_path_client_ptr_=std::make_shared<client_type>(EXECUTE_TRAJECTORY_ACTION,true);

2.4 Initialize Descartes

src/tasks/init_descartes.cpp

Goal1:

/* Fill Code:

* Goal:

* - Initialize the "robot_model_ptr" variable by passing the required application parameters

* into its "initialize" method.

* Hint:

* - The config_ structure contains the variables needed by the robot model

* - The "initialize" method takes the following arguments in this order

* a - robot description string

* b - group_name string.

* c - world_frame string

* d - tip_link string.

*/

if(robot_model_ptr_->initialize(ROBOT_DESCRIPTION_PARAM,

"[ COMPLETE HERE ]",

"[ COMPLETE HERE ]",

"[ COMPLETE HERE ]"))

这一步写的时候一定看一下ur5_demo.srdf中对各个link的命名,不然会提示找不到对应的关节。代码:

if(robot_model_ptr_->initialize(ROBOT_DESCRIPTION_PARAM,

"manipulator",

"world",

"tool"))

Goal2:

/* Fill Code:

* Goal:

* - Initialize the Descartes path planner by calling "planner_.initialize(...)".

* - Pass the robot_model_ptr_ created earlier into the initialize method and save the result

* into the "succeeded" variable.

*/

bool succeeded = false /* [ COMPLETE HERE ]*/;

主要是将planner_进行初始化,使用它的initialize()方法。提示是使用robot_model_ptr_作为model传入initialize(),并将初始化状态存在succeeded变量中。代码:

bool succeeded = planner_.initialize(robot_model_ptr_);

2.5 Move Home

src/tasks/move_home.cpp

Goal1:

/* Fill Code:

* Goal:

* - Call the move_group.move() and save the returned flag into the "result" variable

* - Verify that the robot reached the goal.

* Hint:

* - The "result.val" and "result.SUCCESS" flags can be used to verify that the move was completed

* -

*/

moveit_msgs::MoveItErrorCodes result /* [ COMPLETE HERE ]: = move_group.??() ;*/;

if(false /* [ COMPLETE HERE ]: result.?? != result.?? */)

调用move_group.move()方法并将其返回值存储在result中。提示是result.val和result.SUCCESS可以用来判断移动是否已经完成。代码:

moveit_msgs::MoveItErrorCodes result = move_group.move();

if(result.val != result.SUCCESS)

2.6 Generate a Semi-Constrained Trajectory

src/tasks/generate_trajectory.cpp

Goal1:

/* Fill Code:

* Goal:

* - Create AxialSymetricPt objects in order to define a trajectory cartesian point with

* rotational freedom about the tool's z axis.

*

* Hint:

* - The point can be constructed as follows:

*

* new AxialSymmetricPt(Pose ,Increment, Free Axis)

*

* - The Pose can be found in the for loop's "pose" variable.

* - The Increment can be found in the "ORIENTATION_INCREMENT" global variable.

* - The Free Axis can be selected from the AxialSymmetricPt::FreeAxis::Z_AXIS enumeration constants.

*

*/

descartes_core::TrajectoryPtPtr pt = descartes_core::TrajectoryPtPtr(/*[ COMPLETE HERE ]:

new descartes_trajectory::AxialSymmetricPt( ?? , ?? , descartes_trajectory::AxialSymmetricPt::FreeAxis::Z_AXIS) */);

提示给的很明确了。代码:

descartes_core::TrajectoryPtPtr pt =

descartes_core::TrajectoryPtPtr(new AxialSymmetricPt(pose,

ORIENTATION_INCREMENT,

AxialSymmetricPt::FreeAxis::Z_AXIS));

2.7 Plan a Robot Path

src/tasks/plan_path.cpp

Goal1:

/* Fill Code:

* Goal:

* - Call the "planner_.planPath(...)" method in order to plan a robot path from the trajectory.

* - Save the result of the planPath(...) call into the succeeded variable in order to verify that

* a valid robot path was generated.

* Hint:

* - The "planner_.planPath(...)" can take the "input_traj" Trajectory as an input argument.

*/

bool succeeded = false /* [ COMPLETE HERE ]*/;

调用planner_.planPath()方法从轨迹规划机器人路径,并将规划状态存储到succeeded变量中。提示可用input_traj作为函数的输入。代码:

bool succeeded = planner_.planPath(input_traj);

Goal2:

/* Fill Code:

* Goal:

* - Call the "planner_.getPath(...)" in order to retrieve the planned robot path.

* - Save the result of the planPath(...) call into the succeeded variable in order to verify that

* a valid robot path was generated.

* Hint:

* - The "planner_.getPath(...)" can take the "output_path" variable as an output argument.

*/

succeeded = false /* [ COMPLETE HERE ]*/;

同Goal1。代码:

succeeded = planner_.getPath(output_path);

2.8 Run a Robot Path

src/tasks/run_path.cpp

Goal1:

/* Fill Code:

* Goal:

* - Retrieve the first point in the path.

* - Save the joint values of the first point into "start_pose".

* Hint:

* - The first argument to "getNominalJointPose()" is a "seed" joint pose, used to find a nearby IK solution

* - The last argument to "getNominalJointPose()" is a "std::vector<double>" variable

* where the joint values are to be stored.

*/

std::vector<double> seed_pose(robot_model_ptr_->getDOF());

std::vector<double> start_pose;

 

descartes_core::TrajectoryPtPtr first_point_ptr /* [ COMPLETE HERE ]: = path[??]*/;

/*[ COMPLETE HERE ]: first_point_ptr->getNominalJointPose(??,*robot_model_ptr_,??); */

取回路径中的第一个点,并将这个点的joint值存储进变量start_pose中。代码:

descartes_core::TrajectoryPtPtr first_point_ptr=path[0];

first_point_ptr.getNominalJointPose(seed_pose, *robot_model_ptr_, start_pose);

Goal2:

/* Fill Code:

* Goal:

* - Complete the action goal by placing the "moveit_msgs::RobotTrajectory" trajectory in the goal object

* - Use the action client to send the trajectory for execution.

* Hint:

* - The "goal.trajectory" can be assigned the Moveit trajectory.

* - The "moveit_run_path_client_ptr_->sendGoalAndWait(goal)" sends a trajectory execution request.

*/

moveit_msgs::ExecuteTrajectoryGoal goal;

goal.trajectory ; /* [ COMPLETE HERE ]: = ?? */;

 

ROS_INFO_STREAM("Robot path sent for execution");

if(false /* [ COMPLETE HERE ]: moveit_run_path_client_ptr_->??( ?? ) == actionlib:SimpleClientGoalState::SUCCEEDED*/)

为前往目标点的路径赋值,并使用action的客户端发送轨迹信息来执行任务。代码:

code1:

goal.trajectory = moveit_traj;

code2:

if(moveit_run_path_client_ptr_->sendGoalAndWait(goal) == actionlib::SimpleClientGoalState::SUCCEEDED)

 

### 下载 Popper.min.js 文件的方法 对于希望获取 `popper.min.js` 的开发者来说,可以通过多种方式来实现这一目标。通常情况下,推荐通过官方渠道或可靠的分发网络 (CDN) 来获得最新的稳定版文件。 #### 使用 CDN 获取 Popper.min.js 最简单的方式之一是从流行的 CDN 中加载所需的 JavaScript 库。这不仅简化了集成过程,还可能提高性能,因为许多用户已经缓存了来自这些服务提供商的内容。例如: ```html <script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2/dist/umd/popper.min.js"></script> ``` 这种方式不需要手动下载文件到本地服务器;只需将上述 `<script>` 标签添加至 HTML 文档中的适当位置即可立即使用 Popper 功能[^1]。 #### 从 npm 或 yarn 安装 如果项目采用模块化构建工具链,则可以直接利用包管理器如 npm 或 Yarn 进行安装。命令如下所示: ```bash npm install @popperjs/core # 或者 yarn add @popperjs/core ``` 之后可以根据具体需求引入特定功能模块,而不是整个库,从而减少打包后的体积并优化加载速度[^2]。 #### 访问 GitHub 发布页面下载压缩包 另一种方法是访问 Popper.js 的 [GitHub Releases](https://github.com/popperjs/popper-core/releases) 页面,在这里可以选择不同版本的 tarball 或 zip 归档进行下载解压操作。这种方法适合那些偏好离线工作环境或是想要定制编译选项的人群[^3]。 #### 手动克隆仓库 最后一种较为少见但也可行的办法便是直接克隆完整的 Git 存储库副本。这样可以获得开发分支以及历史记录等更多信息,适用于贡献代码或者深入学习内部机制的情况。 ```bash git clone https://github.com/popperjs/popper-core.git cd popper-core ``` 完成以上任一途径后便能成功取得所需版本的 Popper.min.js 文件,并将其应用于个人项目之中[^4]。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值