Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sentry mode when hit by dart. #104

Closed
wants to merge 45 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
60a648a
Add fuctions in standard.
liyixin135 Jul 9, 2024
8e91447
Achieve auto_shoot by vision.
liyixin135 Jul 9, 2024
cc36deb
Add sub to subscribe event_data.
liyixin135 Jul 9, 2024
d489c5f
Modify wrong topic_name.
liyixin135 Jul 9, 2024
5d68d55
Modify wrong nh.
liyixin135 Jul 9, 2024
03002f2
Finish callback.
liyixin135 Jul 9, 2024
2358156
Achieve auto_shoot in ChassisGimbalShooterManual.
liyixin135 Jul 10, 2024
7de88b8
Modify something wrong.
liyixin135 Jul 10, 2024
a4ba929
Achieve different mode to auto.
liyixin135 Jul 10, 2024
c9a66c6
Make a reset.
liyixin135 Jul 10, 2024
a128ffd
Modify something wrong.
liyixin135 Jul 10, 2024
daea52a
Modify something for try.
liyixin135 Jul 10, 2024
542fb1f
Modify wrong of unable to be auto when press mouseRight twice.
BlanchardLj Jul 10, 2024
b234d32
Merge pull request #1 from BlanchardLj/traj
liyixin135 Jul 10, 2024
83976fc
Modify the method of achievement.
liyixin135 Jul 11, 2024
def92d6
Modify another function.
liyixin135 Jul 11, 2024
506e1e1
Modify the wrong of shoot when tracking and exiting auto_mode.
liyixin135 Jul 11, 2024
a9bf537
Merge branch 'master' into traj
liyixin135 Jul 19, 2024
617b8c3
Modify param name in msg.
liyixin135 Jul 19, 2024
21de4a4
Delete judgeIsAuto() for clean.
liyixin135 Jul 19, 2024
fbf8399
Move place where setting count_.
liyixin135 Jul 19, 2024
caff303
Add init.
liyixin135 Jul 19, 2024
ebee8b8
Add init.
liyixin135 Jul 19, 2024
ac62f70
Use enum to replace number.
liyixin135 Jul 19, 2024
fca04e4
Delete something unused.
liyixin135 Jul 19, 2024
a265dc6
Delete something unused.
liyixin135 Jul 20, 2024
a7f8a19
Override mouseRightPress in ChassisGimbalShooterCoverManual.
liyixin135 Jul 20, 2024
3650acd
Achieve sentry mode in ChassisGimbalShooterCoverManual.
liyixin135 Jul 20, 2024
d55c028
Modify name.
liyixin135 Jul 20, 2024
957af8e
Update for clean.
liyixin135 Jul 23, 2024
2c6147a
Merge branch 'master' into traj
liyixin135 Jul 23, 2024
112dff3
Update for clean.
liyixin135 Jul 23, 2024
df70cab
Merge branch 'master' into traj
liyixin135 Jul 26, 2024
9dfaf3f
Fix wrong.
liyixin135 Jul 26, 2024
e0d724f
Merge branch 'master' into traj
liyixin135 Jul 26, 2024
3fa7c25
Modify the method of count cycle.
liyixin135 Jul 26, 2024
069fc0f
Modify function name.
liyixin135 Jul 26, 2024
91c2bd0
Fix wrong.
liyixin135 Jul 26, 2024
60b3b94
Update for clean.
liyixin135 Jul 26, 2024
b4016e9
Delete something unused.
liyixin135 Jul 26, 2024
1b90fb4
Delete something unused.
liyixin135 Jul 26, 2024
8b91573
Modify a param name.
liyixin135 Jul 26, 2024
61a2597
Merge branch 'master' into traj
liyixin135 Jul 30, 2024
e91fe4f
Fix wrong from merge.
liyixin135 Jul 30, 2024
bf8f6ff
Slow down rotate speed.
liyixin135 Jul 30, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/rm_manual/chassis_gimbal_shooter_cover_manual.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class ChassisGimbalShooterCoverManual : public ChassisGimbalShooterManual
void zRelease();
void wPress() override;
void wPressing() override;
void mouseRightPress() override;

virtual void ctrlZPress();
virtual void ctrlZRelease()
Expand Down
16 changes: 14 additions & 2 deletions include/rm_manual/chassis_gimbal_shooter_manual.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class ChassisGimbalShooterManual : public ChassisGimbalManual
shooter_cmd_sender_->setMode(rm_msgs::ShootCmd::READY);
prepare_shoot_ = true;
}
void mouseRightPress();
virtual void mouseRightPress();
void mouseRightRelease()
{
gimbal_cmd_sender_->setMode(rm_msgs::GimbalCmd::RATE);
Expand Down Expand Up @@ -108,6 +108,7 @@ class ChassisGimbalShooterManual : public ChassisGimbalManual
void ctrlRPress();
void ctrlRRelease();
virtual void ctrlQPress();
void eventDataCallback(const rm_msgs::EventData ::ConstPtr& data) override;

InputEvent self_inspection_event_, game_start_event_, e_event_, c_event_, g_event_, q_event_, b_event_, x_event_,
r_event_, v_event_, ctrl_f_event_, ctrl_v_event_, ctrl_b_event_, ctrl_q_event_, ctrl_r_event_, shift_event_,
Expand All @@ -124,7 +125,18 @@ class ChassisGimbalShooterManual : public ChassisGimbalManual
geometry_msgs::PointStamped point_out_;
uint8_t last_shoot_freq_{};

bool prepare_shoot_ = false, is_balance_ = false, use_scope_ = false, adjust_image_transmission_ = false;
enum TargetHitByDart
{
OUTPOST = 1,
BASE = 2,
MOVE_BASE = 3
};

ros::Time start_timer_time_{};

bool prepare_shoot_ = false, is_balance_ = false, use_scope_ = false, is_auto_ = false,
adjust_image_transmission_ = false;
double yaw_current_{};
int count_{}, last_time_hit_by_dart_{};
};
} // namespace rm_manual
6 changes: 5 additions & 1 deletion include/rm_manual/manual_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include <rm_msgs/TrackData.h>
#include <rm_msgs/GameStatus.h>
#include <rm_msgs/GameRobotHp.h>
#include <rm_msgs/EventData.h>
#include <rm_msgs/BalanceState.h>
#include <rm_msgs/PowerHeatData.h>
#include <rm_msgs/ActuatorState.h>
Expand Down Expand Up @@ -76,6 +77,9 @@ class ManualBase
virtual void shootBeforehandCmdCallback(const rm_msgs::ShootBeforehandCmd ::ConstPtr& data)
{
}
virtual void eventDataCallback(const rm_msgs::EventData ::ConstPtr& data)
{
}
virtual void odomCallback(const nav_msgs::Odometry::ConstPtr& data)
{
}
Expand Down Expand Up @@ -145,7 +149,7 @@ class ManualBase

