Go to Post It’s possible to make friends without agreeing on everything. - Bill Gold [more]
Home
Go Back   Chief Delphi > Technical > Programming > C/C++
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
 
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 20-02-2012, 20:23
DavisC DavisC is offline
Registered User
FRC #0539 (Titans)
Team Role: College Student
 
Join Date: Jul 2011
Rookie Year: 2010
Location: Virginia
Posts: 200
DavisC is just really niceDavisC is just really niceDavisC is just really niceDavisC is just really nice
Any Actual Purpose to Safety Enabled?

Is there any true reason for having the part of code that is "myRobot.SetSafetyEnabled(true);" ?

Or is this pointless code? Cause in the Autonomous it is set to "false" by default.
__________________
FRC Team 539
Student Member: 2010 Breakaway - 2014 Aerial Assist
Mentor: 2015 Recycle Rush - present
Reply With Quote
  #2   Spotlight this post!  
Unread 20-02-2012, 22:37
rbmj rbmj is offline
Registered User
FRC #0612 (Chantilly Robotics)
Team Role: Alumni
 
Join Date: Apr 2011
Rookie Year: 2011
Location: DC Area/Fairfax County
Posts: 192
rbmj is a jewel in the roughrbmj is a jewel in the roughrbmj is a jewel in the rough
Re: Any Actual Purpose to Safety Enabled?

I think it's there for if you get stuck in an infinite loop and all your motors happen to be set at 100% power. Mostly to keep it from running into something if the code stops paying attention.

Sometimes though it can be a pain.
Reply With Quote
  #3   Spotlight this post!  
Unread 21-02-2012, 04:03
mikets's Avatar
mikets mikets is offline
Software Engineer
FRC #0492 (Titan Robotics)
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2008
Location: Bellevue, WA
Posts: 667
mikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of light
Re: Any Actual Purpose to Safety Enabled?

Quote:
Originally Posted by rbmj View Post
I think it's there for if you get stuck in an infinite loop and all your motors happen to be set at 100% power. Mostly to keep it from running into something if the code stops paying attention.

Sometimes though it can be a pain.
I used to think that too. But then I saw sample code such as SimpleRobot template that disables safety in Autonomous. So I asked myself, why did it do that? Thinking more about it, then I realize if you have buggy code, your buggy code can still cause the robot to run away with 100% power. You just call MyRobot.ArcadeDrive(1.0, 0.0) in an infinite loop that doesn't respond to anything else. By doing that, you will make the watchdog happy. So then what good is MotorSafety? There are only a couple reasons I can come up with.
1. Make sure your teleop code is "responsive" to the joystick control. In case you are processing something else, this will make sure you will read the joystick in a timely manner.
2. Make sure if you lose communication with your robot in TeleOp mode, it won't run away with the last joystick reading. Having said that, I was trying to confirm if the WPILib is doing anything else to guard against communication lost to "zero out the m_controlData structure but since there is no source code available for FrcComm.cpp, I can't say for sure.

Because of the above two reasons, it makes sense motor safety is more relevant to TeleOp mode than Autonomous. With that reasoning, is there a reason why we should still enable MotorSafety in Autonomous? We have been enabling it up till now. Like you said, it's a pain. In fact, we still can't explain why we still get some of those "Output not updated often enough" messages, even though our robot is very responsive to joystick and never stop working. We even had timing code put into the robot loop to tell us how long each loop takes and make sure it is nowhere near the limit of the SetExpiration period. But it is still happening occasionally. Recently, the MotorSafety cut off the RobotDrive motors saying we did not update it ofen enough but our "loop timing" code tells us that we did not exceed the Expiration period. It only happens when we "trigger" the vision processing code. But this is impossible because our vision processing code is in a separate task so it should not affect the main robot task. What is the vxwork time slice period anyway? Just in case that the vxwork time slice is long enough and preempt the main task frequent enough that our main robot loop exceeds the expiration period, we set it to 1 second to test the theory. It's still triggering the "watchdog". The interesting thing is that this doesn't happen all the time. We could have the code running perfectly for a while then all the sudden it started to happen with the watchdog. We are still trying to isolate the cause of this. I suspect it may have something to do with the camera task. Have anybody experienced similar scenario?
__________________
Reply With Quote
  #4   Spotlight this post!  
Unread 21-02-2012, 04:47
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,561
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
Another reason for the motor safety is to make sure that the robot doesn't run away if you are debugging and at a break point.
Reply With Quote
  #5   Spotlight this post!  
Unread 21-02-2012, 05:19
mikets's Avatar
mikets mikets is offline
Software Engineer
FRC #0492 (Titan Robotics)
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2008
Location: Bellevue, WA
Posts: 667
mikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of light
Re: Any Actual Purpose to Safety Enabled?

Quote:
Originally Posted by Joe Ross View Post
Another reason for the motor safety is to make sure that the robot doesn't run away if you are debugging and at a break point.
I am not familiar with the WindRiver debugger but my understanding is that debugger usually freezes all tasks when hitting a breakpoint. If not, it would be difficult to debug multi-tasking issues since other tasks keep running. If the other tasks are frozen, so is the task that checks the "watchdog". In other words, even if you have MotorSafety on, if you hit a breakpoint, the robot still runs away. The only real motor safety is if it is implemented in hardware.
__________________

Last edited by mikets : 21-02-2012 at 05:21.
Reply With Quote
  #6   Spotlight this post!  
Unread 21-02-2012, 07:56
Greg McKaskle Greg McKaskle is offline
Registered User
FRC #2468 (Team NI & Appreciate)
 
Join Date: Apr 2008
Rookie Year: 2008
Location: Austin, TX
Posts: 4,748
Greg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond repute
Re: Any Actual Purpose to Safety Enabled?

Ideally, you would write the autonomous code so that you wouldn't need to disable the safety update mechanism. But it is your robot, and you can disable it completely if you like.

The safety update is just a watchdog timer. If your code isn't in control of the robot, sending updates it could be something serious like a breakpoint, an infinite loop, an exception, or other serious issues. It could also be slow code, or code that doesn't care to update the speed -- not really a safety issue, but the code can't tell the difference.

If you are pretty sure that the code is safe, you may choose to turn off the safety. If you would instead like to put in loops to do updates, you don't need to turn it off.

As for the breakpoint issue. I believe the WR debugger can be set both ways. LV, leaves parallel tasks in other diagrams running, by the way, so the robot comms is still going, I/O still enabled. I don't know what the default is for WR. I don't know how Java behaves at a breakpoint.

So, the HW safety mechanism is triggered by a loss of comms, and tthe Safety config is another layer of safety specific to the SW updates.

Greg McKaskle
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 12:57.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi