Formula Student Autonomous Systems
The code for the main driverless system
Loading...
Searching...
No Matches
inspection_ros.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <message_filters/subscriber.h>
4#include <message_filters/sync_policies/approximate_time.h>
5#include <message_filters/synchronizer.h>
6#include <message_filters/time_synchronizer.h>
7
8#include <chrono>
9#include <cmath>
10#include <functional>
11#include <memory>
12#include <rclcpp/rclcpp.hpp>
13#include <std_srvs/srv/trigger.hpp>
14#include <string>
15
17#include "custom_interfaces/msg/control_command.hpp"
18#include "custom_interfaces/msg/operational_status.hpp"
19#include "custom_interfaces/msg/wheel_rpm.hpp"
21
29class InspectionMission : public rclcpp::Node {
30private:
31 rclcpp::Client<std_srvs::srv::Trigger>::SharedPtr _finish_client_;
32 rclcpp::Client<std_srvs::srv::Trigger>::SharedPtr _emergency_client_;
33 rclcpp::Publisher<custom_interfaces::msg::ControlCommand>::SharedPtr _control_command_publisher_;
34
35 rclcpp::Subscription<custom_interfaces::msg::OperationalStatus>::SharedPtr
37 rclcpp::Subscription<custom_interfaces::msg::WheelRPM>::SharedPtr _motor_rpm_subscription_;
38 rclcpp::TimerBase::SharedPtr _timer_;
39
40 // Not used now
41 using WSSPolicy =
42 message_filters::sync_policies::ApproximateTime<custom_interfaces::msg::WheelRPM,
43 custom_interfaces::msg::WheelRPM>;
44
45 std::shared_ptr<message_filters::Synchronizer<WSSPolicy>> _sync_;
46
47 rclcpp::TimerBase::SharedPtr
50 bool _car_stopped_ = false;
51 rclcpp::TimerBase::SharedPtr _main_callback_timer_;
52 rclcpp::Clock _clock_;
53 rclcpp::Time _initial_time_;
55
56 bool _go_ = false;
58
59 double _motor_rpm_ = 0.0;
60
65 void end_of_mission();
66
71 rclcpp::Client<std_srvs::srv::Trigger>::SharedFuture future) const;
72
73public:
79 void mission_decider(custom_interfaces::msg::OperationalStatus::SharedPtr mission_signal);
80
86 void inspection_script();
87
93 void update_rpms_callback(const custom_interfaces::msg::WheelRPM& motor_rpm);
94
101 void publish_controls(double throttle, double steering) const;
102
107};
Class responsible for the Inspection Mission of the car.
rclcpp::Subscription< custom_interfaces::msg::OperationalStatus >::SharedPtr _mission_signal_subscription_
rclcpp::Clock _clock_
Timer for main callback.
void publish_controls(double throttle, double steering) const
Publishes the control command.
void inspection_script()
Function to publish control command while time is less than the defined time limit.
rclcpp::Publisher< custom_interfaces::msg::ControlCommand >::SharedPtr _control_command_publisher_
void mission_decider(custom_interfaces::msg::OperationalStatus::SharedPtr mission_signal)
recieves GoSignal and stores the mission that should be ran
rclcpp::Subscription< custom_interfaces::msg::WheelRPM >::SharedPtr _motor_rpm_subscription_
std::shared_ptr< message_filters::Synchronizer< WSSPolicy > > _sync_
rclcpp::TimerBase::SharedPtr _mission_end_timer_
InspectionMission()
Contruct a new Inspection Mission with constants defined in file.
InspectionFunctions _inspection_object_
Ellapsed time in seconds.
void update_rpms_callback(const custom_interfaces::msg::WheelRPM &motor_rpm)
Function to update the current rpms of the wheels.
void end_of_mission()
Rotations per minute of the motor.
rclcpp::Client< std_srvs::srv::Trigger >::SharedPtr _emergency_client_
rclcpp::Client< std_srvs::srv::Trigger >::SharedPtr _finish_client_
double _motor_rpm_
Mission to be executed;.
rclcpp::TimerBase::SharedPtr _timer_
message_filters::sync_policies::ApproximateTime< custom_interfaces::msg::WheelRPM, custom_interfaces::msg::WheelRPM > WSSPolicy
void handle_end_of_mission_response(rclcpp::Client< std_srvs::srv::Trigger >::SharedFuture future) const
Function to end communication of end of mission.
rclcpp::TimerBase::SharedPtr _main_callback_timer_
common_lib::competition_logic::Mission _mission_
Flag to start the mission.
bool _mission_end_timer_started_
Timer for repetition of end of mission signal.
rclcpp::Time _initial_time_