Skip to content

Conversation

izivkov
Copy link
Contributor

@izivkov izivkov commented Jul 9, 2021

  • Can now drive by just tilting the controller. See updated README file in the controller directory.
  • Selections on the controller for sound and image mirroring are automatically persisted on the bot app. so they are preserved across app restarts and switching controller device.
  • Added a kill switch to stop bot if does not receive drive commands within 1/2 second.
  • Updated the README file.

);
}

class KillSwitch {
Copy link
Collaborator

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

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.

Copy link
Collaborator

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?

Copy link
Collaborator

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.

Copy link
Contributor Author

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 on disconnect, 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.

Copy link
Contributor Author

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.

Copy link
Collaborator

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.

Copy link
Contributor Author

@izivkov izivkov Jul 21, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • I added accelerator and break pedals to the tilt screen. These are implemented in Accelerator.kt and Break.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.

@thias15
Copy link
Collaborator

thias15 commented Jul 22, 2021

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.

<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,
Copy link
Collaborator

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.

Copy link
Contributor Author

@izivkov izivkov left a 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, and minSpeed 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
)
Copy link
Contributor Author

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.

Copy link
Collaborator

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.
@izivkov
Copy link
Contributor Author

izivkov commented Jul 26, 2021

The brake and accelerator pedals could be better looking. I spent quite a lot of time on these, originally rotating one pedal 90 degrees to use of the other pedal. This created some problem where the rotated pedal disappeared after a while. If somebody wants to make a better pedal icons, please go ahead.

@thias15
Copy link
Collaborator

thias15 commented Aug 16, 2021

I'll just update the image with a compressed jpeg.

@thias15 thias15 merged commit 3e8f2bf into ob-f:master Aug 16, 2021
lacykaltgr pushed a commit to satinavrobotics/SatiBot that referenced this pull request Jun 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants