Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
T
torcs_dl
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Test Cases
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
autonomousdriving
torcs_dl
Commits
c8549d76
Commit
c8549d76
authored
Jun 19, 2018
by
Svetlana
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Controlling TORCS car via messages received from the mastercomponent
parent
e659b7a3
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
5 additions
and
112 deletions
+5
-112
TorcsEMAMGenerator/src/main/resources/torcs/src/camera/src/torcsclient.cpp
...r/src/main/resources/torcs/src/camera/src/torcsclient.cpp
+0
-51
TorcsEMAMGenerator/src/main/resources/torcs/src/camera/src/torcsclient.h
...tor/src/main/resources/torcs/src/camera/src/torcsclient.h
+2
-3
TorcsEMAMGenerator/src/main/resources/torcs/src/driver/src/torcsclient.cpp
...r/src/main/resources/torcs/src/driver/src/torcsclient.cpp
+1
-53
TorcsEMAMGenerator/src/main/resources/torcs/src/driver/src/torcsclient.h
...tor/src/main/resources/torcs/src/driver/src/torcsclient.h
+2
-3
assemble.sh
assemble.sh
+0
-2
No files found.
TorcsEMAMGenerator/src/main/resources/torcs/src/camera/src/torcsclient.cpp
View file @
c8549d76
...
...
@@ -81,54 +81,3 @@ std::unique_ptr<DataContainer> TorcsClient::getScreenshot()
return
result
;
}
void
TorcsClient
::
sendCommand
(
Command
cmd
)
{
assert
(
connected
);
while
(
shared
->
control
==
0
)
{
std
::
this_thread
::
sleep_for
(
std
::
chrono
::
milliseconds
(
100
));
}
shared
->
accelCmd
=
cmd
.
accelCmd
;
shared
->
steerCmd
=
cmd
.
steerCmd
;
shared
->
brakeCmd
=
cmd
.
brakeCmd
;
shared
->
control
=
0
;
//shared->accelCmd = 10.0;
//shared->steerCmd = 1.0;
}
/*void writeScreenshot(shared_use_st* shared, unsigned int& num)
{
std::cout << "Read image." << std::endl;
FIBITMAP* newShot = FreeImage_Allocate(IMAGE_WIDTH, IMAGE_HEIGHT, 24);
if (!newShot)
{
std::cerr << "Failed to allocate freeimage file." << std::endl;
FreeImage_Unload(newShot);
return;
}
BYTE *bits = (BYTE*)FreeImage_GetBits(newShot);
for (int h = 0; h < IMAGE_HEIGHT; h++) {
BYTE *pixel = (BYTE*)bits;
for (int w = 0; w < IMAGE_WIDTH; w++) {
pixel[FI_RGBA_RED] = shared->data[((h)*IMAGE_WIDTH+w)*3+0];
pixel[FI_RGBA_GREEN] = shared->data[((h)*IMAGE_WIDTH+w)*3+1];
pixel[FI_RGBA_BLUE] = shared->data[((h)*IMAGE_WIDTH+w)*3+2];
pixel += 3;
}
bits += 3*IMAGE_WIDTH;
}
FreeImage_Save(FIF_BMP, newShot, (std::string("shot-")+std::to_string(num)).c_str());
FreeImage_Unload(newShot);
shared->control = 0;
shared->written = 0;
std::this_thread::sleep_for(std::chrono::seconds(2));std::cout << "Read image." << std::endl;
}*/
TorcsEMAMGenerator/src/main/resources/torcs/src/camera/src/torcsclient.h
View file @
c8549d76
...
...
@@ -7,8 +7,8 @@
namespace
torcs
{
constexpr
auto
IMAGE_WIDTH
=
28
0
;
constexpr
auto
IMAGE_HEIGHT
=
21
0
;
constexpr
auto
IMAGE_WIDTH
=
64
0
;
constexpr
auto
IMAGE_HEIGHT
=
48
0
;
constexpr
auto
IMAGE_CHANNELS
=
3
;
constexpr
auto
IMAGE_SIZE_BYTES
=
IMAGE_WIDTH
*
IMAGE_HEIGHT
*
IMAGE_CHANNELS
;
...
...
@@ -63,7 +63,6 @@ class TorcsClient
{
public:
TorcsClient
();
std
::
unique_ptr
<
DataContainer
>
getScreenshot
();
void
sendCommand
(
Command
cmd
);
private:
...
...
TorcsEMAMGenerator/src/main/resources/torcs/src/driver/src/torcsclient.cpp
View file @
c8549d76
...
...
@@ -65,27 +65,11 @@ TorcsClient::TorcsClient()
shared
->
brakeCmd
=
0.0
;
}
std
::
unique_ptr
<
DataContainer
>
TorcsClient
::
getScreenshot
()
{
assert
(
connected
);
while
(
shared
->
written
==
0
)
{
std
::
this_thread
::
sleep_for
(
std
::
chrono
::
milliseconds
(
100
));
}
auto
result
=
std
::
make_unique
<
DataContainer
>
();
memcpy
(
result
->
data
(),
shared
->
data
,
result
->
size
());
shared
->
written
=
0
;
return
result
;
}
void
TorcsClient
::
sendCommand
(
Command
cmd
)
{
assert
(
connected
);
while
(
shared
->
control
==
0
)
{
while
(
shared
->
control
==
1
)
{
std
::
this_thread
::
sleep_for
(
std
::
chrono
::
milliseconds
(
100
));
}
...
...
@@ -94,41 +78,5 @@ void TorcsClient::sendCommand(Command cmd)
shared
->
brakeCmd
=
cmd
.
brakeCmd
;
shared
->
control
=
0
;
//shared->accelCmd = 10.0;
//shared->steerCmd = 1.0;
}
/*void writeScreenshot(shared_use_st* shared, unsigned int& num)
{
std::cout << "Read image." << std::endl;
FIBITMAP* newShot = FreeImage_Allocate(IMAGE_WIDTH, IMAGE_HEIGHT, 24);
if (!newShot)
{
std::cerr << "Failed to allocate freeimage file." << std::endl;
FreeImage_Unload(newShot);
return;
}
BYTE *bits = (BYTE*)FreeImage_GetBits(newShot);
for (int h = 0; h < IMAGE_HEIGHT; h++) {
BYTE *pixel = (BYTE*)bits;
for (int w = 0; w < IMAGE_WIDTH; w++) {
pixel[FI_RGBA_RED] = shared->data[((h)*IMAGE_WIDTH+w)*3+0];
pixel[FI_RGBA_GREEN] = shared->data[((h)*IMAGE_WIDTH+w)*3+1];
pixel[FI_RGBA_BLUE] = shared->data[((h)*IMAGE_WIDTH+w)*3+2];
pixel += 3;
}
bits += 3*IMAGE_WIDTH;
}
FreeImage_Save(FIF_BMP, newShot, (std::string("shot-")+std::to_string(num)).c_str());
FreeImage_Unload(newShot);
shared->control = 0;
shared->written = 0;
std::this_thread::sleep_for(std::chrono::seconds(2));std::cout << "Read image." << std::endl;
}*/
TorcsEMAMGenerator/src/main/resources/torcs/src/driver/src/torcsclient.h
View file @
c8549d76
...
...
@@ -7,8 +7,8 @@
namespace
torcs
{
constexpr
auto
IMAGE_WIDTH
=
28
0
;
constexpr
auto
IMAGE_HEIGHT
=
21
0
;
constexpr
auto
IMAGE_WIDTH
=
64
0
;
constexpr
auto
IMAGE_HEIGHT
=
48
0
;
constexpr
auto
IMAGE_CHANNELS
=
3
;
constexpr
auto
IMAGE_SIZE_BYTES
=
IMAGE_WIDTH
*
IMAGE_HEIGHT
*
IMAGE_CHANNELS
;
...
...
@@ -63,7 +63,6 @@ class TorcsClient
{
public:
TorcsClient
();
std
::
unique_ptr
<
DataContainer
>
getScreenshot
();
void
sendCommand
(
Command
cmd
);
private:
...
...
assemble.sh
deleted
100644 → 0
View file @
e659b7a3
#!bin/bash
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment