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,210 @@
#ifndef __UT_ROBOT_GO2_CONFIG_API_HPP__
#define __UT_ROBOT_GO2_CONFIG_API_HPP__
#include <unitree/common/json/jsonize.hpp>
namespace unitree
{
namespace robot
{
namespace go2
{
/*
* service name
*/
const std::string CONFIG_SERVICE_NAME = "config";
/*
* api version
*/
const std::string CONFIG_API_VERSION = "1.0.0.1";
/*
* api id
*/
const int32_t CONFIG_API_ID_SET = 1001;
const int32_t CONFIG_API_ID_GET = 1002;
const int32_t CONFIG_API_ID_DEL = 1003;
const int32_t CONFIG_API_ID_META = 1004;
/*
* data type
*/
class JsonizeConfigMeta : public common::Jsonize
{
public:
JsonizeConfigMeta()
{}
~JsonizeConfigMeta()
{}
void fromJson(common::JsonMap& json)
{
common::FromJson(json["name"], name);
common::FromJson(json["lastModified"], lastModified);
common::FromJson(json["size"], size);
common::FromJson(json["epoch"], epoch);
}
void toJson(common::JsonMap& json) const
{
common::ToJson(name, json["name"]);
common::ToJson(lastModified, json["lastModified"]);
common::ToJson(size, json["size"]);
common::ToJson(epoch, json["epoch"]);
}
public:
std::string name;
std::string lastModified;
int32_t size;
int32_t epoch;
};
class ConfigSetParameter : public common::Jsonize
{
public:
ConfigSetParameter()
{}
~ConfigSetParameter()
{}
void fromJson(common::JsonMap& json)
{
common::FromJson(json["name"], name);
common::FromJson(json["content"], content);
}
void toJson(common::JsonMap& json) const
{
common::ToJson(name, json["name"]);
common::ToJson(content, json["content"]);
}
public:
std::string name;
std::string content;
};
class ConfigGetParameter : public common::Jsonize
{
public:
ConfigGetParameter()
{}
~ConfigGetParameter()
{}
void fromJson(common::JsonMap& json)
{
common::FromJson(json["name"], name);
}
void toJson(common::JsonMap& json) const
{
common::ToJson(name, json["name"]);
}
public:
std::string name;
};
class ConfigGetData : public common::Jsonize
{
public:
ConfigGetData()
{}
~ConfigGetData()
{}
void fromJson(common::JsonMap& json)
{
common::FromJson(json["content"], content);
}
void toJson(common::JsonMap& json) const
{
common::ToJson(content, json["content"]);
}
public:
std::string content;
};
class ConfigDelParameter : public common::Jsonize
{
public:
ConfigDelParameter()
{}
~ConfigDelParameter()
{}
void fromJson(common::JsonMap& json)
{
common::FromJson(json["name"], name);
}
void toJson(common::JsonMap& json) const
{
common::ToJson(name, json["name"]);
}
public:
std::string name;
};
class ConfigMetaParameter : public common::Jsonize
{
public:
ConfigMetaParameter()
{}
~ConfigMetaParameter()
{}
void fromJson(common::JsonMap& json)
{
common::FromJson(json["name"], name);
}
void toJson(common::JsonMap& json) const
{
common::ToJson(name, json["name"]);
}
public:
std::string name;
};
class ConfigMetaData : public common::Jsonize
{
public:
ConfigMetaData()
{}
~ConfigMetaData()
{}
void fromJson(common::JsonMap& json)
{
common::FromJson(json["meta"], meta);
}
void toJson(common::JsonMap& json) const
{
common::ToJson(meta, json["meta"]);
}
public:
JsonizeConfigMeta meta;
};
}
}
}
#endif//__UT_ROBOT_GO2_CONFIG_API_HPP__

View File

