Skip to content

Commit 299e794

Browse files
authored
Merge branch 'rm-controls:master' into legged_manual_new
2 parents b70a509 + cb51cb1 commit 299e794

12 files changed

+1576
-78
lines changed

include/rm_manual/chassis_gimbal_shooter_cover_manual.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ class ChassisGimbalShooterCoverManual : public ChassisGimbalShooterManual
2020

2121
protected:
2222
void changeSpeedMode(SpeedMode speed_mode);
23+
double getDynamicScale(const double base_scale, const double amplitude, const double period, const double phase);
2324
void changeGyroSpeedMode(SpeedMode speed_mode);
2425
void updatePc(const rm_msgs::DbusData::ConstPtr& dbus_data) override;
2526
void checkKeyboard(const rm_msgs::DbusData::ConstPtr& dbus_data) override;
@@ -52,6 +53,7 @@ class ChassisGimbalShooterCoverManual : public ChassisGimbalShooterManual
5253
double low_speed_scale_{}, normal_speed_scale_{};
5354
double exit_buff_mode_duration_{};
5455
double gyro_speed_limit_{};
56+
double sin_gyro_base_scale_{ 1. }, sin_gyro_amplitude_{ 0. }, sin_gyro_period_{ 1. }, sin_gyro_phase_{ 0. };
5557
rm_common::SwitchDetectionCaller* switch_buff_srv_{};
5658
rm_common::SwitchDetectionCaller* switch_buff_type_srv_{};
5759
rm_common::SwitchDetectionCaller* switch_exposure_srv_{};

include/rm_manual/chassis_gimbal_shooter_manual.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,14 @@ class ChassisGimbalShooterManual : public ChassisGimbalManual
107107
void ctrlVPress();
108108
void ctrlBPress();
109109
void ctrlRPress();
110+
void ctrlZPress();
111+
void ctrlXPress();
110112
virtual void ctrlRRelease();
111113
virtual void ctrlQPress();
112114

113115
InputEvent self_inspection_event_, game_start_event_, e_event_, c_event_, g_event_, q_event_, b_event_, x_event_,
114-
r_event_, v_event_, ctrl_f_event_, ctrl_v_event_, ctrl_b_event_, ctrl_q_event_, ctrl_r_event_, shift_event_,
115-
ctrl_shift_b_event_, mouse_left_event_, mouse_right_event_;
116+
r_event_, v_event_, ctrl_f_event_, ctrl_v_event_, ctrl_b_event_, ctrl_q_event_, ctrl_r_event_, ctrl_z_event_,
117+
ctrl_x_event_, shift_event_, ctrl_shift_b_event_, mouse_left_event_, mouse_right_event_;
116118
rm_common::ShooterCommandSender* shooter_cmd_sender_{};
117119
rm_common::CameraSwitchCommandSender* camera_switch_cmd_sender_{};
118120
rm_common::JointPositionBinaryCommandSender* scope_cmd_sender_{};
@@ -126,7 +128,9 @@ class ChassisGimbalShooterManual : public ChassisGimbalManual
126128
geometry_msgs::PointStamped point_out_;
127129
uint8_t last_shoot_freq_{};
128130

