Skip to content
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

Flutter controller v2 #464

Open
wants to merge 75 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
d21727f
creating flutter project working both ios and android
sparsh3dwe Dec 15, 2022
58a15e5
creating main page
sparsh3dwe Dec 16, 2022
6f3910c
completed ui of controller application
Dec 20, 2022
8848506
add onpress on main screen
Dec 20, 2022
d73af10
controller arrow icon styling change
Dec 20, 2022
bff1a8b
added function to accelerator in Drive by tilting by phone
nitishpratap18 Dec 20, 2022
6770e7d
mergin drive by tilting mode
nitishpratap18 Dec 20, 2022
fb08558
set slider value -1 to 1
Dec 21, 2022
693b02d
added log to client and create client new global variable
nitishpratap18 Dec 21, 2022
31f7eef
change client socket variables
Dec 21, 2022
6e38930
made filter function for data send to openBot
nitishpratap18 Dec 22, 2022
c8ec7d8
fixed zitter in Drive by tilting mode
nitishpratap18 Dec 22, 2022
bb67529
set slider value, slider cmd send to client, indicator and switch com…
Dec 22, 2022
c659248
indicator button blink when indicator on
Dec 23, 2022
612627d
set accelerometer value in tilt phone mode
Dec 23, 2022
5bbfdc6
set ui of forward and reverse button in tilting phone mode
Dec 26, 2022
1c26545
change socket service name
Dec 26, 2022
d1803fe
set ui of select controller shadow
Dec 26, 2022
e1583d8
send command to openBot App issue solved
Dec 29, 2022
c31e298
Merge branch 'isl-org:master' into flutter-controller
sparsh3dwe Jan 3, 2023
97f2f79
videoViewWebRTC
Jan 5, 2023
1ee4862
peer connection successful
Jan 6, 2023
698c4f4
video rendering done in webrtc
Jan 10, 2023
d888130
video view set on controll selector in fit to full screen
Jan 12, 2023
c268240
video view is set on all screen
Jan 12, 2023
0266ce0
implement change mirror view, add toast message, disable back button,…
Jan 12, 2023
65715fc
update service name
Jan 13, 2023
3ef8a56
updating readme file and updating command on drive mode
sparsh3dwe Jan 13, 2023
2bfa9ff
removing extra logs and adding screenshots
sparsh3dwe Jan 13, 2023
37c42eb
reformatting code
sparsh3dwe Jan 13, 2023
2513726
removing extra code
sparsh3dwe Jan 13, 2023
be7202a
removing warnings and extra code
sparsh3dwe Jan 13, 2023
aedeaa9
creating constants to store common msgs and renaming some files
sparsh3dwe Jan 13, 2023
19bb952
add toast message for RTSP video server
Jan 14, 2023
eeada17
renaming file import
sparsh3dwe Jan 20, 2023
f3e1392
renaming app ids
sparsh3dwe Jan 20, 2023
ff3a8d8
remove unnecessary logs and upgrade java 11
Jan 23, 2023
51926c6
upgrade java version
Jan 23, 2023
6f032d3
remove logs
Jan 23, 2023
5b42b2e
Merge branch 'isl-org:master' into flutter-controller
sparsh3dwe Feb 16, 2023
cedb9b2
formatting
sparsh3dwe Feb 16, 2023
bd1bc50
Merge branch 'isl-org:master' into flutter-controller
sparsh3dwe Feb 24, 2023
99c826a
Merge branch 'isl-org:master' into flutter-controller
sparsh3dwe Mar 3, 2023
1df61f3
Merge branch 'isl-org:master' into flutter-controller
sparsh3dwe Mar 5, 2023
1fd9cb4
Merge branch 'isl-org:master' into flutter-controller
sparsh3dwe Apr 3, 2023
b703732
Merge branch 'isl-org:master' into flutter-controller
sparsh3dwe Apr 7, 2023
3d691ea
Merge branch 'isl-org:master' into flutter-controller
sparsh3dwe Apr 9, 2023
db27790
upgrade webrtc library
Jun 17, 2023
5592fa2
get server of openBot and set drop down button in control selector sc…
Jun 20, 2023
03a66c5
set server name in drop down button and send server name to openBot o…
Jun 20, 2023
12e156a
server choose using openBot controller app in autopilot fragment
Jun 21, 2023
ae67b00
fixed ios data channeling issue
Dec 5, 2023
9ef8ced
Merge branch 'master' into flutter-controller
Dec 5, 2023
5112d9c
updated readme file
Eashika2504 Dec 6, 2023
3c00613
fixed errors in readme file
Eashika2504 Dec 11, 2023
1139b02
updated readme file
Eashika2504 Dec 11, 2023
b1197a9
added flutter dependecy in gitignore
Dec 11, 2023
181b6a2
updated gitignore
Dec 11, 2023
d42e985
removing .run
Dec 11, 2023
f828588
updated readme file
Eashika2504 Dec 11, 2023
2815682
added space b/w bullet points
Eashika2504 Dec 11, 2023
b3c8e37
changed indicators info alignment in readme
Eashika2504 Dec 11, 2023
736c2f9
fixed mute functionality on drive screen
Dec 12, 2023
0d6c562
changed UI for flutter controller settings
Dec 20, 2023
d5936f7
fixed drawer UI and added relevant settings
Dec 21, 2023
39c3295
added logs and network icon in on-screen control mode
Dec 28, 2023
2405ea9
fix state updation of fragment type
Dec 29, 2023
43b42c3
updated UI in tilting phone mode screen
Dec 30, 2023
08fd64a
integrate socket for fragment type
Eashika2504 Jan 1, 2024
5b88355
update change color switch button
Surajitinker Mar 21, 2024
0a65d7e
Merge branch 'master' of https://github.com/3dwesupport/OpenBot into …
isha382 Nov 22, 2024
b734c2b
updated kotlin version
isha382 Nov 25, 2024
236941c
updated readme and version
isha382 Nov 25, 2024
880aa6d
Updated README.md
isha382 Nov 25, 2024
e790567
fix minor changes
isha382 Nov 25, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -589,4 +589,3 @@ private void disconnectPhoneController() {
binding.controllerContainer.driveMode.setAlpha(1.0f);
}
}

Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.openbot.env;