@@ -0,0 +1,68 @@
#ifndef __UT_ROBOT_GO2_CONFIG_CLIENT_HPP__
#define __UT_ROBOT_GO2_CONFIG_CLIENT_HPP__
#include <unitree/robot/client/client.hpp>
#include <unitree/robot/channel/channel_subscriber.hpp>
#include <unitree/idl/go2/ConfigChangeStatus_.hpp>
namespace unitree
{
namespace robot
{
namespace go2
{
/*
* @brief ConfigMeta
*/
class ConfigMeta
{
public:
ConfigMeta() : size(-1), epoch(-1)
{}
~ConfigMeta()
{}
public:
std::string name;
std::string lastModified;
int32_t size;
int32_t epoch;
};
/*
* @brief ConfigClient
*/
using ConfigChangeStatusCallback = std::function<void(const std::string&,const std::string&)>;
class ConfigClient : public Client
{
public:
explicit ConfigClient();
~ConfigClient();
void Init();
int32_t Set(const std::string& name, const std::string& content);
int32_t Get(const std::string& name, std::string& content);
int32_t Del(const std::string& name);
int32_t Meta(const std::string& name, ConfigMeta& meta);
int32_t Meta(const std::string& name, std::string& meta);
void SubscribeChangeStatus(const std::string& name, const ConfigChangeStatusCallback& callback);
private:
void ChangeStatusMessageHandler(const void* message);
private:
unitree::common::Mutex mLock;
std::map<std::string,ConfigChangeStatusCallback> mNameCallbackMap;
ChannelSubscriberPtr<unitree_go::msg::dds_::ConfigChangeStatus_> mSubscriberPtr;
};
}
}
}
#endif//__UT_ROBOT_GO2_CONFIG_CLIENT_HPP__

View File

@@ -0,0 +1,29 @@
#ifndef __UT_ROBOT_GO2_CONFIG_ERROR_HPP__
#define __UT_ROBOT_GO2_CONFIG_ERROR_HPP__
namespace unitree
{
namespace robot
{
namespace go2
{
UT_DECL_ERR(UT_CONFIG_ERR_PARAMETER, 8201, "parameter error.")
UT_DECL_ERR(UT_CONFIG_ERR_NOT_FOUND, 8202, "config name is not found.")
UT_DECL_ERR(UT_CONFIG_ERR_NAME, 8203, "name is invalid.")
UT_DECL_ERR(UT_CONFIG_ERR_LIMITED, 8204, "name/content length limited.")
UT_DECL_ERR(UT_CONFIG_ERR_LOCK, 8205, "lock error.")
UT_DECL_ERR(UT_CONFIG_ERR_LOAD_META, 8206, "load meta error.")
UT_DECL_ERR(UT_CONFIG_ERR_SAVE_META, 8207, "save meta error.")
UT_DECL_ERR(UT_CONFIG_ERR_TEMP_META, 8208, "save meta temp error.")
UT_DECL_ERR(UT_CONFIG_ERR_FORMAL_META, 8209, "formalize meta error.")
UT_DECL_ERR(UT_CONFIG_ERR_REMOVE_META, 8210, "remove meta error.")
UT_DECL_ERR(UT_CONFIG_ERR_LOAD_DATA, 8211, "load data error.")
UT_DECL_ERR(UT_CONFIG_ERR_SAVE_DATA, 8212, "save data error.")
UT_DECL_ERR(UT_CONFIG_ERR_TEMP_DATA, 8213, "save data temp error.")
UT_DECL_ERR(UT_CONFIG_ERR_FORMAL_DATA, 8214, "formalize data error.")
UT_DECL_ERR(UT_CONFIG_ERR_REMOVE_DATA, 8215, "remove data error.")
}
}
}
#endif//__UT_ROBOT_GO2_CONFIG_ERROR_HPP__

View File

@@ -0,0 +1,104 @@
#ifndef __UT_ROBOT_GO2_OBSTACLES_AVOID_API_HPP__
#define __UT_ROBOT_GO2_OBSTACLES_AVOID_API_HPP__
#include <unitree/common/json/jsonize.hpp>
namespace unitree
{
namespace robot
{
namespace go2
{
const std::string ROBOT_OBSTACLES_AVOID_SERVICE_NAME = "obstacles_avoid";
const std::string ROBOT_OBSTACLES_AVOID_API_VERSION = "1.0.0.2";
const int32_t ROBOT_API_ID_OBSTACLES_AVOID_SWITCH_SET = 1001;
const int32_t ROBOT_API_ID_OBSTACLES_AVOID_SWITCH_GET = 1002;
const int32_t ROBOT_API_ID_OBSTACLES_AVOID_MOVE = 1003;
const int32_t ROBOT_API_ID_OBSTACLES_AVOID_USE_REMOTE_COMMAND_FROM_API = 1004;
class ObstaclesAvoidSwitchSetParameter : public common::Jsonize
{
public:
void fromJson(common::JsonMap& json)
{
common::FromJson(json["enable"], mEnable);
}
void toJson(common::JsonMap& json) const
{
common::ToJson(mEnable, json["enable"]);
}
bool mEnable = true;
};
class ObstaclesAvoidSwitchGetData : public common::Jsonize
{
public:
void fromJson(common::JsonMap& json)
{
common::FromJson(json["enable"], mEnable);
}
void toJson(common::JsonMap& json) const
{
common::ToJson(mEnable, json["enable"]);
}
bool mEnable = true;
};
class ObstaclesAvoidMoveParameter : public common::Jsonize
{
public:
void fromJson(common::JsonMap& json)
{
common::FromJson(json["x"], mX);
common::FromJson(json["y"], mY);
common::FromJson(json["yaw"], mYaw);
common::FromJson(json["mode"], mMode);
}
void toJson(common::JsonMap& json) const
{
common::ToJson(mX, json["x"]);
common::ToJson(mY, json["y"]);
common::ToJson(mYaw, json["yaw"]);
common::ToJson(mMode, json["mode"]);
}
float mX = 0.0;
float mY = 0.0;
float mYaw = 0.0;
/*
* mode:
* 0 for vel
* 1 for increment pose
* 2 for absolute pose
*/
int mMode = 0;
};
class ObstaclesAvoidRemoteCommandSource : public common::Jsonize
{
public:
void fromJson(common::JsonMap& json)
{
common::FromJson(json["is_remote_commands_from_api"], mIsRemoteCommandsFromApi);
}
void toJson(common::JsonMap& json) const
{
common::ToJson(mIsRemoteCommandsFromApi, json["is_remote_commands_from_api"]);
}
bool mIsRemoteCommandsFromApi = true;
};
}
}
}
#endif//__UT_ROBOT_GO2_OBSTACLES_AVOID_API_HPP__

View File

@@ -0,0 +1,33 @@
#ifndef __UT_ROBOT_GO2_OBSTACLES_AVOID_CLIENT_HPP__
#define __UT_ROBOT_GO2_OBSTACLES_AVOID_CLIENT_HPP__
#include <unitree/robot/client/client.hpp>
namespace unitree
{
namespace robot
{
namespace go2
{
class ObstaclesAvoidClient : public Client
{
public:
ObstaclesAvoidClient();
~ObstaclesAvoidClient();
void Init();
int32_t SwitchSet(bool enable);
int32_t SwitchGet(bool& enable);
int32_t Move(float x, float y, float yaw);
int32_t UseRemoteCommandFromApi(bool isRemoteCommandsFromApi);
int32_t MoveToAbsolutePosition(float x, float y, float yaw);
int32_t MoveToIncrementPosition(float x, float y, float yaw);
};
}
}
}
#endif//__UT_ROBOT_GO2_OBSTACLES_AVOID_CLIENT_HPP__

View File

@@ -0,0 +1,311 @@
#ifndef __UT_ROBOT_GO2_SDK_JSON_DATA_TYPE_HPP__
#define __UT_ROBOT_GO2_SDK_JSON_DATA_TYPE_HPP__
#include <unitree/common/json/jsonize.hpp>
namespace unitree
{
namespace robot
{
namespace go2
{
/*
* @brief Jonsize for simple flag type bool
*/
class JsonizeFlagBool : public common::Jsonize
{
public:
JsonizeFlagBool() : flag(false)
{}
~JsonizeFlagBool()
{}
void fromJson(common::JsonMap& json)
{
common::FromJson(json["flag"], flag);
}
void toJson(common::JsonMap& json) const
{
common::ToJson(flag, json["flag"]);
}
public:
bool flag;
};
/*
* @brief Jonsize for simple data type bool
*/
class JsonizeDataBool : public common::Jsonize
{
public:
JsonizeDataBool() : data(false)
{}
~JsonizeDataBool()
{}
void fromJson(common::JsonMap& json)
{
common::FromJson(json["data"], data);
}
void toJson(common::JsonMap& json) const
{
common::ToJson(data, json["data"]);
}
public:
bool data;
};
/*
* @brief Jonsize for simple data type int
*/
class JsonizeDataInt : public common::Jsonize
{
public:
JsonizeDataInt() : data(0)
{}
~JsonizeDataInt()
{}
void fromJson(common::JsonMap& json)
{
common::FromJson(json["data"], data);
}
void toJson(common::JsonMap& json) const
{
common::ToJson(data, json["data"]);
}
public:
int data;
};
/*
* @brief Jonsize for simple data type float
*/
class JsonizeDataFloat : public common::Jsonize
{
public:
JsonizeDataFloat() : data(0.0F)
{}
~JsonizeDataFloat()
{}
void fromJson(common::JsonMap& json)
{
common::FromJson(json["data"], data);
}
void toJson(common::JsonMap& json) const
{
common::ToJson(data, json["data"]);
}
public:
float data;
};
/*
* @brief Jonsize for simple data type double
*/
class JsonizeDataDouble : public common::Jsonize
{
public:
JsonizeDataDouble() : data(0.0F)
{}
~JsonizeDataDouble()
{}
void fromJson(common::JsonMap& json)
{
common::FromJson(json["data"], data);
}
void toJson(common::JsonMap& json) const
{
common::ToJson(data, json["data"]);
}
public:
double data;
};
/*
* @brief Jonsize for simple data type string
*/
class JsonizeDataString : public common::Jsonize
{
public:
JsonizeDataString()
{}
~JsonizeDataString()
{}
void fromJson(common::JsonMap& json)
{
common::FromJson(json["data"], data);
}
void toJson(common::JsonMap& json) const
{
common::ToJson(data, json["data"]);
}
public:
std::string data;
};
/*
* @brief Jonsize for data type vec3
*/
class JsonizeVec3 : public common::Jsonize
{
public:
JsonizeVec3() : x(0.0F), y(0.0F), z(0.0F)
{}
~JsonizeVec3()
{}
void fromJson(common::JsonMap& json)
{
common::FromJson(json["x"], x);
common::FromJson(json["y"], y);
common::FromJson(json["z"], z);
}
void toJson(common::JsonMap& json) const
{
common::ToJson(x, json["x"]);
common::ToJson(y, json["y"]);
common::ToJson(z, json["z"]);
}
public:
float x;
float y;
float z;
};
/*
* @brief Jonsize for data type quaternion
*/
class JsonizeQuat : public common::Jsonize
{
public:
JsonizeQuat() : x(0.0F), y(0.0F), z(0.0F), w(0.0F)
{}
~JsonizeQuat()
{}
void fromJson(common::JsonMap& json)
{
common::FromJson(json["x"], x);
common::FromJson(json["y"], y);
common::FromJson(json["z"], z);
common::FromJson(json["w"], w);
}
void toJson(common::JsonMap& json) const
{
common::ToJson(x, json["x"]);
common::ToJson(y, json["y"]);
common::ToJson(z, json["z"]);
common::ToJson(w, json["w"]);
}
public:
float x;
float y;
float z;
float w;
};
/*
* Jsonize class for PathPoint
*/
class JsonizePathPoint : public common::Jsonize
{
public:
JsonizePathPoint() :
timeFromStart(0.0F), x(0.0F), y(0.0F), yaw(0.0F), vx(0.0F), vy(0.0F), vyaw(0.0F)
{}
~JsonizePathPoint()
{}
public:
void fromJson(common::JsonMap& json)
{
common::FromJson(json["t_from_start"], timeFromStart);
common::FromJson(json["x"], x);
common::FromJson(json["y"], y);
common::FromJson(json["yaw"], yaw);
common::FromJson(json["vx"], vx);
common::FromJson(json["vy"], vy);
common::FromJson(json["vyaw"], vyaw);
}
void toJson(common::JsonMap& json) const
{
common::ToJson(timeFromStart, json["t_from_start"]);
common::ToJson(x, json["x"]);
common::ToJson(y, json["y"]);
common::ToJson(yaw, json["yaw"]);
common::ToJson(vx, json["vx"]);
common::ToJson(vy, json["vy"]);
common::ToJson(vyaw, json["vyaw"]);
}
public:
float timeFromStart;
float x;
float y;
float yaw;
float vx;
float vy;
float vyaw;
};
/*
* @brief Jonsize for simple common object type int
*/
class JsonizeCommObjInt : public common::Jsonize
{
public:
JsonizeCommObjInt() : value(0)
{}
~JsonizeCommObjInt()
{}
void fromJson(common::JsonMap& json)
{
common::FromJson(json[name], value);
}
void toJson(common::JsonMap& json) const
{
common::ToJson(value, json[name]);
}
public:
int value;
std::string name;
};
}
}
}
#endif//__UT_ROBOT_GO2_SDK_JSON_DATA_TYPE_HPP__

View File