129-
bool prepare_shoot_ = false, is_balance_ = false, use_scope_ = false, adjust_image_transmission_ = false;
131+
bool prepare_shoot_ = false, is_balance_ = false, use_scope_ = false, adjust_image_transmission_ = false,
132+
up_change_position_ = false, low_change_position_ = false, need_change_position_ = false;
130133
double yaw_current_{};
134+
double scale_;
131135
};
132136
} // namespace rm_manual
Lines changed: 193 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,193 @@
1+
//
2+
// Created by qiayuan on 5/23/21.
3+
//
4+
5+
#pragma once
6+
7+
#include "chassis_gimbal_manual.h"
8+
9+
#include <utility>
10+
#include <std_srvs/Empty.h>
11+
#include <actionlib/client/simple_action_client.h>
12+
#include <rm_common/decision/calibration_queue.h>
13+
#include <std_msgs/Float64.h>
14+
#include <tf2_geometry_msgs/tf2_geometry_msgs.h>
15+
#include <rm_msgs/EngineerAction.h>
16+
#include <rm_msgs/MultiDofCmd.h>
17+
#include <rm_msgs/GpioData.h>
18+
#include <rm_msgs/EngineerUi.h>
19+
#include <rm_msgs/VisualizeStateData.h>
20+
#include <stack>
21+
#include "unordered_map"
22+
23+
namespace rm_manual
24+
{
25+
class Engineer2Manual : public ChassisGimbalManual
26+
{
27+
public:
28+
enum ControlMode
29+
{
30+
MANUAL,
31+
MIDDLEWARE
32+
};
33+
34+
enum JointMode
35+
{
36+
SERVO,
37+
JOINT
38+
};
39+
40+
enum GimbalMode
41+
{
42+
RATE,
43+
DIRECT
44+
};
45+
46+
enum SpeedMode
47+
{
48+
LOW,
49+
NORMAL,
50+
FAST,
51+
EXCHANGE,
52+
BIG_ISLAND_SPEED
53+
};
54+
55+
Engineer2Manual(ros::NodeHandle& nh, ros::NodeHandle& nh_referee);
56+
void run() override;
57+
58+
private:
59+
void changeSpeedMode(SpeedMode speed_mode);
60+
void checkKeyboard(const rm_msgs::DbusData::ConstPtr& dbus_data) override;
61+
void updateRc(const rm_msgs::DbusData::ConstPtr& dbus_data) override;
62+
void updatePc(const rm_msgs::DbusData::ConstPtr& dbus_data) override;
63+
void updateServo(const rm_msgs::DbusData::ConstPtr& dbus_data);
64+
void dbusDataCallback(const rm_msgs::DbusData::ConstPtr& data) override;
65+
void gpioStateCallback(const rm_msgs::GpioData::ConstPtr& data);
66+
void stoneNumCallback(const std_msgs::String ::ConstPtr& data);
67+
void sendCommand(const ros::Time& time) override;
68+
void runStepQueue(const std::string& step_queue_name);
69+
void actionFeedbackCallback(const rm_msgs::EngineerFeedbackConstPtr& feedback);
70+
void actionDoneCallback(const actionlib::SimpleClientGoalState& state, const rm_msgs::EngineerResultConstPtr& result);
71+
72+
void initMode();
73+
void enterServo();
74+
void actionActiveCallback()
75+
{
76+
operating_mode_ = MIDDLEWARE;
77+
}
78+
void remoteControlTurnOff() override;
79+
void chassisOutputOn() override;
80+
void gimbalOutputOn() override;
81+
82+
void rightSwitchUpRise() override;
83+
void rightSwitchMidRise() override;
84+
void rightSwitchDownRise() override;
85+
void leftSwitchUpRise() override;
86+
void leftSwitchUpFall();
87+
void leftSwitchDownRise() override;
88+
void leftSwitchDownFall();
89+
void ctrlAPress();
90+
void ctrlBPress();
91+
void ctrlBPressing();
92+
void ctrlBRelease();
93+
void ctrlCPress();
94+
void ctrlDPress();
95+
void ctrlEPress();
96+
void ctrlFPress();
97+
void ctrlGPress();
98+
void ctrlQPress();
99+
void ctrlRPress();
100+
void ctrlSPress();
101+
void ctrlVPress();
102+
void ctrlVRelease();
103+
void ctrlWPress();
104+
void ctrlXPress();
105+
void ctrlZPress();
106+
107+
void bPressing();
108+
void bRelease();
109+
void cPressing();
110+
void cRelease();
111+
void ePressing();
112+
void eRelease();
113+
void fPress();
114+
void fRelease();
115+
void gPress();
116+
void gRelease();
117+
void qPressing();
118+
void qRelease();
119+
void rPress();
120+
void rRelease();
121+
void vPressing();
122+
void vRelease();
123+
void xPress();
124+
void zPressing();
125+
void zRelease();
126+
127+
void shiftPressing();
128+
void shiftRelease();
129+
void shiftBPress();
130+
void shiftBRelease();
131+
void shiftCPress();
132+
void shiftEPress();
133+
void shiftFPress();
134+
void shiftGPress();
135+
void shiftQPress();
136+
void shiftRPress();
137+
void shiftRRelease();
138+
void shiftVPress();
139+
void shiftVRelease();
140+
void shiftXPress();
141+
void shiftZPress();
142+
void shiftZRelease();
143+
144+
void mouseLeftRelease();
145+
void mouseRightRelease();
146+
147+
// Servo
148+
149+
bool mouse_left_pressed_{}, mouse_right_pressed_{}, had_ground_stone_{ false }, main_gripper_on_{ false },
150+
had_side_gold_{ false }, stone_state_[4]{};
151+
double angular_z_scale_{}, gyro_scale_{}, fast_gyro_scale_{}, low_gyro_scale_{}, normal_gyro_scale_{},
152+
exchange_gyro_scale_{}, fast_speed_scale_{}, low_speed_scale_{}, normal_speed_scale_{}, exchange_speed_scale_{},
153+
big_island_speed_scale_{};
154+
155+
std::string prefix_{}, root_{}, exchange_direction_{ "left" }, exchange_arm_position_{ "normal" };
156+
int operating_mode_{}, servo_mode_{ 1 }, gimbal_mode_{}, gimbal_direction_{ 0 };
157+
158+
std::stack<std::string> stone_num_{};
159+
160+
ros::Time last_time_;
161+
ros::Subscriber stone_num_sub_, gripper_state_sub_;
162+
ros::Publisher engineer_ui_pub_, gripper_ui_pub_;
163+
164+
rm_msgs::GpioData gpio_state_;
165+
rm_msgs::EngineerUi engineer_ui_, old_ui_;
166+
rm_msgs::VisualizeStateData gripper_ui_;
167+
168+
rm_common::Vel3DCommandSender* servo_command_sender_;
169+
rm_common::ServiceCallerBase<std_srvs::Empty>* servo_reset_caller_;
170+
rm_common::CalibrationQueue* calibration_gather_{};
171+
172+
actionlib::SimpleActionClient<rm_msgs::EngineerAction> action_client_;
173+
174+
InputEvent left_switch_up_event_, left_switch_down_event_, ctrl_a_event_, ctrl_b_event_, ctrl_c_event_, ctrl_d_event_,
175+
ctrl_e_event_, ctrl_f_event_, ctrl_g_event_, ctrl_q_event_, ctrl_r_event_, ctrl_s_event_, ctrl_v_event_,
176+
ctrl_w_event_, ctrl_x_event_, ctrl_z_event_, b_event_, c_event_, e_event_, f_event_, g_event_, q_event_, r_event_,
177+
v_event_, x_event_, z_event_, shift_event_, shift_b_event_, shift_c_event_, shift_e_event_, shift_f_event_,
178+
shift_g_event_, shift_v_event_, shift_q_event_, shift_r_event_, shift_x_event_, shift_z_event_, mouse_left_event_,
179+
mouse_right_event_;
180+
181+
std::unordered_map<std::string, int> stoneNumMap_ = {
182+
{ "+g", 0 }, { "+s1", 1 }, { "+s2", 2 }, { "+s3", 3 }, { "-g", 0 }, { "-s1", 1 }, { "-s2", 2 }, { "-s3", 3 },
183+
};
184+
185+
enum UiState
186+
{
187+
NONE,
188+
BIG_ISLAND,
189+
SMALL_ISLAND
190+
};
191+
};
192+
193+
} // namespace rm_manual

