more cleanup to tracer_base

This commit is contained in:
Ruixiang Du
2020-11-06 09:50:25 +08:00
parent 3ca082d1f0
commit 16ccaa1706
4 changed files with 8 additions and 23 deletions

View File

@@ -91,8 +91,6 @@ add_library(${PROJECT_NAME}
# src/scout_can_parser.c
# src/scout_uart_parser.c
src/tracer_base.cpp
# src/tracer_can_parser.c
# src/tracer_uart_parser.c
# src/bunker_base.cpp
# src/bunker_can_parser.c
)

View File

@@ -32,23 +32,19 @@ int main(int argc, char **argv) {
// light control
std::cout << "Light: const off" << std::endl;
tracer.SetLightCommand({TracerLightCmd::LightMode::CONST_OFF, 0,
TracerLightCmd::LightMode::CONST_OFF, 0});
tracer.SetLightCommand({TracerLightCmd::LightMode::CONST_OFF, 0});
// usleep(50000);
sleep(3);
std::cout << "Light: const on" << std::endl;
tracer.SetLightCommand({TracerLightCmd::LightMode::CONST_ON, 0,
TracerLightCmd::LightMode::CONST_ON, 0});
tracer.SetLightCommand({TracerLightCmd::LightMode::CONST_ON, 0});
// usleep(50000);
sleep(3);
std::cout << "Light: breath" << std::endl;
tracer.SetLightCommand({TracerLightCmd::LightMode::BREATH, 0,
TracerLightCmd::LightMode::BREATH, 0});
tracer.SetLightCommand({TracerLightCmd::LightMode::BREATH, 0});
// usleep(50000);
sleep(8);
std::cout << "Light: custom 90-80" << std::endl;
tracer.SetLightCommand({TracerLightCmd::LightMode::CUSTOM, 90,
TracerLightCmd::LightMode::CUSTOM, 80});
tracer.SetLightCommand({TracerLightCmd::LightMode::CUSTOM, 90});
// usleep(50000);
sleep(3);
std::cout << "Light: diabled cmd control" << std::endl;

View File

@@ -39,14 +39,10 @@ class TracerBase : public MobileBase {
private:
// cmd/status update related variables
std::mutex tracer_state_mutex_;
std::mutex uart_tracer_state_mutex_;
std::mutex motion_cmd_mutex_;
std::mutex light_cmd_mutex_;
std::mutex mode_cmd_mutex_;
TracerState tracer_state_;
TracerMotionCmd current_motion_cmd_;
TracerLightCmd current_light_cmd_;
bool light_ctrl_enabled_ = false;
bool light_ctrl_requested_ = false;

View File

@@ -75,19 +75,14 @@ struct TracerLightCmd {
};
TracerLightCmd() = default;
TracerLightCmd(LightMode f_mode, uint8_t f_value, LightMode r_mode,
uint8_t r_value)
: enable_ctrl(true),
front_mode(f_mode),
front_custom_value(f_value),
rear_mode(r_mode),
rear_custom_value(r_value) {}
TracerLightCmd(LightMode f_mode, uint8_t f_value)
: enable_ctrl(true), front_mode(f_mode), front_custom_value(f_value) {}
bool enable_ctrl = false;
LightMode front_mode;
uint8_t front_custom_value;
LightMode rear_mode;
uint8_t rear_custom_value;
LightMode rear_mode = LightMode::CONST_OFF;
uint8_t rear_custom_value = 0;
};
} // namespace westonrobot