commit
8366e5c0c9
|
@ -48,6 +48,7 @@ namespace carla {
|
|||
if (!worldConnected())
|
||||
return false;
|
||||
readed = _pimpl->communication.tryReadEpisodeStart(startIndex, endIndex);
|
||||
std::cout << "Episode Start: " << readed << std::endl;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -62,6 +63,7 @@ namespace carla {
|
|||
if (!worldConnected())
|
||||
return false;
|
||||
newEpisode = _pimpl->communication.tryReadRequestNewEpisode();
|
||||
std::cout << "New Episode Request: " << newEpisode << std::endl;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -77,6 +79,8 @@ namespace carla {
|
|||
if (!worldConnected())
|
||||
return false;
|
||||
_pimpl->communication.sendScene(values);
|
||||
|
||||
std::cout << "Send scene values" << std::endl;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -84,6 +88,9 @@ namespace carla {
|
|||
if (!worldConnected())
|
||||
return false;
|
||||
_pimpl->communication.sendReset();
|
||||
|
||||
std::cout << "Send end reset" << std::endl;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -44,7 +44,8 @@ namespace carla {
|
|||
Reward_Values();
|
||||
~Reward_Values();
|
||||
/// Time-stamp of the current frame.
|
||||
int32_t timestamp;
|
||||
int32_t platform_timestamp;
|
||||
int32_t game_timestamp;
|
||||
/// World location of the player.
|
||||
Vector2D player_location;
|
||||
/// Orientation of the player.
|
||||
|
|
|
@ -221,16 +221,12 @@ namespace server {
|
|||
}
|
||||
|
||||
void CarlaCommunication::sendScene(const Scene_Values &values) {
|
||||
// Protobuf produces a segmentation fault in the destructor of the Scene
|
||||
// when called from Unreal Engine in Linux. As a workaround, we added this
|
||||
// cute memory leak.
|
||||
/// @todo #10 Fix the memory leak!
|
||||
Scene *scene = new Scene;
|
||||
_proto->LoadScene(*scene, values);
|
||||
Scene scene;
|
||||
_proto->LoadScene(scene, values);
|
||||
|
||||
auto message = std::make_unique<std::string>();
|
||||
|
||||
if (scene->SerializeToString(message.get())) {
|
||||
if (scene.SerializeToString(message.get())) {
|
||||
_worldThread.push(std::move(message));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -241,11 +241,6 @@ static bool getPNGImages(const std::vector<Image> &images, Reward &rwd) {
|
|||
|
||||
}
|
||||
|
||||
std::cout << "send depth size: " << depth_size_data.size() <<
|
||||
" send image size: " << image_size_data.size()<<
|
||||
" send image: " << image_data.size()<<
|
||||
" send depth: " << depth_data.size() << std::endl;
|
||||
|
||||
rwd.set_depth_sizes(depth_size_data);
|
||||
rwd.set_image_sizes(image_size_data);
|
||||
rwd.set_images(image_data);
|
||||
|
@ -280,7 +275,8 @@ static bool getPNGImages(const std::vector<Image> &images, Reward &rwd) {
|
|||
reward.set_player_y(values.player_location.y);
|
||||
reward.set_player_x(values.player_location.x);
|
||||
reward.set_speed(values.forward_speed);
|
||||
reward.set_timestamp(values.timestamp);
|
||||
reward.set_platform_timestamp(values.platform_timestamp);
|
||||
reward.set_game_timestamp(values.game_timestamp);
|
||||
|
||||
#ifdef CARLA_WITH_PNG_COMPRESSION
|
||||
if (!getPNGImages(values.images, reward)) {
|
||||
|
|
|
@ -36,7 +36,12 @@ namespace carla {
|
|||
port(port),
|
||||
_service(),
|
||||
_socket(_service),
|
||||
_connected(false){}
|
||||
_connected(false){
|
||||
|
||||
//int32_t timeout = 500;
|
||||
//setsockopt(_socket.native(), SOL_SOCKET, SO_SNDTIMEO, (const char*)&timeout, sizeof(timeout));
|
||||
|
||||
}
|
||||
|
||||
TCPServer::~TCPServer() {}
|
||||
|
||||
|
@ -60,7 +65,6 @@ namespace carla {
|
|||
void TCPServer::writeString(const std::string &message, error_code &error) {
|
||||
const int messageSize = static_cast<int>(message.length());
|
||||
std::string outMessage(GetBytes(messageSize) + message);
|
||||
|
||||
boost::asio::write(_socket, boost::asio::buffer(outMessage), error);
|
||||
|
||||
if (error)
|
||||
|
|
|
@ -78,13 +78,14 @@ message Reward {
|
|||
optional float acceleration_x = 9;
|
||||
optional float acceleration_y = 10;
|
||||
optional float acceleration_z = 11;
|
||||
optional int32 timestamp = 12;
|
||||
optional float ori_x = 13;
|
||||
optional float ori_y = 14;
|
||||
optional float ori_z = 15;
|
||||
optional bytes image_sizes = 16;
|
||||
optional bytes depth_sizes = 17;
|
||||
optional bytes images = 18;
|
||||
optional bytes depths = 19;
|
||||
optional int32 platform_timestamp = 12;
|
||||
optional int32 game_timestamp = 13;
|
||||
optional float ori_x = 14;
|
||||
optional float ori_y = 15;
|
||||
optional float ori_z = 16;
|
||||
optional bytes image_sizes = 17;
|
||||
optional bytes depth_sizes = 18;
|
||||
optional bytes images = 19;
|
||||
optional bytes depths = 20;
|
||||
|
||||
}
|
||||
|
|
|
@ -58,6 +58,7 @@ std::unique_ptr<carla::Reward_Values> makeReward() {
|
|||
reward->collision_car = 10.0f;
|
||||
reward->intersect_other_lane = 0.5f;
|
||||
reward->intersect_offroad = 0.5f;
|
||||
reward->game_timestamp = 0u;
|
||||
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
carla::Image img;
|
||||
|
@ -74,8 +75,9 @@ std::unique_ptr<carla::Reward_Values> makeReward() {
|
|||
reward->image_depth_0 = makeImage(imageWidth, imageHeight);
|
||||
reward->image_depth_1 = makeImage(imageWidth, imageHeight);
|
||||
*/
|
||||
static decltype(carla::Reward_Values::timestamp) timestamp = 0u;
|
||||
reward->timestamp = timestamp++;
|
||||
static decltype(carla::Reward_Values::platform_timestamp) timestamp = 0u;
|
||||
|
||||
reward->platform_timestamp = timestamp++;
|
||||
|
||||
return reward;
|
||||
}
|
||||
|
@ -162,7 +164,11 @@ int main(int argc, char *argv[]) {
|
|||
uint32_t startPoint, endPoint;
|
||||
bool error = false, readed = false;
|
||||
do {
|
||||
|
||||
std::cout << "Try read episode Start: ";
|
||||
error = !server.tryReadEpisodeStart(startPoint, endPoint, readed);
|
||||
std::cout << error << std::endl;
|
||||
|
||||
} while (!readed && !error);
|
||||
|
||||
if (error) {
|
||||
|
@ -181,12 +187,13 @@ int main(int argc, char *argv[]) {
|
|||
break;
|
||||
} else if (readed) {
|
||||
std::cout << "CONTROL --> gas: " << gas << " steer: " << steer << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
if (!server.sendReward(makeReward().release())) {
|
||||
std::cerr << "ERROR while sending Reward" << std::endl;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!server.sendReward(makeReward().release())) {
|
||||
std::cerr << "ERROR while sending Reward" << std::endl;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
std::cout << " ----- RESTARTING -----" << std::endl;
|
||||
|
|
Loading…
Reference in New Issue