include/rm_manual/engineer_manual.h

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <rm_msgs/MultiDofCmd.h>
1717
#include <rm_msgs/GpioData.h>
1818
#include <rm_msgs/EngineerUi.h>
19+
#include <stack>
1920

2021
namespace rm_manual
2122
{
@@ -48,6 +49,13 @@ class EngineerManual : public ChassisGimbalManual
4849
EXCHANGE
4950
};
5051

52+
enum ServoOrientation
53+
{
54+
MID,
55+
RIGHT,
56+
LEFT
57+
};
58+
5159
EngineerManual(ros::NodeHandle& nh, ros::NodeHandle& nh_referee);
5260
void run() override;
5361

@@ -122,40 +130,47 @@ class EngineerManual : public ChassisGimbalManual
122130
void shiftBPress();
123131
void shiftBRelease();
124132
void shiftCPress();
133+
void shiftEPress();
125134
void shiftFPress();
126135
void shiftGPress();
136+
void shiftQPress();
127137
void shiftRPress();
128138
void shiftRRelease();
129139
void shiftVPress();
130140
void shiftVRelease();
131141
void shiftXPress();
132142
void shiftZPress();
143+
void shiftZRelease();
133144

134145
void mouseLeftRelease();
135146
void mouseRightRelease();
136147

137148
// Servo
138149

139-
bool change_flag_{};
150+
bool change_flag_{}, ore_rotator_pos_{ false }, shift_z_pressed_{ false }, ore_lifter_on_{ false },
151+
v_pressed_{ false };
152+
140153
double angular_z_scale_{}, gyro_scale_{}, fast_gyro_scale_{}, low_gyro_scale_{}, normal_gyro_scale_{},
141154
exchange_gyro_scale_{}, fast_speed_scale_{}, low_speed_scale_{}, normal_speed_scale_{}, exchange_speed_scale_{};
142155

