diff --git a/CMakeLists.txt b/CMakeLists.txt index 5b334fe..8a65f26 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,7 +8,7 @@ endif() project( lebai - VERSION 1.1.28 + VERSION 1.1.29 LANGUAGES CXX) list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") diff --git a/Doxyfile b/Doxyfile index d9f105f..616c277 100644 --- a/Doxyfile +++ b/Doxyfile @@ -38,7 +38,7 @@ PROJECT_NAME = "lebai sdk" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 1.1.28 +PROJECT_NUMBER = 1.1.29 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a diff --git a/doc/changelog.md b/doc/changelog.md index 4571559..9af8460 100644 --- a/doc/changelog.md +++ b/doc/changelog.md @@ -1,5 +1,8 @@ # ChangeLog +## 1.1.29 +修正move_pvat不能正常工作的问题。 + ## 1.1.28 修正c++安装包CMake Config的错误,添加使用文档。 diff --git a/doc/faq.md b/doc/faq.md index 43eb124..dc936a0 100644 --- a/doc/faq.md +++ b/doc/faq.md @@ -13,7 +13,7 @@ FAQ # 机械臂界面上坐标系统中,Rz、Ry、Rx是如何定义的。 -乐白机械臂界面的Rz,Rz,Rz表示机械臂姿态,是由EulerZYX确定的。 +乐白机械臂界面的Rx,Ry,Rz表示机械臂姿态,是由EulerZYX确定的。 界面显示的Rz,Ry,Rx为角度,将其转换为弧度后,它和旋转矩阵的关系如下: diff --git a/examples/example.cc b/examples/example.cc index 29195ae..7909c63 100755 --- a/examples/example.cc +++ b/examples/example.cc @@ -20,10 +20,8 @@ #include #include -int main(int argc, char **argv) -{ - if (argc < 2) - { +int main(int argc, char **argv) { + if (argc < 2) { std::cerr << "You must specify the IP address of the robot" << std::endl; std::cerr << "Execute example as follow:" << std::endl; std::cerr << "./example 192.168.1.200 sim" << std::endl; @@ -31,11 +29,9 @@ int main(int argc, char **argv) } std::string ip = argv[1]; bool sim = false; - if (argc > 2) - { + if (argc > 2) { std::string sim_str = argv[2]; - if (sim_str == "sim") - { + if (sim_str == "sim") { sim = true; } } @@ -44,23 +40,51 @@ int main(int argc, char **argv) // Create robot instance lebai::l_master::Robot robot(ip, sim); std::this_thread::sleep_for(std::chrono::seconds(1)); - robot.movej({13.0 / 180.0 * M_PI, -52.0 / 180.0 * M_PI, 86.0 / 180.0 * M_PI, 8.0 / 180.0 * M_PI, -59.0 / 180.0 * M_PI, -11.0 / 180.0 * M_PI}, 1.0, 0.5, 0.0, 0.0); - robot.movej({0.0 / 180.0 * M_PI, -52.0 / 180.0 * M_PI, 86.0 / 180.0 * M_PI, - 8.0 / 180.0 * M_PI, -59.0 / 180.0 * M_PI, -11.0 / 180.0 * M_PI}, - 1.0, 0.5, 0.0, 0.0); + robot.movej({0.0, 0.0, 0.0, 0.0, 0.0, 0.5}, 1.0, 0.5, 0.0, 0.0); + robot.movej({0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, 1.0, 0.5, 0.0, 0.0); + + // robot.movej({0.0 / 180.0 * M_PI, -52.0 / 180.0 * M_PI, 86.0 / 180.0 * M_PI, + // 8.0 / 180.0 * M_PI, -59.0 / 180.0 * M_PI, -11.0 / 180.0 * + // M_PI}, + // 1.0, 0.5, 0.0, 0.0); robot.wait_move(); - for (size_t i = 0; i < 30; ++i) - { - std::this_thread::sleep_for(std::chrono::seconds(1)); - try { - robot.get_robot_mode(); - } - catch(std::runtime_error & ex) - { - std::cout<<"get_robot_mode error: "< jp = {3.0/ 180.0 * M_PI, -48.0/ 180.0 * M_PI, 78.0/ 180.0 * M_PI, 9.0/ 180.0 * M_PI, -67.0/ 180.0 * M_PI, -3.0/ 180.0 * M_PI}; - // std::cout<<"jp "< jp = {3.0/ 180.0 * M_PI, -48.0/ 180.0 * + // M_PI, 78.0/ 180.0 * M_PI, 9.0/ 180.0 * M_PI, -67.0/ 180.0 * M_PI, -3.0/ + // 180.0 * M_PI}; std::cout<<"jp "<(resp) << ", " << std::get<1>(resp) - * << std::endl; + * std::cout << "resp: " << std::get<0>(resp) << ", " << std::get<1>(resp) << std::endl; * * * @brief 用JSON格式字符串调用机械臂的接口. @@ -121,6 +121,7 @@ class Robot { * 如果返回码为0,表示调用成功,第二个元素是JSONRPC的返回数据. * 如果返回码为非0,表示调用失败,第二个元素是错误信息. */ + // clang-format on std::tuple call(const std::string &method, const std::string ¶ms); diff --git a/sdk/src/protos/motion.cc b/sdk/src/protos/motion.cc index 969e475..7ade4cb 100644 --- a/sdk/src/protos/motion.cc +++ b/sdk/src/protos/motion.cc @@ -322,13 +322,13 @@ const double JointMove::acc() const { return acc_; } double* JointMove::mutable_acc() { return &acc_; } bool JointMove::Deserialize(const rapidjson::Value& obj) { if (obj.HasMember("pose")) { - pose_ = (double)(obj["pose"].GetDouble()); + pose_ = obj["pose"].GetDouble(); } if (obj.HasMember("velocity")) { - velocity_ = (double)(obj["velocity"].GetDouble()); + velocity_ = obj["velocity"].GetDouble(); } if (obj.HasMember("acc")) { - acc_ = (double)(obj["acc"].GetDouble()); + acc_ = obj["acc"].GetDouble(); } return true; } @@ -374,9 +374,10 @@ bool MovePvatRequest::Serialize( writer->StartObject(); writer->Key("duration"); writer->Double(duration_); + writer->Key("joints"); writer->StartArray(); for (auto j : joints_) { - writer->String(j.ToJSONString().c_str()); + j.Serialize(writer); } writer->EndArray(); writer->EndObject(); diff --git a/sdk/src/robot_impl.cc b/sdk/src/robot_impl.cc index 7ce9da4..6458fa1 100644 --- a/sdk/src/robot_impl.cc +++ b/sdk/src/robot_impl.cc @@ -141,21 +141,19 @@ motion::MotionIndex Robot::RobotImpl::speedLinear( std::string resp; auto req_string = req.ToJSONString(); - std::cout << "req " << req_string << "\n"; json_rpc_connector_->CallRpc("speed_linear", req_string, &resp); // json_rpc_connector_->CallRpc("speed_linear",req.ToJSONString(),&resp); motion::MotionIndex motion_resp; motion_resp.FromJSONString(resp); - std::cout << "resp " << resp << "\n"; return motion_resp; } void Robot::RobotImpl::movePvat(const motion::MovePvatRequest &req) { - json_rpc_connector_->CallRpc("move_pvat", req.ToJSONString(), nullptr); + std::string resp; + json_rpc_connector_->CallRpc("move_pvat", req.ToJSONString(), &resp); } void Robot::RobotImpl::waitMove(const motion::MotionIndex &req) { std::string resp; json_rpc_connector_->CallRpc("wait_move", req.ToJSONString(), &resp); - // std::cout<<"resp " << resp << std::endl; } motion::MotionIndex Robot::RobotImpl::getRunningMotion() { std::string resp; diff --git a/sdk/test/test_protos.cc b/sdk/test/test_protos.cc index ce6b0b3..d365e19 100644 --- a/sdk/test/test_protos.cc +++ b/sdk/test/test_protos.cc @@ -378,6 +378,24 @@ TEST_F(ProtosTest, TestMotion) { EXPECT_NEAR(0.3, *req_check.mutable_param()->mutable_velocity(), 1e-6); EXPECT_NEAR(0.5, *req_check.mutable_rad(), 1e-6); } + { + lebai::motion::JointMove joint_move; + joint_move.set_pose(0.1); + joint_move.set_velocity(0.2); + joint_move.set_acc(0.3); + auto json_str = joint_move.ToJSONString(); + // "{"pose":0.1,"velocity":0.2,"acc":0.3}" + EXPECT_EQ("{\"pose\":0.1,\"velocity\":0.2,\"acc\":0.3}", json_str); + lebai::motion::MovePvatRequest req; + req.set_duration(0.4); + req.set_joints({joint_move}); + json_str = req.ToJSONString(); + // {"duration":0.4,"joints":[{"pose":0.1,"velocity":0.2,"acc":0.3}]} + EXPECT_EQ( + "{\"duration\":0.4,\"joints\":[{\"pose\":0.1,\"velocity\":0.2,\"acc\":" + "0.3}]}", + json_str); + } } } // namespace lebai