mirror of
https://github.com/westonrobot/ugv_sdk
synced 2023-04-08 06:32:14 +08:00
more cleanup to tracer_base
This commit is contained in:
@@ -91,8 +91,6 @@ add_library(${PROJECT_NAME}
|
|||||||
# src/scout_can_parser.c
|
# src/scout_can_parser.c
|
||||||
# src/scout_uart_parser.c
|
# src/scout_uart_parser.c
|
||||||
src/tracer_base.cpp
|
src/tracer_base.cpp
|
||||||
# src/tracer_can_parser.c
|
|
||||||
# src/tracer_uart_parser.c
|
|
||||||
# src/bunker_base.cpp
|
# src/bunker_base.cpp
|
||||||
# src/bunker_can_parser.c
|
# src/bunker_can_parser.c
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -32,23 +32,19 @@ int main(int argc, char **argv) {
|
|||||||
|
|
||||||
// light control
|
// light control
|
||||||
std::cout << "Light: const off" << std::endl;
|
std::cout << "Light: const off" << std::endl;
|
||||||
tracer.SetLightCommand({TracerLightCmd::LightMode::CONST_OFF, 0,
|
tracer.SetLightCommand({TracerLightCmd::LightMode::CONST_OFF, 0});
|
||||||
TracerLightCmd::LightMode::CONST_OFF, 0});
|
|
||||||
// usleep(50000);
|
// usleep(50000);
|
||||||
sleep(3);
|
sleep(3);
|
||||||
std::cout << "Light: const on" << std::endl;
|
std::cout << "Light: const on" << std::endl;
|
||||||
tracer.SetLightCommand({TracerLightCmd::LightMode::CONST_ON, 0,
|
tracer.SetLightCommand({TracerLightCmd::LightMode::CONST_ON, 0});
|
||||||
TracerLightCmd::LightMode::CONST_ON, 0});
|
|
||||||
// usleep(50000);
|
// usleep(50000);
|
||||||
sleep(3);
|
sleep(3);
|
||||||
std::cout << "Light: breath" << std::endl;
|
std::cout << "Light: breath" << std::endl;
|
||||||
tracer.SetLightCommand({TracerLightCmd::LightMode::BREATH, 0,
|
tracer.SetLightCommand({TracerLightCmd::LightMode::BREATH, 0});
|
||||||
TracerLightCmd::LightMode::BREATH, 0});
|
|
||||||
// usleep(50000);
|
// usleep(50000);
|
||||||
sleep(8);
|
sleep(8);
|
||||||
std::cout << "Light: custom 90-80" << std::endl;
|
std::cout << "Light: custom 90-80" << std::endl;
|
||||||
tracer.SetLightCommand({TracerLightCmd::LightMode::CUSTOM, 90,
|
tracer.SetLightCommand({TracerLightCmd::LightMode::CUSTOM, 90});
|
||||||
TracerLightCmd::LightMode::CUSTOM, 80});
|
|
||||||
// usleep(50000);
|
// usleep(50000);
|
||||||
sleep(3);
|
sleep(3);
|
||||||
std::cout << "Light: diabled cmd control" << std::endl;
|
std::cout << "Light: diabled cmd control" << std::endl;
|
||||||
|
|||||||
@@ -39,14 +39,10 @@ class TracerBase : public MobileBase {
|
|||||||
private:
|
private:
|
||||||
// cmd/status update related variables
|
// cmd/status update related variables
|
||||||
std::mutex tracer_state_mutex_;
|
std::mutex tracer_state_mutex_;
|
||||||
std::mutex uart_tracer_state_mutex_;
|
|
||||||
std::mutex motion_cmd_mutex_;
|
std::mutex motion_cmd_mutex_;
|
||||||
std::mutex light_cmd_mutex_;
|
|
||||||
std::mutex mode_cmd_mutex_;
|
|
||||||
|
|
||||||
TracerState tracer_state_;
|
TracerState tracer_state_;
|
||||||
TracerMotionCmd current_motion_cmd_;
|
TracerMotionCmd current_motion_cmd_;
|
||||||
TracerLightCmd current_light_cmd_;
|
|
||||||
|
|
||||||
bool light_ctrl_enabled_ = false;
|
bool light_ctrl_enabled_ = false;
|
||||||
bool light_ctrl_requested_ = false;
|
bool light_ctrl_requested_ = false;
|
||||||
|
|||||||
@@ -75,19 +75,14 @@ struct TracerLightCmd {
|
|||||||
};
|
};
|
||||||
|
|
||||||
TracerLightCmd() = default;
|
TracerLightCmd() = default;
|
||||||
TracerLightCmd(LightMode f_mode, uint8_t f_value, LightMode r_mode,
|
TracerLightCmd(LightMode f_mode, uint8_t f_value)
|
||||||
uint8_t r_value)
|
: enable_ctrl(true), front_mode(f_mode), front_custom_value(f_value) {}
|
||||||
: enable_ctrl(true),
|
|
||||||
front_mode(f_mode),
|
|
||||||
front_custom_value(f_value),
|
|
||||||
rear_mode(r_mode),
|
|
||||||
rear_custom_value(r_value) {}
|
|
||||||
|
|
||||||
bool enable_ctrl = false;
|
bool enable_ctrl = false;
|
||||||
LightMode front_mode;
|
LightMode front_mode;
|
||||||
uint8_t front_custom_value;
|
uint8_t front_custom_value;
|
||||||
LightMode rear_mode;
|
LightMode rear_mode = LightMode::CONST_OFF;
|
||||||
uint8_t rear_custom_value;
|
uint8_t rear_custom_value = 0;
|
||||||
};
|
};
|
||||||
} // namespace westonrobot
|
} // namespace westonrobot
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user