add all TODO-devel-go2

This commit is contained in:
fan-ziqi 2024-10-12 22:20:11 +08:00
parent a421711610
commit 11ec554365
6 changed files with 9 additions and 9 deletions

View File

@ -16,6 +16,6 @@ Guidelines for modifications:
## Contributors ## Contributors
TODO add your name TODO-devel-go2 add your name
## Acknowledgements ## Acknowledgements

View File

@ -128,7 +128,7 @@ Or press **0** on the keyboard to switch the robot to the default standing posit
#### Unitree Go2 #### Unitree Go2
TODO 添加go2的使用说明 TODO-devel-go2 添加go2的使用说明
Open a new terminal and start the control program Open a new terminal and start the control program

View File

@ -129,7 +129,7 @@ rosrun rl_sar rl_real_a1
#### Unitree Go2 #### Unitree Go2
TODO 添加go2的使用说明 TODO-devel-go2 添加go2的使用说明
新建终端,启动控制程序 新建终端,启动控制程序

View File

@ -4,14 +4,14 @@
#include "rl_sdk.hpp" #include "rl_sdk.hpp"
#include "observation_buffer.hpp" #include "observation_buffer.hpp"
#include "loop.hpp" #include "loop.hpp"
#include <unitree/robot/channel/channel_publisher.hpp> // TODO go2的sdk没有传上来 #include <unitree/robot/channel/channel_publisher.hpp> // TODO-devel-go2 go2的sdk没有传上来
#include <unitree/robot/channel/channel_subscriber.hpp> #include <unitree/robot/channel/channel_subscriber.hpp>
#include <unitree/idl/go2/LowState_.hpp> #include <unitree/idl/go2/LowState_.hpp>
#include <unitree/idl/go2/LowCmd_.hpp> #include <unitree/idl/go2/LowCmd_.hpp>
#include <unitree/common/time/time_tool.hpp> #include <unitree/common/time/time_tool.hpp>
#include <unitree/common/thread/thread.hpp> #include <unitree/common/thread/thread.hpp>
#include <unitree/robot/go2/robot_state/robot_state_client.hpp> #include <unitree/robot/go2/robot_state/robot_state_client.hpp>
#include "unitree_joystick.h" // TODO 这里调用的是a1的go2有自己的键盘接口吗 #include "unitree_joystick.h" // TODO-devel-go2 这里调用的是a1的go2有自己的键盘接口吗
#include <csignal> #include <csignal>
#include "matplotlibcpp.h" #include "matplotlibcpp.h"

View File

@ -29,7 +29,7 @@ void RL_Real::RL_Real()
// create subscriber // create subscriber
lowstate_subscriber.reset(new ChannelSubscriber<unitree_go::msg::dds_::LowState_>(TOPIC_LOWSTATE)); lowstate_subscriber.reset(new ChannelSubscriber<unitree_go::msg::dds_::LowState_>(TOPIC_LOWSTATE));
lowstate_subscriber->InitChannel(std::bind(&RL_Real::LowStateMessageHandler, this, std::placeholders::_1), 1); lowstate_subscriber->InitChannel(std::bind(&RL_Real::LowStateMessageHandler, this, std::placeholders::_1), 1);
// loop publishing thread TODO why? // loop publishing thread TODO-devel-go2 why?
// lowCmdWriteThreadPtr = CreateRecurrentThreadEx("writebasiccmd", UT_CPU_ID_NONE, 2000, &RL_Real::LowCmdwriteHandler, this); // lowCmdWriteThreadPtr = CreateRecurrentThreadEx("writebasiccmd", UT_CPU_ID_NONE, 2000, &RL_Real::LowCmdwriteHandler, this);
// init rl // init rl
@ -78,7 +78,7 @@ RL_Real::~RL_Real()
void RL_Real::GetState(RobotState<double> *state) void RL_Real::GetState(RobotState<double> *state)
{ {
// TODO 加锁 // TODO-devel-mutex 加锁
memcpy(&this->unitree_joy, &this->unitree_low_state.wireless_remote()[0], 40); memcpy(&this->unitree_joy, &this->unitree_low_state.wireless_remote()[0], 40);
if ((int)this->unitree_joy.btn.components.R2 == 1) if ((int)this->unitree_joy.btn.components.R2 == 1)
@ -133,7 +133,7 @@ void RL_Real::SetCommand(const RobotCommand<double> *command)
this->unitree_low_command.motor_cmd()[i].tau() = command->motor_command.tau[command_mapping[i]]; this->unitree_low_command.motor_cmd()[i].tau() = command->motor_command.tau[command_mapping[i]];
} }
// 暂时不发 TODO Why? // 暂时不发 TODO-devel-go2 Why?
this->unitree_low_command.crc() = Crc32Core((uint32_t *)&unitree_low_command, (sizeof(unitree_go::msg::dds_::LowCmd_) >> 2) - 1); this->unitree_low_command.crc() = Crc32Core((uint32_t *)&unitree_low_command, (sizeof(unitree_go::msg::dds_::LowCmd_) >> 2) - 1);
lowcmd_publisher->Write(unitree_low_command); lowcmd_publisher->Write(unitree_low_command);
} }

View File

@ -252,7 +252,7 @@ torch::Tensor RL_Sim::Forward()
if (this->params.use_history) if (this->params.use_history)
{ {
this->history_obs_buf.insert(clamped_obs); this->history_obs_buf.insert(clamped_obs);
// TODO 这里要找一种方法适配不同的顺序不能直接改这里会导致a1的模型不可用 // TODO-devel-go2 这里要找一种方法适配不同的顺序不能直接改这里会导致a1的模型不可用
this->history_obs = this->history_obs_buf.get_obs_vec({5, 4, 3, 2, 1, 0}); this->history_obs = this->history_obs_buf.get_obs_vec({5, 4, 3, 2, 1, 0});
actions = this->model.forward({this->history_obs}).toTensor(); actions = this->model.forward({this->history_obs}).toTensor();
} }