ros::Subscriber odom_sub_, dbus_sub_, track_sub_, referee_sub_, capacity_sub_, game_status_sub_, joint_state_sub_,
game_robot_hp_sub_, actuator_state_sub_, power_heat_data_sub_, gimbal_des_error_sub_, game_robot_status_sub_,
suggest_fire_sub_, shoot_beforehand_cmd_sub_, shoot_data_sub_;
suggest_fire_sub_, shoot_beforehand_cmd_sub_, shoot_data_sub_, event_data_sub_;

sensor_msgs::JointState joint_state_;
rm_msgs::TrackData track_data_;
Expand Down
28 changes: 28 additions & 0 deletions src/chassis_gimbal_shooter_cover_manual.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,4 +211,32 @@ void ChassisGimbalShooterCoverManual::ctrlZPress()
}
}

void ChassisGimbalShooterCoverManual::mouseRightPress()
{
ChassisGimbalShooterManual::mouseRightPress();
if (is_auto_)
{
if (!is_gyro_)
{
chassis_cmd_sender_->power_limit_->updateState(rm_common::PowerLimit::NORMAL);
setChassisMode(rm_msgs::ChassisCmd::RAW);
}
if (track_data_.id == 0)
{
gimbal_cmd_sender_->setMode(rm_msgs::GimbalCmd::TRAJ);
double traj_yaw = M_PI * count_ / 1000;
double traj_pitch = 0.15 * sin(2 * M_PI * (count_ % 1100) / 1100) + 0.15;
count_++;
gimbal_cmd_sender_->setGimbalTraj(traj_yaw, traj_pitch);
shooter_cmd_sender_->setMode(rm_msgs::ShootCmd::READY);
}
else
{
shooter_cmd_sender_->setMode(rm_msgs::ShootCmd::PUSH);
liyixin135 marked this conversation as resolved.
Show resolved Hide resolved
shooter_cmd_sender_->checkError(ros::Time::now());
}
}
else if (!mouse_left_event_.getState() && shooter_cmd_sender_->getMsg()->mode == rm_msgs::ShootCmd::PUSH)
shooter_cmd_sender_->setMode(rm_msgs::ShootCmd::READY);
}
} // namespace rm_manual
18 changes: 18 additions & 0 deletions src/chassis_gimbal_shooter_manual.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ void ChassisGimbalShooterManual::remoteControlTurnOff()
shooter_calibration_->stop();
gimbal_calibration_->stop();
use_scope_ = false;
is_auto_ = false;
adjust_image_transmission_ = false;
}

Expand All @@ -215,6 +216,7 @@ void ChassisGimbalShooterManual::robotDie()
ManualBase::robotDie();
shooter_cmd_sender_->setMode(rm_msgs::ShootCmd::STOP);
use_scope_ = false;
is_auto_ = false;
adjust_image_transmission_ = false;
}

Expand Down Expand Up @@ -628,4 +630,20 @@ void ChassisGimbalShooterManual::ctrlQPress()
gimbal_calibration_->reset();
}

void ChassisGimbalShooterManual::eventDataCallback(const rm_msgs::EventData::ConstPtr& data)
{
ChassisGimbalManual::eventDataCallback(data);
if (data->be_hit_time != last_time_hit_by_dart_)
{
last_time_hit_by_dart_ = data->be_hit_time;
start_timer_time_ = ros::Time::now();
count_ = 0;
}
if ((data->be_hit_target == OUTPOST && (ros::Time::now() - start_timer_time_).toSec() <= 5) ||
(data->be_hit_target == BASE && (ros::Time::now() - start_timer_time_).toSec() <= 10) ||
(data->be_hit_target == MOVE_BASE && (ros::Time::now() - start_timer_time_).toSec() <= 15))
is_auto_ = true;
else
is_auto_ = false;
}
} // namespace rm_manual
1 change: 1 addition & 0 deletions src/manual_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ ManualBase::ManualBase(ros::NodeHandle& nh, ros::NodeHandle& nh_referee)
"power_management/sample_and_status", 10, &ManualBase::capacityDataCallback, this);
power_heat_data_sub_ =
nh_referee.subscribe<rm_msgs::PowerHeatData>("power_heat_data", 10, &ManualBase::powerHeatDataCallback, this);
event_data_sub_ = nh_referee.subscribe<rm_msgs::EventData>("event_data", 10, &ManualBase::eventDataCallback, this);
shoot_data_sub_ = nh_referee.subscribe<rm_msgs::ShootData>("shoot_data", 10, &ManualBase::shootDataCallback, this);

// pub
Expand Down
Loading