@@ -168,6 +168,24 @@ void RC_Controls::setSubscriber(ros::NodeHandle& n) {
168168 stamp = ros::Time::now ();
169169}
170170
171+ bool RC_Controls::setEngagedState () {
172+ if (throttle > ENGAGED_THRESHOLD && pitch > ENGAGED_THRESHOLD)
173+ {
174+ if (yaw > ENGAGED_THRESHOLD && roll < -ENGAGED_THRESHOLD)
175+ {
176+ ROS_INFO (" >>>>>>>> RC_CONTROL SPECIAL FUNCTION ENGAGED <<<<<<<<<<" );
177+ user_function_engaged = true ;
178+ }
179+ else if (yaw < -ENGAGED_THRESHOLD && roll > ENGAGED_THRESHOLD)
180+ {
181+ ROS_INFO (" <<<<<<<<<< RC_CONTROL SPECIAL FUNCTION DISENGAGED >>>>>>>>>>" );
182+ user_function_engaged = false ;
183+ }
184+ }
185+
186+ return user_function_engaged;
187+ }
188+
171189// ===================================================
172190// DJI specific RC stuff
173191// ===================================================
@@ -198,6 +216,9 @@ void RC_Controls::setDJIControls(const sensor_msgs::Joy::ConstPtr& msg) {
198216
199217 setDJIModeSwitch (mode_, mode);
200218 setDJIGearSwitch (gear_, gear);
219+
220+ setEngagedState ();
221+
201222// printf("XXX RC: roll[%0.2f], pitch[%0.2f], yaw[%0.2f], throttle[%0.2f], gear[%0.2f], mode[%0.2f]\n",
202223// roll_, pitch_, yaw_, throttle_, gear_, mode_);
203224}
@@ -290,8 +311,10 @@ void RC_Controls::setLogitechControls(const sensor_msgs::Joy::ConstPtr& msg) {
290311 setLogitechStickValue (roll_, roll);
291312 setLogitechStickValue (throttle_, throttle);
292313
293- ROS_INFO_THROTTLE (1.0 , " XXX RC: roll[%0.2f], pitch[%0.2f], yaw[%0.2f], throttle[%0.2f], gear[%0.2f], mode[%0.2f]\n " ,
294- roll_, pitch_, yaw_, throttle_, gear_, mode_);
314+ setEngagedState ();
315+
316+ ROS_INFO_THROTTLE (1.0 , " XXX RC: roll[%0.2f], pitch[%0.2f], yaw[%0.2f], throttle[%0.2f], gear[%0.2f], mode[%0.2f], engaged[%d]\n " ,
317+ roll_, pitch_, yaw_, throttle_, gear_, mode_, user_function_engaged);
295318}
296319
297320bool RC_Controls::setLogitechModeSwitch (double mode_switch, RC_MODE& state) {
@@ -347,6 +370,9 @@ void RC_Controls::setPX4Controls(const mavros_msgs::RCIn::ConstPtr& msg) {
347370 setPX4ModeSwitch (mode_, mode);
348371 setPX4GearSwitch (gear_, gear);
349372 setPX4ArmSwitch (armed_, armed_switch);
373+
374+ setEngagedState ();
375+
350376 // ROS_INFO_THROTTLE(2, "XXX RC: roll[%0.2f], pitch[%0.2f], yaw[%0.2f], throttle[%0.2f], gear[%d], mode[%d] armed[%d]\n",
351377 // roll, pitch, yaw, throttle, static_cast<int>(gear), static_cast<int>(mode), armed_switch);
352378}
0 commit comments