@@ -0,0 +1,152 @@
#ifndef __UT_ROBOT_GO2_ROBOT_STATE_API_HPP__
#define __UT_ROBOT_GO2_ROBOT_STATE_API_HPP__
#include <unitree/common/json/jsonize.hpp>
namespace unitree
{
namespace robot
{
namespace go2
{
/*
* service name
*/
const std::string ROBOT_STATE_SERVICE_NAME = "robot_state";
/*
* api version
*/
const std::string ROBOT_STATE_API_VERSION = "1.0.0.1";
/*
* api id
*/
const int32_t ROBOT_STATE_API_ID_SERVICE_SWITCH = 1001;
const int32_t ROBOT_STATE_API_ID_SET_REPORT_FREQ = 1002;
const int32_t ROBOT_STATE_API_ID_SERVICE_LIST = 1003;
/*
* request parameter for 1001
*/
class ServiceSwitchParameter : public common::Jsonize
{
public:
ServiceSwitchParameter() : swit(0)
{}
~ServiceSwitchParameter()
{}
void fromJson(common::JsonMap& json)
{
common::FromJson(json["name"], name);
common::FromJson(json["switch"], swit);
}
void toJson(common::JsonMap& json) const
{
common::ToJson(name, json["name"]);
common::ToJson(swit, json["switch"]);
}
public:
std::string name;
int32_t swit;
};
/*
* response data for 1001
*/
class ServiceSwitchData : public common::Jsonize
{
public:
ServiceSwitchData() : status(0)
{}
~ServiceSwitchData()
{}
void fromJson(common::JsonMap& json)
{
common::FromJson(json["name"], name);
common::FromJson(json["status"], status);
}
void toJson(common::JsonMap& json) const
{
common::ToJson(name, json["name"]);
common::ToJson(status, json["status"]);
}
public:
std::string name;
int32_t status;
};
/*
* request parameter for 1002
*/
class SetReportFreqParameter : public common::Jsonize
{
public:
SetReportFreqParameter()
{}
~SetReportFreqParameter()
{}
void fromJson(common::JsonMap& json)
{
common::FromJson(json["interval"], interval);
common::FromJson(json["duration"], duration);
}
void toJson(common::JsonMap& json) const
{
common::ToJson(interval, json["interval"]);
common::ToJson(duration, json["duration"]);
}
public:
int32_t interval;
int32_t duration;
};
/*
* request data for 1003
*/
class ServiceStateData : public common::Jsonize
{
public:
ServiceStateData()
{}
~ServiceStateData()
{}
void fromJson(common::JsonMap& json)
{
common::FromJson(json["name"], name);
common::FromJson(json["status"], status);
common::FromJson(json["protect"], protect);
}
void toJson(common::JsonMap& json) const
{
common::ToJson(name, json["name"]);
common::ToJson(status, json["status"]);
common::ToJson(protect, json["protect"]);
}
public:
std::string name;
int32_t status;
int32_t protect;
};
}
}
}
#endif//__UT_ROBOT_GO2_ROBOT_STATE_API_HPP__

View File

@@ -0,0 +1,47 @@
#ifndef __UT_ROBOT_GO2_ROBOT_STATE_CLIENT_HPP__
#define __UT_ROBOT_GO2_ROBOT_STATE_CLIENT_HPP__
#include <unitree/robot/client/client.hpp>
namespace unitree
{
namespace robot
{
namespace go2
{
/*
* @brief ServiceState
*/
class ServiceState
{
public:
ServiceState() : status(0), protect(0)
{}
std::string name;
int32_t status;
int32_t protect;
};
/*
* @brief RobotStateClient
*/
class RobotStateClient : public Client
{
public:
explicit RobotStateClient();
~RobotStateClient();
void Init();
int32_t ServiceList(std::vector<ServiceState>& serviceStateList);
int32_t ServiceSwitch(const std::string& name, int32_t swit, int32_t& status);
int32_t SetReportFreq(int32_t interval, int32_t duration);
};
}
}
}
#endif//__UT_ROBOT_GO2_ROBOT_STATE_CLIENT_HPP__

View File

@@ -0,0 +1,18 @@
#ifndef __UT_ROBOT_GO2_ROBOT_STATE_CLIENT_ERROR_HPP__
#define __UT_ROBOT_GO2_ROBOT_STATE_CLIENT_ERROR_HPP__
#include <unitree/common/decl.hpp>
namespace unitree
{
namespace robot
{
namespace go2
{
UT_DECL_ERR(UT_ROBOT_STATE_CLIENT_ERR_SERVICE_SWITCH, 5201, "service switch error.")
UT_DECL_ERR(UT_ROBOT_STATE_CLIENT_ERR_SERVICE_PROTECTED, 5202, "service is protected.")
}
}
}
#endif//__UT_ROBOT_GO2_ROBOT_STATE_CLIENT_ERROR_HPP__

View File