import android.app.Fragment;
import android.content.Context;
import android.content.SharedPreferences;
import com.google.common.reflect.TypeToken;
Expand Down Expand Up @@ -43,6 +44,9 @@ public class SharedPreferencesManager {
private static final String DELAY = "DELAY";
private static final String PROJECTS_LIST = "PROJECTS_LIST";

private static final String FRAGMENT_TYPE = "FRAGMENT_TYPE";


private final SharedPreferences preferences;

public SharedPreferencesManager(Context context) {
Expand All @@ -51,6 +55,11 @@ public SharedPreferencesManager(Context context) {
.getApplicationContext()
.getSharedPreferences(PREFERENCES_NAME, Context.MODE_PRIVATE);
}
public String getFragment(){return preferences.getString(FRAGMENT_TYPE, "" );}
public void setFragment(String fragment)
{
preferences.edit().putString(FRAGMENT_TYPE, fragment).apply();
}

public int getBaudrate() {
return preferences.getInt(BAUD_RATE, DEFAULT_BAUD_RATE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ public void startClient() {
@Override
public void sendServerUrl() {
BotToControllerEventBus.emitEvent(ConnectionUtils.createStatus("VIDEO_SERVER_URL", ""));
BotToControllerEventBus.emitEvent(ConnectionUtils.createFragment(""));
}

@Override
Expand Down Expand Up @@ -369,7 +370,6 @@ public void onTrack(RtpTransceiver transceiver) {}

return factory.createPeerConnection(rtcConfig, pcConstraints, pcObserver);
}

private void sendMessage(JSONObject message) {
BotToControllerEventBus.emitEvent(ConnectionUtils.createStatus("WEB_RTC_EVENT", message));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ public View onCreateView(
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
preferencesManager.setFragment(Enums.fragmentType.DATACOLLECTION.getFragment());
BotToControllerEventBus.emitEvent(ConnectionUtils.createFragment(preferencesManager.getFragment()));
binding.controllerContainer.speedInfo.setText(getString(R.string.speedInfo, "---,---"));

intentSensorService = new Intent(requireActivity(), SensorService.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,14 @@
import org.openbot.common.CameraFragment;
import org.openbot.databinding.FragmentObjectNavBinding;
import org.openbot.env.BorderedText;
import org.openbot.env.BotToControllerEventBus;
import org.openbot.env.ImageUtils;
import org.openbot.tflite.Detector;
import org.openbot.tflite.Model;
import org.openbot.tflite.Network;
import org.openbot.tracking.MultiBoxTracker;
import org.openbot.utils.CameraUtils;
import org.openbot.utils.ConnectionUtils;
import org.openbot.utils.Constants;
import org.openbot.utils.Enums;
import org.openbot.utils.MovingAverage;
Expand Down Expand Up @@ -97,9 +99,9 @@ public View onCreateView(
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);

preferencesManager.setFragment(Enums.fragmentType.OBJECTDETECTION.getFragment());
BotToControllerEventBus.emitEvent(ConnectionUtils.createFragment(preferencesManager.getFragment()));
binding.confidenceValue.setText((int) (MINIMUM_CONFIDENCE_TF_OD_API * 100) + "%");

binding.plusConfidence.setOnClickListener(
v -> {
String trimConfValue = binding.confidenceValue.getText().toString().trim();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
import org.openbot.R;
import org.openbot.common.ControlsFragment;
import org.openbot.databinding.FragmentFreeRoamBinding;
import org.openbot.env.BotToControllerEventBus;
import org.openbot.env.PhoneController;
import org.openbot.utils.ConnectionUtils;
import org.openbot.utils.Constants;
import org.openbot.utils.Enums;
import org.openbot.utils.PermissionUtils;
Expand All @@ -45,6 +47,10 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat

phoneController = PhoneController.getInstance(requireContext());

preferencesManager.setFragment(Enums.fragmentType.FREEROAM.getFragment());

BotToControllerEventBus.emitEvent(ConnectionUtils.createFragment(preferencesManager.getFragment()));

binding.voltageInfo.setText(getString(R.string.voltageInfo, "--.-"));
binding.controllerContainer.speedInfo.setText(getString(R.string.speedInfo, "---,---"));
binding.sonarInfo.setText(getString(R.string.distanceInfo, "---"));
Expand Down
10 changes: 10 additions & 0 deletions android/robot/src/main/java/org/openbot/utils/ConnectionUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public static JSONObject createStatus(String name, String value) {
return new JSONObject();
}


public static JSONObject createStatus(String name, JSONObject value) {
try {
return new JSONObject().put("status", new JSONObject().put(name, value.toString()));
Expand All @@ -33,6 +34,15 @@ public static JSONObject createStatus(String name, JSONObject value) {
return new JSONObject();
}

public static JSONObject createFragment(String value){
try {
return new JSONObject().put("FRAGMENT_TYPE", value);
} catch (JSONException e) {
e.printStackTrace();
}
return new JSONObject();
}

public static JSONObject getStatus(
boolean loggingEnabled,
boolean noiseEnabled,
Expand Down
10 changes: 10 additions & 0 deletions android/robot/src/main/java/org/openbot/utils/Enums.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,16 @@ public String getSensor() {
}
}

public enum fragmentType{
AUTOPILOT("Autopilot"),
OBJECTDETECTION("ObjectDetection"),
DATACOLLECTION("DataCollection"),
FREEROAM("FreeRoam");
private String fragmentType;
fragmentType(String fragmentType) {this.fragmentType=fragmentType;}
public String getFragment() {return fragmentType;}
}

public enum LogMode {
ALL_IMGS(0),
CROP_IMG(1),
Expand Down
26 changes: 20 additions & 6 deletions controller/flutter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

This Controller app serves as a `remote controller` for the [OpenBot](https://www.openbot.org) vehicle similar as a BT controller (e.g. PS3/4 or Xbox). It runs on another Android/iOS device and supports live video/audio streaming in addition to control.

## Getting Started
## Getting Started
Begin by installing [Flutter](https://flutter.dev/) on your system. Choose the appropriate download for your operating system, which includes options for Windows, macOS, Linux, and ChromeOS. Follow the official Flutter installation guide for detailed instructions: [Flutter Installation Guide](https://docs.flutter.dev/get-started/install)

### Using Terminal
Expand All @@ -22,16 +22,16 @@ Begin by installing [Flutter](https://flutter.dev/) on your system. Choose the a
```bash
flutter pub get
```
Run the project:
Run the project:
```bash
flutter run
```
If you encounter any issues, run the following command:
If you encounter any issues, run the following command:
```bash
flutter doctor
```
### Using Editor
- Follow the official Flutter guide for setting up an editor: [Set up an editor ](https://docs.flutter.dev/tools/android-studio)
- Follow the official Flutter guide for setting up an editor: [Set up an editor ](https://docs.flutter.dev/tools/android-studio)
- Ensure that your editor is configured for Flutter development. Install any required plugins or extensions, following the editor-specific instructions in the Flutter documentation for the best development experience.

- Once you open your project in the editor after the setup, it will appear as shown in the following image.
Expand All @@ -46,7 +46,7 @@ Begin by installing [Flutter](https://flutter.dev/) on your system. Choose the a
<img src="../../docs/images/run_editor.jpg" width="50%" />
</p>

## Connection
## Connection

When the controller app is started, it immediately tries to connect to the robot and shows the following screen:

Expand Down Expand Up @@ -89,7 +89,7 @@ above/below the center of the slider.

- ``Switch Camera``: switch between the front and back camera modes.
- ``Mute``: enable/disable audio transmission.
- ``Mirror view``: mirror the the video feed.
- ``Mirror view``: mirror the the video feed.

### Tilt to drive

Expand All @@ -112,4 +112,18 @@ Use the `accelerator` and `brake` buttons to move forward/backward.
robot will come to a stop.
- The robot is steered by tilting the controller phone left or right.

### Controller Settings UI

Here is a picture of the `Controller Settings` screen:

- Controller Selection: Switch between different controller types (e.g., mobile, joystick) using the provided icons.

- Server: Displays the current server status with a dropdown to select or change the server.

- Noise Toggle : Enable or disable noise simulation through the toggle switch.

<p float="left">
<img src="../../docs/images/flutter_controller_setting.jpg" width="50%" />
</p>

Here is a [Technical Overview](../../docs/technical/OpenBotController.pdf) of the controller app.
2 changes: 1 addition & 1 deletion controller/flutter/android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
buildscript {
ext.kotlin_version = '1.6.10'
ext.kotlin_version = '1.7.0'
repositories {
google()
mavenCentral()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@

You can customize the launch screen with your own desired assets by replacing the image files in this directory.

You can also do it by opening your Flutter project's Xcode project with `open ios/Runner.xcworkspace`, selecting `Runner/Assets.xcassets` in the Project Navigator and dropping in the desired images.
You can also do it by opening your Flutter project's Xcode project with `open ios/Runner.xcworkspace`, selecting `Runner/Assets.xcassets` in the Project Navigator and dropping in the desired images.
52 changes: 51 additions & 1 deletion controller/flutter/lib/screens/component/onScreenIcon.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,17 @@ import 'package:flutter/material.dart';
import 'package:flutter_webrtc/flutter_webrtc.dart';
import 'package:openbot_controller/buttonCommands/buttonCommands.dart';
import 'package:openbot_controller/screens/component/blinkingButton.dart';
import 'package:openbot_controller/globals.dart';

class OnScreenIcon extends StatefulWidget {
final dynamic updateMirrorView;
final bool indicatorLeft;
final bool indicatorRight;
final RTCPeerConnection? peerConnection;
final String fragmentType;

const OnScreenIcon(this.updateMirrorView, this.indicatorLeft,
this.indicatorRight, this.peerConnection,
this.indicatorRight, this.peerConnection, this.fragmentType,
{super.key});

@override
Expand All @@ -24,13 +26,15 @@ class OnScreenIconState extends State<OnScreenIcon> {
bool speaker = false;
bool leftIndicator = false;
bool rightIndicator = false;
String typeOfFragment = "";

@override
void didUpdateWidget(covariant OnScreenIcon oldWidget) {
// TODO: implement didUpdateWidget
setState(() {
leftIndicator = widget.indicatorLeft;
rightIndicator = widget.indicatorRight;
typeOfFragment = widget.fragmentType;
});
super.didUpdateWidget(oldWidget);
}
Expand Down Expand Up @@ -186,6 +190,52 @@ class OnScreenIconState extends State<OnScreenIcon> {
width: 23,
),
)),
const SizedBox(
width: 15,
),
GestureDetector(
onTap: () {
if (typeOfFragment == "DataCollection") {
clientSocket?.writeln("{command: LOGS}");
}
}, // Image tapped
child: Container(
padding: const EdgeInsets.all(15),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(45),
color: typeOfFragment == "DataCollection"
? Colors.white.withOpacity(0.5)
: Colors.grey.withOpacity(0.5),
),
child: const Icon(
Icons.file_present,
color: Colors.blue,
),
)),
const SizedBox(
width: 15,
),
GestureDetector(
onTap: () {
if (typeOfFragment == "Autopilot" ||
typeOfFragment == "ObjectDetection") {
clientSocket?.writeln("{command: NETWORK}");
}
}, // Image tapped
child: Container(
padding: const EdgeInsets.all(15),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(45),
color: typeOfFragment == "Autopilot" ||
typeOfFragment == "ObjectDetection"
? Colors.white.withOpacity(0.5)
: Colors.grey.withOpacity(0.5),
),
child: const Icon(
Icons.network_check,
color: Colors.blue,
),
)),
],
),
);
Expand Down
Loading
Loading