-
Notifications
You must be signed in to change notification settings - Fork 592
Ivo/tilt control #205
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ivo/tilt control #205
Conversation
); | ||
} | ||
|
||
class KillSwitch { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you constantly sending some controls to make sure the bot does not get killed by mistake. For example if user drives at a constant speed, there may not be any new event for a while.
For the communication between robot and bot app, I have implemented a heartbeat (will make a PR soon). Basically every 250ms a heartbeat message will be sent from the phone to the bot. The bot will stop if there is some issue in the communication channel.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We send drive commands every 50 ms when the controller is active. The kill switch will trigger if it does not receive drive command in 500 ms.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When using sliders to drive, this is usually a non-issue, because the sliders revert back to zero. Using tilt control can leave the bot running after the controller has stopped sending commands. That is why I added this kill switch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok sounds good. I have tested everything and it looks good. The one thing is that it is a bit difficult to find the zero point again to stop the car. I was wondering if it makes sense to add a brake button to the screen. Maybe even do throttle control on the screen and only use accelerometer for steering. What are your thoughts on this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As for the kill switch, let's put in into a separate file since it is a class. Or is there a way to do this from the controller? I would prefer not to have this kill switch wrapper.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-
OK, I will remove the KillSwitch. It is a bit inefficient anyway. My original idea was to have this "Transmission" class wrapper, which can change the driving characteristics, and a killSwitch() being just one method. But I see your point, I will move it to another class and not use it. The only issue is a
runaway bot
. We send a stop command ondisconnect
, but if we change the controller type on the bot app, it will not get a disconnect event. Anyway, I will check this again. -
For the zero point, I think I have a
dead zone
which will send 0,0 if the control is near zero. I will check if this is still there, and maybe widen the range. There is also an option to stop the robot if you place the controller flat on the table at any time, which should work now. -
I will update the PR soon.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"I was wondering if it makes sense to add a brake button to the screen. Maybe even do throttle control on the screen and only use accelerometer for steering. What are your thoughts on this?"
Yes, I have seen this in other apps, like "Racing in a Car" app. If you think this is better, we can do this. Full "Zen" mode maybe a bit more difficult to drive.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess it's hard to know without trying. But I have also seen this in many car racing games. I guess it's easier to control only one axis via rotation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- I added
accelerator
andbreak
pedals to the tilt screen. These are implemented inAccelerator.kt
andBreak.kt
files. The icons are very basic, but if somebody can draw a better pedals, please go ahead and replace them. - In both if these files, there is a class called
DrivingCharacteristics
, which defines various parameters controlling responsiveness of the pedals. One can experiment with these to archive optimum driving experience.
Removed kill switch in the main app
I like the pedal. I think it would be more intuitive if the car speed decreases when releasing the accelerator. When pressing the brake, the car should instantly go 0 and then start driving backwards. This is not like a real car, but common in car racing games on the phone. |
android/controller/README.md
Outdated
<img src="../../docs/images/orientation_axis.png" width="50%" /> | ||
</p> | ||
|
||
Start with the controller in the up-right position in landscape mode. To move forward, increase the `roll` angle (rotate forward around the `Y` access). To turn left or right, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The documentation needs to be updated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be more intuitive if the car speed decreases when releasing the accelerator.
-
It is supposed to do this already. In the
Accelerator
class,decelerationTime
controls how long it takes to decelerate after releasing the pedal, andminSpeed
controls what is the final decelerated speed. Currently,decelerationTime
is set to 5 seconds, maybe this is too long. -
I will add ability to go backwards when pressing the break. I was thinking, we should start going backwords after some delay, say 2 seconds (I will add it as param to easily change it)
-
I will also update the documentation, just waited to finalise these.
from = 1, | ||
to = 10 | ||
) val stepsToFullStop: Int = 3, // in haw many steps to get to min speed after releasing the accelerator | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can experiment with these parameters to taste. Same as in Break.kt
file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Yes, the delay before going backwards makes sense.
- Brake pedal can put the robot in reverse - Updated the README file.
The |
…nificant change to the command. - Rename EventProcessor class to LocalEventBus for clarity.
I'll just update the image with a compressed jpeg. |
Ivo/tilt control
Uh oh!
There was an error while loading. Please reload this page.