@@ -0,0 +1,64 @@
#ifndef __UT_ROBOT_GO2_SPORT_API_HPP__
#define __UT_ROBOT_GO2_SPORT_API_HPP__
#include <unitree/common/json/jsonize.hpp>
namespace unitree
{
namespace robot
{
namespace go2
{
/*service name*/
const std::string ROBOT_SPORT_SERVICE_NAME = "sport";
/*api version*/
const std::string ROBOT_SPORT_API_VERSION = "1.0.0.1";
/*api id*/
const int32_t ROBOT_SPORT_API_ID_DAMP = 1001;
const int32_t ROBOT_SPORT_API_ID_BALANCESTAND = 1002;
const int32_t ROBOT_SPORT_API_ID_STOPMOVE = 1003;
const int32_t ROBOT_SPORT_API_ID_STANDUP = 1004;
const int32_t ROBOT_SPORT_API_ID_STANDDOWN = 1005;
const int32_t ROBOT_SPORT_API_ID_RECOVERYSTAND = 1006;
const int32_t ROBOT_SPORT_API_ID_EULER = 1007;
const int32_t ROBOT_SPORT_API_ID_MOVE = 1008;
const int32_t ROBOT_SPORT_API_ID_SIT = 1009;
const int32_t ROBOT_SPORT_API_ID_RISESIT = 1010;
const int32_t ROBOT_SPORT_API_ID_SPEEDLEVEL = 1015;
const int32_t ROBOT_SPORT_API_ID_HELLO = 1016;
const int32_t ROBOT_SPORT_API_ID_STRETCH = 1017;
const int32_t ROBOT_SPORT_API_ID_CONTENT = 1020;
const int32_t ROBOT_SPORT_API_ID_DANCE1 = 1022;
const int32_t ROBOT_SPORT_API_ID_DANCE2 = 1023;
const int32_t ROBOT_SPORT_API_ID_SWITCHJOYSTICK = 1027;
const int32_t ROBOT_SPORT_API_ID_POSE = 1028;
const int32_t ROBOT_SPORT_API_ID_SCRAPE = 1029;
const int32_t ROBOT_SPORT_API_ID_FRONTFLIP = 1030;
const int32_t ROBOT_SPORT_API_ID_FRONTJUMP = 1031;
const int32_t ROBOT_SPORT_API_ID_FRONTPOUNCE = 1032;
const int32_t ROBOT_SPORT_API_ID_HEART = 1036;
const int32_t ROBOT_SPORT_API_ID_STATICWALK = 1061;
const int32_t ROBOT_SPORT_API_ID_TROTRUN = 1062;
const int32_t ROBOT_SPORT_API_ID_ECONOMICGAIT = 1063;
const int32_t ROBOT_SPORT_API_ID_LEFTFLIP = 2041;
const int32_t ROBOT_SPORT_API_ID_BACKFLIP = 2043;
const int32_t ROBOT_SPORT_API_ID_HANDSTAND = 2044;
const int32_t ROBOT_SPORT_API_ID_FREEWALK = 2045;
const int32_t ROBOT_SPORT_API_ID_FREEBOUND = 2046;
const int32_t ROBOT_SPORT_API_ID_FREEJUMP = 2047;
const int32_t ROBOT_SPORT_API_ID_FREEAVOID = 2048;
const int32_t ROBOT_SPORT_API_ID_CLASSICWALK = 2049;
const int32_t ROBOT_SPORT_API_ID_WALKUPRIGHT = 2050;
const int32_t ROBOT_SPORT_API_ID_CROSSSTEP = 2051;
const int32_t ROBOT_SPORT_API_ID_AUTORECOVERY_SET = 2054;
const int32_t ROBOT_SPORT_API_ID_AUTORECOVERY_GET = 2055;
const int32_t ROBOT_SPORT_API_ID_SWITCHAVOIDMODE = 2058;
}
}
}
#endif //__UT_ROBOT_GO2_SPORT_API_HPP__

View File

@@ -0,0 +1,86 @@
#ifndef __UT_ROBOT_GO2_SPORT_CLIENT_HPP__
#define __UT_ROBOT_GO2_SPORT_CLIENT_HPP__
#include <unitree/robot/client/client.hpp>
namespace unitree
{
namespace robot
{
namespace go2
{
/*
* PathPoint
*/
struct stPathPoint
{
float timeFromStart;
float x;
float y;
float yaw;
float vx;
float vy;
float vyaw;
};
typedef struct stPathPoint PathPoint;
/*
* SportClient
*/
class SportClient : public Client
{
public:
explicit SportClient(bool enableLease = false);
~SportClient();
void Init();
int32_t Damp();
int32_t BalanceStand();
int32_t StopMove();
int32_t StandUp();
int32_t StandDown();
int32_t RecoveryStand();
int32_t Euler(float roll, float pitch, float yaw);
int32_t Move(float vx, float vy, float vyaw);
int32_t Sit();
int32_t RiseSit();
int32_t SpeedLevel(int level);
int32_t Hello();
int32_t Stretch();
int32_t SwitchJoystick(bool flag);
int32_t Content();
int32_t Heart();
int32_t Pose(bool flag);
int32_t Scrape();
int32_t FrontFlip();
int32_t FrontJump();
int32_t FrontPounce();
int32_t Dance1();
int32_t Dance2();
int32_t LeftFlip();
int32_t BackFlip();
int32_t HandStand(bool flag);
int32_t FreeWalk();
int32_t FreeBound(bool flag);
int32_t FreeJump(bool flag);
int32_t FreeAvoid(bool flag);
int32_t ClassicWalk(bool flag);
int32_t WalkUpright(bool flag);
int32_t CrossStep(bool flag);
int32_t AutoRecoverSet(bool flag);
int32_t AutoRecoverGet(bool& flag);
int32_t StaticWalk();
int32_t TrotRun();
int32_t EconomicGait();
int32_t SwitchAvoidMode();
};
}
}
}
#endif//__UT_ROBOT_GO2_SPORT_CLIENT_HPP__

View File

@@ -0,0 +1,19 @@
#ifndef __UT_ROBOT_GO2_SPORT_ERROR_HPP__
#define __UT_ROBOT_GO2_SPORT_ERROR_HPP__
#include <unitree/common/decl.hpp>
namespace unitree
{
namespace robot
{
namespace go2
{
UT_DECL_ERR(UT_ROBOT_SPORT_ERR_CLIENT_POINT_PATH, 4101, "point path error.")
UT_DECL_ERR(UT_ROBOT_SPORT_ERR_SERVER_OVERTIME, 4201, "server overtime.")
UT_DECL_ERR(UT_ROBOT_SPORT_ERR_SERVER_NOT_INIT, 4205, "server function not init.")
}
}
}
#endif//__UT_ROBOT_GO2_SPORT_ERROR_HPP__

View File

@@ -0,0 +1,55 @@
#ifndef __UT_ROBOT_GO2_UTRACK_API_HPP__
#define __UT_ROBOT_GO2_UTRACK_API_HPP__
#include <unitree/common/json/jsonize.hpp>
namespace unitree
{
namespace robot
{
namespace go2
{
const std::string ROBOT_UTRACK_SERVICE_NAME = "uwbswitch";
const std::string ROBOT_UTRACK_API_VERSION = "1.0.0.1";
const int32_t ROBOT_API_ID_UTRACK_SWITCH_SET = 1001;
const int32_t ROBOT_API_ID_UTRACK_SWITCH_GET = 1002;
const int32_t ROBOT_API_ID_UTRACK_IS_TRACKING = 1003;
class UtrackSwitchSetParameter : public common::Jsonize
{
public:
void fromJson(common::JsonMap& json)
{
common::FromJson(json["enable"], mEnable);
}
void toJson(common::JsonMap& json) const
{
common::ToJson(mEnable, json["enable"]);
}
int32_t mEnable = true;
};
class UtrackSwitchGetData : public common::Jsonize
{
public:
void fromJson(common::JsonMap& json)
{
common::FromJson(json["enable"], mEnable);
}
void toJson(common::JsonMap& json) const
{
common::ToJson(mEnable, json["enable"]);
}
int32_t mEnable = true;
};
}
}
}
#endif//__UT_ROBOT_GO2_UTRACK_API_HPP__

View File

@@ -0,0 +1,28 @@
#ifndef __UT_ROBOT_GO2_UTRACK_CLIENT_HPP__
#define __UT_ROBOT_GO2_UTRACK_CLIENT_HPP__
#include <unitree/robot/client/client.hpp>
namespace unitree
{
namespace robot
{
namespace go2
{
class UtrackClient : public Client
{
public:
UtrackClient();
~UtrackClient();
void Init();
int32_t SwitchSet(bool enable);
int32_t SwitchGet(bool& enable);
int32_t IsTracking(bool& enable);
};
}
}
}
#endif//__UT_ROBOT_GO2_UTRACK_CLIENT_HPP__

View File

