The Proc logic of the component, which called by the CyberRT frame.
70 {
71 int8_t revent = 0;
72 struct pollfd fd = {STDIN_FILENO, POLLIN, revent};
73 switch (poll(&fd, 1, 100)) {
74 case -1:
75 std::cout << "Failed to read keyboard" << std::endl;
76 return false;
77 case 0:
78 return true;
79 default:
80 char data[50];
81 std::cin.getline(data, 50);
82 std::string input_command_string = data;
83 if (input_command_string == "pull_over") {
84
85 SendActionCommand(
87 } else if (input_command_string == "stop") {
88
90 } else if (input_command_string == "start") {
91
93 } else if (input_command_string == "clear") {
94
95 SendActionCommand(
97 } else if (input_command_string == "manual") {
98
99 SendActionCommand(
101 } else if (input_command_string == "auto") {
102
103 SendActionCommand(
105 } else if (input_command_string == "vin") {
106
108 } else if (input_command_string == "enter_mission") {
109
110 SendActionCommand(
112 } else if (input_command_string == "exit_mission") {
113
114 SendActionCommand(
116 } else if (input_command_string == "chassis") {
117 SendVehicleSignalCommand();
118 } else if (input_command_string == "custom_chassis") {
119 SendCustomChassisCommand();
120 } else if (input_command_string.find("set_speed") != std::string::npos) {
121 auto index = input_command_string.find("set_speed");
122 std::string speed_value_string = input_command_string.substr(
123 index + std::string("set_speed").length(),
124 input_command_string.length());
125 if (!speed_value_string.empty()) {
126 double speed_value = std::atof(speed_value_string.c_str());
127 SendSpeedCommand(speed_value);
128 } else {
129 AWARN <<
"Input format is invalid, please input format like: "
130 "set_speed 1.5";
131 }
132 } else if (input_command_string == "increase_speed") {
133 double speed_factor = 1.2;
134 SendSpeedFactorCommand(speed_factor);
135 } else if (input_command_string == "decrease_speed") {
136 double speed_factor = 0.8;
137 SendSpeedFactorCommand(speed_factor);
138 } else if (input_command_string == "restore_speed") {
139 RestoreSpeed();
140 } else if (input_command_string == "lane") {
141
143 way_point.set_x(0.0);
144 way_point.set_y(0.0);
145 way_point.set_heading(0.0);
146 std::vector<apollo::external_command::Pose> way_points;
147 way_points.emplace_back(way_point);
149 end_pose.set_x(10.0);
150 end_pose.set_y(0.0);
151 end_pose.set_heading(0.0);
152 SendLaneFollowCommand(way_points, end_pose,
154 } else if (input_command_string == "path_loc") {
155 SendPathFollowCommandWithLocationRecord(
157 } else if (input_command_string == "path_path") {
158 SendPathFollowCommandWithPathRecord(
160 } else if (input_command_string == "valet_parking") {
161 std::string parking_spot_id = "451089045";
162 SendValetParkingCommand(parking_spot_id, demo_config_.
target_speed());
163 } else if (input_command_string.find("command_status") !=
164 std::string::npos) {
165
166
167 const size_t start_pos = std::string("command_status=").length();
168 const size_t end_pos = input_command_string.length();
169 if (end_pos <= start_pos) {
170 std::cout
171 << "Please check command status with format: command_status=XX!"
172 << std::endl;
173 break;
174 }
175 std::string command_id_string =
176 input_command_string.substr(start_pos, end_pos);
177 command_id_string.erase(
178 std::remove_if(command_id_string.begin(), command_id_string.end(),
179 ::isspace),
180 command_id_string.end());
181 uint64_t id = std::atoi(command_id_string.c_str());
182 CheckCommandStatus(id);
183 } else if (input_command_string == "free1") {
188 std::vector<apollo::external_command::Point> way_points;
193 point1.set_x(demo_config_.
point1_x());
194 point1.set_y(demo_config_.
point1_y());
195 point2.set_x(demo_config_.
point2_x());
196 point2.set_y(demo_config_.
point2_y());
197 point3.set_x(demo_config_.
point3_x());
198 point3.set_y(demo_config_.
point3_y());
199 point4.set_x(demo_config_.
point4_x());
200 point4.set_y(demo_config_.
point4_y());
201 way_points.emplace_back(point1);
202 way_points.emplace_back(point2);
203 way_points.emplace_back(point3);
204 way_points.emplace_back(point4);
205
206 SendFreespaceCommand(way_points, end_pose);
207 } else if (input_command_string == "zone_cover") {
208 std::string overlap_id = demo_config_.
overlap_id();
209 SendZoneCoverCommand(overlap_id);
210 } else {
211 std::cout << "Invalid input!" << input_command_string << std::endl;
212 }
213 }
214 return true;
215}
optional string overlap_id
optional double end_pose_y
optional string file_of_path_follow_with_planning_record
optional string file_of_path_follow_with_localization_record
optional double end_pose_heading
optional double target_speed
optional double end_pose_x