mirror of
https://github.com/BotChain-Robots/control.git
synced 2026-03-10 00:32:26 +01:00
Add distance sensor and display
This commit is contained in:
@@ -24,7 +24,11 @@ struct current_text {
|
||||
std::string text;
|
||||
};
|
||||
|
||||
typedef std::variant<target_angle, current_angle, current_text> sensor_value;
|
||||
struct distance {
|
||||
float distance;
|
||||
};
|
||||
|
||||
typedef std::variant<target_angle, current_angle, current_text, distance> sensor_value;
|
||||
|
||||
class SensorMessageBuilder {
|
||||
public:
|
||||
@@ -51,6 +55,10 @@ class SensorMessageBuilder {
|
||||
static_cast<const Messaging::CurrentText *>(value);
|
||||
return current_text{current->value()->str()};
|
||||
}
|
||||
case Messaging::SensorValue_Distance: {
|
||||
const Messaging::Distance *current = static_cast<const Messaging::Distance *>(value);
|
||||
return distance{current->value()};
|
||||
}
|
||||
default:
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user