Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F74212882
Cellulo.dart
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Fri, Jul 26, 12:20
Size
4 KB
Mime Type
text/x-c++
Expires
Sun, Jul 28, 12:20 (2 d)
Engine
blob
Format
Raw Data
Handle
19356594
Attached To
R10646 Orchestration
Cellulo.dart
View Options
import 'dart:async';
import 'dart:ffi'; // For FFI
import 'dart:io'; // For Platform.isX
Cellulo cellulox = new Cellulo(0);
Cellulo celluloy = new Cellulo(1);
class Cellulo {
int robotID = 0;
bool colorset = false;
bool velocityset = false;
static var robots = [];
int robot = -1;
Cellulo(this.robotID);
setup() async {
print(totalRobots());
// print("thisis the current robot" + _robot.toString());
// robot = _robot;
for (var i = 0; i < totalRobots(); i++) {
int _robot = newRobotfromPool();
robots.add(_robot);
}
print(robots);
}
void setColor() async {
print(robots[robotID]);
setVisualEffect(robots[robotID], 120, 0, 0, 0, 0);
}
void resetrobot() async {
reset(robots[robotID]);
}
Future<double> getrobotx() async {
//print(robots[robotID]);
return getX(robots[robotID]);
}
Future<double> getroboty() async {
//print(robots[robotID]);
return getY(robots[robotID]);
}
Future<double> getrobottetha() async {
//print(robots[robotID]);
return getTheta(robots[robotID]);
}
Future<int> getrobotKidnapped() async {
//print(robots[robotID]);
return getKidnapped(robots[robotID]);
}
Future<Null> setVelocity() async {
setGoalVelocity(robots[robotID], 100, 0, 0);
}
Future<Null> setGoalPosition(double x, double y) async {
setGoalPose(robots[robotID], x, y, 0, 150, 150);
}
}
final DynamicLibrary nativeAddLib = Platform.isAndroid
? DynamicLibrary.open("libnative_add.so")
: DynamicLibrary.process();
final DynamicLibrary nativeCellulolib = Platform.isAndroid
? DynamicLibrary.open("libcellulo-library.so")
: DynamicLibrary.process();
final int Function(int x, int y) nativeAdd = nativeAddLib
.lookup<NativeFunction<Int32 Function(Int32, Int32)>>("native_add")
.asFunction();
final int Function(int x, int y) nativeAddCellulo = nativeCellulolib
.lookup<NativeFunction<Int32 Function(Int32, Int32)>>("test_native_add")
.asFunction();
final int Function() initialize = nativeCellulolib
.lookup<NativeFunction<Int32 Function()>>("initialize")
.asFunction();
final void Function(int robot) reset = nativeCellulolib
.lookup<NativeFunction<Void Function(Int64 robot)>>("reset")
.asFunction();
final int Function() newRobotfromPool = nativeCellulolib
.lookup<NativeFunction<Int64 Function()>>("newRobotFromPool")
.asFunction();
final void Function() destroyRobot = nativeCellulolib
.lookup<NativeFunction<Void Function()>>("destroyRobot")
.asFunction();
final void Function(int robot, int effect, int r, int g, int b, int value)
setVisualEffect = nativeCellulolib
.lookup<
NativeFunction<
Void Function(Int64 robot, Int64 effect, Int64 r, Int64 g,
Int64 b, Int64 value)>>("setVisualEffect")
.asFunction();
//setGoalVelocity(int64_t robot, float vx, float vy, float w)
final void Function(int robot, double vx, double vy, double w) setGoalVelocity =
nativeCellulolib
.lookup<
NativeFunction<
Void Function(Int64 robot, Float vx, Float vy,
Float w)>>("setGoalVelocity")
.asFunction();
final void Function(
int robot, double x, double y, double theta, double v, double w)
setGoalPose = nativeCellulolib
.lookup<
NativeFunction<
Void Function(Int64 robot, Float x, Float y, Float theta,
Float v, Float w)>>("setGoalPose")
.asFunction();
final int Function() totalRobots = nativeCellulolib
.lookup<NativeFunction<Int64 Function()>>("totalRobots")
.asFunction();
final double Function(int robot) getX = nativeCellulolib
.lookup<NativeFunction<Float Function(Int64 robot)>>("getX")
.asFunction();
final double Function(int robot) getY = nativeCellulolib
.lookup<NativeFunction<Float Function(Int64 robot)>>("getY")
.asFunction();
final double Function(int robot) getTheta = nativeCellulolib
.lookup<NativeFunction<Float Function(Int64 robot)>>("getTheta")
.asFunction();
final int Function(int robot) getKidnapped = nativeCellulolib
.lookup<NativeFunction<Int64 Function(Int64 robot)>>("getKidnapped")
.asFunction();
Event Timeline
Log In to Comment