Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F61700792
cellulounity.cpp
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
Wed, May 8, 10:25
Size
2 KB
Mime Type
text/x-c
Expires
Fri, May 10, 10:25 (2 d)
Engine
blob
Format
Raw Data
Handle
17546820
Attached To
R9807 cellulo-lua
cellulounity.cpp
View Options
#include "cellulounity.h"
#include "cellulothread.h"
#include "cellulorobotwrapper.h"
#include "democlass.h"
#include <QDebug>
CelluloThread
*
thread
=
nullptr
;
DemoClass
*
obj
=
nullptr
;
int
nRobots
=
0
;
const
int
MAXROBOTS
=
100
;
CelluloRobotWrapper
*
robots
[
MAXROBOTS
];
void
demoPrint
()
{
if
(
thread
==
nullptr
)
{
thread
=
new
CelluloThread
;
thread
->
start
();
obj
=
new
DemoClass
;
qDebug
()
<<
"Move to thread..."
;
obj
->
moveToThread
(
thread
);
qDebug
()
<<
"Call init..."
;
obj
->
init
();
qDebug
()
<<
"Starting thread..."
;
}
obj
->
print
();
}
int
getVar
()
{
return
obj
->
getVar
();
}
void
setLocalAdapterMacAddr
(
int
robot
,
const
char
*
localAdapterMacAddr
)
{
robots
[
robot
]
->
setLocalAdapterMacAddr
(
localAdapterMacAddr
);
}
int
newRobot
()
{
if
(
thread
==
nullptr
)
{
thread
=
new
CelluloThread
;
thread
->
start
();
}
if
(
nRobots
==
MAXROBOTS
)
{
qDebug
(
"Have used all slots already"
);
return
-
1
;
}
robots
[
nRobots
]
=
new
CelluloRobotWrapper
();
robots
[
nRobots
]
->
moveToThread
(
thread
);
robots
[
nRobots
]
->
init
();
return
nRobots
++
;
}
void
setAutoConnect
(
int
robot
,
bool
autoConnect
)
{
robots
[
robot
]
->
setAutoConnect
(
autoConnect
);
}
void
setMacAddr
(
int
robot
,
const
char
*
macAddr
)
{
robots
[
robot
]
->
setMacAddr
(
macAddr
);
}
void
connectToServer
(
int
robot
)
{
robots
[
robot
]
->
connectToServer
();
}
void
setGoalVelocity
(
int
robot
,
float
vx
,
float
vy
,
float
w
)
{
robots
[
robot
]
->
setGoalVelocity
(
vx
,
vy
,
w
);
}
void
setGoalPose
(
int
robot
,
float
x
,
float
y
,
float
theta
,
float
v
,
float
w
)
{
robots
[
robot
]
->
setGoalPose
(
x
,
y
,
theta
,
v
,
w
);
}
void
setGoalPosition
(
int
robot
,
float
x
,
float
y
,
float
v
)
{
robots
[
robot
]
->
setGoalPosition
(
x
,
y
,
v
);
}
void
clearTracking
(
int
robot
)
{
robots
[
robot
]
->
clearTracking
();
}
void
clearHapticFeedback
(
int
robot
)
{
robots
[
robot
]
->
clearHapticFeedback
();
}
void
setVisualEffect
(
int
robot
,
int
effect
,
int
r
,
int
g
,
int
b
,
int
value
)
{
robots
[
robot
]
->
setVisualEffect
(
effect
,
QColor
(
r
,
g
,
b
),
value
);
}
void
setCasualBackdriveAssistEnabled
(
int
robot
,
bool
enabled
)
{
robots
[
robot
]
->
setCasualBackdriveAssistEnabled
(
enabled
);
}
void
setHapticBackdriveAssist
(
int
robot
,
float
xAssist
,
float
yAssist
,
float
thetaAssist
)
{
robots
[
robot
]
->
setHapticBackdriveAssist
(
xAssist
,
yAssist
,
thetaAssist
);
}
void
reset
(
int
robot
)
{
robots
[
robot
]
->
reset
();
}
void
simpleVibrate
(
int
robot
,
float
iX
,
float
iY
,
float
iTheta
,
unsigned
int
period
,
unsigned
int
duration
)
{
robots
[
robot
]
->
simpleVibrate
(
iX
,
iY
,
iTheta
,
period
,
duration
);
}
float
getX
(
int
robot
)
{
return
robots
[
robot
]
->
robot
->
getX
();
}
float
getY
(
int
robot
)
{
return
robots
[
robot
]
->
robot
->
getY
();
}
float
getTheta
(
int
robot
)
{
return
robots
[
robot
]
->
robot
->
getTheta
();
}
bool
getKidnapped
(
int
robot
)
{
return
robots
[
robot
]
->
robot
->
getKidnapped
();
}
Event Timeline
Log In to Comment