This commit is contained in:
2025-09-24 10:53:28 +08:00
commit f8e4df77fb
856 changed files with 140098 additions and 0 deletions

View File

@@ -0,0 +1,99 @@
#ifndef __UT_ROBOT_B2_MOTION_SWITCHER_API_HPP__
#define __UT_ROBOT_B2_MOTION_SWITCHER_API_HPP__
#include <unitree/common/json/jsonize.hpp>
namespace unitree
{
namespace robot
{
namespace b2
{
/*
* service name
*/
const std::string MOTION_SWITCHER_SERVICE_NAME = "motion_switcher";
/*
* api version
*/
const std::string MOTION_SWITCHER_API_VERSION = "1.0.0.1";
/*
* api id
*/
const int32_t MOTION_SWITCHER_API_ID_CHECK_MODE = 1001;
const int32_t MOTION_SWITCHER_API_ID_SELECT_MODE = 1002;
const int32_t MOTION_SWITCHER_API_ID_RELEASE_MODE = 1003;
const int32_t MOTION_SWITCHER_API_ID_SET_SILENT = 1004;
const int32_t MOTION_SWITCHER_API_ID_GET_SILENT = 1005;
/*
* api data type
*/
class JsonizeModeName : public common::Jsonize
{
public:
JsonizeModeName()
{}
~JsonizeModeName()
{}
/*override*/
void fromJson(common::JsonMap& json)
{
common::FromJson(json["name"], name);
if (json.find("form") != json.end())
{
common::FromJson(json["form"], form);
}
}
/*override*/
void toJson(common::JsonMap& json) const
{
common::ToJson(name, json["name"]);
if (!form.empty())
{
common::ToJson(form, json["form"]);
}
}
public:
std::string name;
std::string form;
};
class JsonizeSilent : public common::Jsonize
{
public:
JsonizeSilent() : silent(false)
{}
~JsonizeSilent()
{}
/*override*/
void fromJson(common::JsonMap& json)
{
common::FromJson(json["silent"], silent);
}
/*override*/
void toJson(common::JsonMap& json) const
{
common::ToJson(silent, json["silent"]);
}
public:
bool silent;
};
}
}
}
#endif//__UT_ROBOT_B2_MOTION_SWITCHER_API_HPP__

View File

@@ -0,0 +1,35 @@
#ifndef __UT_ROBOT_B2_MOTION_SWITCHER_CLIENT_HPP__
#define __UT_ROBOT_B2_MOTION_SWITCHER_CLIENT_HPP__
#include <unitree/robot/client/client.hpp>
namespace unitree
{
namespace robot
{
namespace b2
{
/*
* @brief MotionSwitcherClient
*/
class MotionSwitcherClient : public Client
{
public:
explicit MotionSwitcherClient();
~MotionSwitcherClient();
void Init();
int32_t CheckMode(std::string& form, std::string& name);
int32_t SelectMode(const std::string& nameOrAlias);
int32_t ReleaseMode();
int32_t SetSilent(bool silent);
int32_t GetSilent(bool& silent);
};
}
}
}
#endif//__UT_ROBOT_B2_MOTION_SWITCHER_CLIENT_HPP__

View File

@@ -0,0 +1,25 @@
#ifndef __UT_ROBOT_B2_MOTION_SWITCHER_ERROR_HPP__
#define __UT_ROBOT_B2_MOTION_SWITCHER_ERROR_HPP__
#include <unitree/common/decl.hpp>
namespace unitree
{
namespace robot
{
namespace b2
{
UT_DECL_ERR(UT_SWITCH_ERR_PARAMETR, 7001, "parameter is invalid.")
UT_DECL_ERR(UT_SWITCH_ERR_BUSY, 7002, "switcher is busy.")
UT_DECL_ERR(UT_SWITCH_ERR_EVENT, 7003, "event is invalid.")
UT_DECL_ERR(UT_SWITCH_ERR_NAME, 7004, "name or alias is invalid.")
UT_DECL_ERR(UT_SWITCH_ERR_CMD, 7005, "name or alias is invalid.")
UT_DECL_ERR(UT_SWITCH_ERR_EXEC_CHECK, 7006, "check cmd execute error.")
UT_DECL_ERR(UT_SWITCH_ERR_EXEC_SELECT, 7007, "select cmd execute error.")
UT_DECL_ERR(UT_SWITCH_ERR_EXEC_RELEASE, 7008, "release cmd execute error.")
UT_DECL_ERR(UT_SWITCH_ERR_CUSTOMIZE, 7009, "save customize data error.")
}
}
}
#endif//__UT_ROBOT_B2_MOTION_SWITCHER_ERROR_HPP__