143-
std::string prefix_{}, root_{}, reversal_state_{}, drag_state_{ "off" }, gripper_state_{ "off" };
144-
int operating_mode_{}, servo_mode_{}, gimbal_mode_{}, stone_num_{ 0 }, gimbal_height_{ 0 };
156+
std::string prefix_{}, root_{}, reversal_state_{}, drag_state_{ "off" }, gripper_state_{ "off" }, last_ore_{};
157+
158+
int operating_mode_{}, servo_mode_{}, servo_orientation_{ 0 }, gimbal_mode_{}, gimbal_height_{ 0 },
159+
gimbal_direction_{ 0 }, ore_lifter_pos_{ 0 };
160+
161+
std::stack<std::string> stone_num_{};
145162

146163
ros::Time last_time_;
147164
ros::Subscriber stone_num_sub_, gripper_state_sub_;
148165
ros::Publisher engineer_ui_pub_;
149166

150167
rm_msgs::GpioData gpio_state_;
151-
rm_msgs::EngineerUi engineer_ui_;
168+
rm_msgs::EngineerUi engineer_ui_, previous_ui_;
152169

153170
rm_common::Vel3DCommandSender* servo_command_sender_;
154171
rm_common::ServiceCallerBase<std_srvs::Empty>* servo_reset_caller_;
155-
rm_common::JointPositionBinaryCommandSender *extend_arm_a_command_sender_, *extend_arm_b_command_sender_;
156-
rm_common::JointPointCommandSender *ore_bin_lifter_command_sender_, *ore_bin_rotate_command_sender_,
157-
*gimbal_lifter_command_sender_;
158-
rm_common::CalibrationQueue *calibration_gather_{}, *pitch_calibration_;
172+
173+
rm_common::CalibrationQueue *calibration_gather_{}, *pitch_calibration_, *ore_bin_lifter_calibration_{};
159174

160175
actionlib::SimpleActionClient<rm_msgs::EngineerAction> action_client_;
161176

include/rm_manual/manual_base.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ class ManualBase
159159
ros::NodeHandle nh_;
160160

161161
ros::Time referee_last_get_stamp_;
162-
bool remote_is_open_{}, referee_is_online_ = false;
162+
bool remote_is_open_{ false }, referee_is_online_ = false;
163163
int state_ = PASSIVE;
164164
int robot_id_, chassis_power_;
165165
int chassis_output_on_ = 0, gimbal_output_on_ = 0, shooter_output_on_ = 0;

launch/load.launch

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<launch>
2-
<arg name="robot_type" default="$(env ROBOT_TYPE)" doc="Robot type [standard, hero, engineer]"/>
2+
<arg name="robot_type" default="$(env ROBOT_TYPE)" doc="Robot type [standard, hero, engineer, engineer2]"/>
33

44
<rosparam file="$(find rm_config)/config/rm_controllers/$(arg robot_type).yaml" command="load"/>
55
<rosparam file="$(find rm_manual)/config/$(arg robot_type).yaml" command="load"/>

src/chassis_gimbal_manual.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,10 @@ void ChassisGimbalManual::checkKeyboard(const rm_msgs::DbusData::ConstPtr& dbus_
7272
ManualBase::checkKeyboard(dbus_data);
7373
if (robot_id_ == rm_msgs::GameRobotStatus::RED_ENGINEER || robot_id_ == rm_msgs::GameRobotStatus::BLUE_ENGINEER)
7474
{
75-
w_event_.update((!dbus_data->key_ctrl) && (!dbus_data->key_shift) && dbus_data->key_w);
76-
s_event_.update((!dbus_data->key_ctrl) && (!dbus_data->key_shift) && dbus_data->key_s);
77-
a_event_.update((!dbus_data->key_ctrl) && (!dbus_data->key_shift) && dbus_data->key_a);
78-
d_event_.update((!dbus_data->key_ctrl) && (!dbus_data->key_shift) && dbus_data->key_d);
75+
w_event_.update((!dbus_data->key_ctrl) && dbus_data->key_w);
76+
s_event_.update((!dbus_data->key_ctrl) && dbus_data->key_s);
77+
a_event_.update((!dbus_data->key_ctrl) && dbus_data->key_a);
78+
d_event_.update((!dbus_data->key_ctrl) && dbus_data->key_d);
7979
}
8080
else
8181
{

0 commit comments

Comments
 (0)