@@ -0,0 +1,24 @@
#ifndef __UT_ROBOT_GO2_VIDEO_API_HPP__
#define __UT_ROBOT_GO2_VIDEO_API_HPP__
#include <unitree/common/json/jsonize.hpp>
namespace unitree
{
namespace robot
{
namespace go2
{
/*service name*/
const std::string ROBOT_VIDEO_SERVICE_NAME = "videohub";
/*api version*/
const std::string ROBOT_VIDEO_API_VERSION = "1.0.0.0";
/*api id*/
const int32_t ROBOT_VIDEO_API_ID_GETIMAGESAMPLE = 1001;
}
}
}
#endif //__UT_ROBOT_GO2_VIDEO_API_HPP__

View File

@@ -0,0 +1,34 @@
#ifndef __UT_ROBOT_GO2_VIDEO_CLIENT_HPP__
#define __UT_ROBOT_GO2_VIDEO_CLIENT_HPP__
#include <unitree/robot/client/client.hpp>
namespace unitree
{
namespace robot
{
namespace go2
{
/*
* VideoClient
*/
class VideoClient : public Client
{
public:
explicit VideoClient();
~VideoClient();
void Init();
/*
* @brief GetImageSample
* @api: 1001
*/
int32_t GetImageSample(std::vector<uint8_t>&);
};
}
}
}
#endif//__UT_ROBOT_GO2_VIDEO_CLIENT_HPP__

View File

@@ -0,0 +1,17 @@
#ifndef __UT_ROBOT_GO2_VIDEO_ERROR_HPP__
#define __UT_ROBOT_GO2_VIDEO_ERROR_HPP__
#include <unitree/common/decl.hpp>
namespace unitree
{
namespace robot
{
namespace go2
{
UT_DECL_ERR(UT_ROBOT_VIDEO_ERR_COMM, 100, "Invalid parameter")
}
}
}
#endif//__UT_ROBOT_GO2_VIDEO_ERROR_HPP__

View File

@@ -0,0 +1,29 @@
#ifndef __UT_ROBOT_GO2_VUI_API_HPP__
#define __UT_ROBOT_GO2_VUI_API_HPP__
#include <unitree/common/json/jsonize.hpp>
namespace unitree
{
namespace robot
{
namespace go2
{
/*service name*/
const std::string ROBOT_VUI_SERVICE_NAME = "vui";
/*api version*/
const std::string ROBOT_VUI_API_VERSION = "1.0.0.0";
/*api id*/
const int32_t ROBOT_VUI_API_ID_SETSWITCH = 1001;
const int32_t ROBOT_VUI_API_ID_GETSWITCH = 1002;
const int32_t ROBOT_VUI_API_ID_SETVOLUME = 1003;
const int32_t ROBOT_VUI_API_ID_GETVOLUME = 1004;
const int32_t ROBOT_VUI_API_ID_SETBRIGHTNESS = 1005;
const int32_t ROBOT_VUI_API_ID_GETBRIGHTNESS = 1006;
}
}
}
#endif //__UT_ROBOT_GO2_VUI_API_HPP__

View File

@@ -0,0 +1,64 @@
#ifndef __UT_ROBOT_GO2_VUI_CLIENT_HPP__
#define __UT_ROBOT_GO2_VUI_CLIENT_HPP__
#include <unitree/robot/client/client.hpp>
namespace unitree
{
namespace robot
{
namespace go2
{
/*
* VuiClient
*/
class VuiClient : public Client
{
public:
explicit VuiClient();
~VuiClient();
void Init();
/*
* @brief SetSwitch
* @api: 1001
*/
int32_t SetSwitch(int enable);
/*
* @brief GetSwitch
* @api: 1002
*/
int32_t GetSwitch(int&);
/*
* @brief SetVolume
* @api: 1003
*/
int32_t SetVolume(int level);
/*
* @brief GetVolume
* @api: 1004
*/
int32_t GetVolume(int&);
/*
* @brief SetBrightness
* @api: 1005
*/
int32_t SetBrightness(int level);
/*
* @brief GetBrightness
* @api: 1006
*/
int32_t GetBrightness(int&);
};
}
}
}
#endif//__UT_ROBOT_GO2_VUI_CLIENT_HPP__

View File

@@ -0,0 +1,17 @@
#ifndef __UT_ROBOT_GO2_VUI_ERROR_HPP__
#define __UT_ROBOT_GO2_VUI_ERROR_HPP__
#include <unitree/common/decl.hpp>
namespace unitree
{
namespace robot
{
namespace go2
{
UT_DECL_ERR(UT_ROBOT_VUI_ERR_COMM, 100, "Invalid parameter")
}
}
}
#endif//__UT_ROBOT_GO2_VUI_ERROR_HPP__