Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add realism to simoulator cli run
Browse files Browse the repository at this point in the history
sanatd33 committed Oct 1, 2024
1 parent c32d1f2 commit fd695ec
Showing 6 changed files with 4 additions and 31 deletions.
2 changes: 1 addition & 1 deletion launch/framework.bash
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@ if [ -z "$binary" ]; then
fi

# Run the binary in the background
"$binary" &
"$binary" -g 2020B --realism RC2021 &
binary_pid=$!

# Ensure that pressing Ctrl+C kills all subprocesses
2 changes: 0 additions & 2 deletions soccer/src/soccer/control/motion_control.cpp
Original file line number Diff line number Diff line change
@@ -159,8 +159,6 @@ void MotionControl::run(const RobotState& state, const planning::Trajectory& tra
drawer_.publish();
}

set_velocity(setpoint, rj_geometry::Twist{rj_geometry::Point{}, 1.4});

if (maybe_target) {
RobotState desired_state;
desired_state.pose = maybe_target->pose;
14 changes: 1 addition & 13 deletions soccer/src/soccer/radio/packet_convert.cpp
Original file line number Diff line number Diff line change
@@ -131,7 +131,6 @@ void status_to_ros(const RobotStatus& status, rj_msgs::msg::RobotStatus* msg) {
msg->battery_voltage = status.battery_voltage;
msg->motor_errors = status.motors_healthy;
msg->has_ball_sense = status.has_ball;
if (msg->robot_id == 1) SPDLOG_INFO("ID: {} HAS BALL: {}", msg->robot_id, msg->has_ball_sense);
msg->kicker_charged = status.kicker == RobotStatus::KickerState::kCharged;
msg->kicker_healthy = status.kicker != RobotStatus::KickerState::kFailed;
msg->fpga_error = !status.fpga_healthy;
@@ -314,23 +313,12 @@ void ros_to_sim(const rj_msgs::msg::ManipulatorSetpoint& manipulator,
}
}

sim->set_kick_speed(0);

auto* command = sim->mutable_move_command()->mutable_local_velocity();
command->set_forward(static_cast<float>(motion.velocity_y_mps));
command->set_left(-static_cast<float>(motion.velocity_x_mps));
command->set_angular(static_cast<float>(motion.velocity_z_radps));

sim->set_dribbler_speed(2000);
// if (sim->id() == 1) i = -i;

// SPDLOG_INFO("ID: {}", sim->id());
// SPDLOG_INFO("forward: {}", sim->move_command().local_velocity().forward());
// SPDLOG_INFO("left: {}", sim->move_command().local_velocity().left());
// SPDLOG_INFO("angular: {}", sim->move_command().local_velocity().angular());
// SPDLOG_INFO("Kick Speed: {}", sim->kick_speed());
// SPDLOG_INFO("Kick Angle: {}", sim->kick_angle());
if (sim->id() == 1) SPDLOG_INFO("Dribbler Speed: {}", sim->dribbler_speed());
sim->set_dribbler_speed(static_cast<float>(PARAM_max_dribbler_speed * manipulator.dribbler_speed));
}

} // namespace ConvertTx
2 changes: 1 addition & 1 deletion soccer/src/soccer/radio/packet_convert.hpp
Original file line number Diff line number Diff line change
@@ -65,5 +65,5 @@ void to_sim(const RobotIntent& intent, const MotionSetpoint& setpoint,
void ros_to_sim(const rj_msgs::msg::ManipulatorSetpoint& manipulator,
const rj_msgs::msg::MotionSetpoint& motion, int shell,
RobotCommand* sim);
static int i = 1;

} // namespace ConvertTx
2 changes: 1 addition & 1 deletion soccer/src/soccer/radio/radio.cpp
Original file line number Diff line number Diff line change
@@ -74,7 +74,7 @@ void Radio::tick() {
.shoot_mode(ManipulatorSetpoint::SHOOT_MODE_KICK)
.trigger_mode(ManipulatorSetpoint::TRIGGER_MODE_STAND_DOWN)
.kick_speed(0)
.dribbler_speed(2000);
.dribbler_speed(0);
last_updates_.at(i) = RJ::now();
send_control_message(i, motion, manipulator, positions_.at(i));
}
13 changes: 0 additions & 13 deletions soccer/src/soccer/radio/sim_radio.cpp
Original file line number Diff line number Diff line change
@@ -138,19 +138,6 @@ void SimRadio::send_control_message(uint8_t robot_id, const rj_msgs::msg::Motion
std::string out;
sim_packet.SerializeToString(&out);

if (robot_id == -1) {

SPDLOG_INFO("size: {}", out.size());

std::string print = "";

for (auto &c : out) {
print += std::to_string(static_cast<int>(c)) + " ";
}

SPDLOG_INFO("msg: {}", print);
}

// print kick speed
// TODO(Alex): replace with UI indicator
/* if (sim_robot->kick_speed() > 0) { */

0 comments on commit fd695ec

Please sign in to comment.