Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [sumo-user] Class for person in Omnet++

Thank you, Dominik S.Buse
I run the veins_inet_pedestrians example and it works. It gives me some ideas for declaring a "person" class.
However, I could not establish C++ class for VeinsInetPerson. My steps include:
1. In VeinsInetPerson.ned, I write:  @class(veins::VeinsInetPerson);
2. I declare a C++ class named VeinsInetPerson
3. Declare a .h file in which the namespace of the class is veins, and this class uses namespace omnetpp
4. In .cc file, implement the code. 
And as running as Omnet++ simulation, the IDE reports error: cannot convert 'veins::VeinsInetPerson*' to 'omnetpp::cObject*' in initialization
I search the Internet for the error  to "'omnetpp::cObject*' in initialization" but I found nothing :(
Any help will be appreciated. Thank you in advance

PS: I attached three files NED, .CC and .H


On Fri, Apr 22, 2022 at 4:25 PM Dominik S. Buse <buse@xxxxxxxxxxxx> wrote:

Hi,

you may also want to take a look at this pull request to veins: https://github.com/sommer/veins/pull/148

It included subscription support for pedestrians. It seemed to have worked, yet was to complex to get merged into Veins. But you may be able to gain some ideas or salvage some code.


On 22.04.22 10:05, Jakob Erdmann wrote:
You'll have to patch TraCICommandInterface to add this method. The code is easily adaptable from other entities that provide a position (i.e. Poi)
On the implementation side, it should look like this:

Coord TraCICommandInterface::Person::getPosition()
{
return traci->genericGetCoord(CMD_GET_PERSON_VARIABLE, personId, VAR_POSITION, RESPONSE_GET_PERSON_VARIABLE);
}

Adding a pull-request against https://github.com/sommer/veins may help out future Veins users.

Am Fr., 22. Apr. 2022 um 09:50 Uhr schrieb Thanhnt Nguyen <thanhnt.fit@xxxxxxxxx>:
Thank you.
I suppose "traci" is an attribute of DemoBaseApplLayer class. In this class "traci" is an instance of TraCICommandInterface.
However the TraCICommandInterface class has no attribute named "person"
How could I access it?


On Fri, Apr 22, 2022 at 9:26 AM Jakob Erdmann <namdre.sumo@xxxxxxxxx> wrote:
The default way to write position information is with --fcd-output.
If you need the information at runtime, you can call traci.person.getPosition(personID) 
The list of all person ids can be obtained with traci.person.getIDList() (This includes all persons generated by a personFlow)

Am Fr., 22. Apr. 2022 um 09:20 Uhr schrieb Thanhnt Nguyen <thanhnt.fit@xxxxxxxxx>:
I found a quick hack to get coordinates of all pedestrians in personFlow.
In the source code of SUMO, edit the file: GUIEdge.cpp. More specifically, find the statement:
person->drawGL(s);
and then write a new line: std::cout<<person->getPosition()<<std::endl;
It works, the position will be printed as sumo-gui runs alone.
However, a new problem arises: My project needs positions to be available while the simulation is running. But the data of position is not printed as choosing "Run as Omnet++ simulation". The simulation should end and a user should close the Qtenv, the data would be available in the terminal. I tried other ways (such as writing a file) but it doesn't change: data only is printed after a user closes Qtenv.
_______________________________________________
sumo-user mailing list
sumo-user@xxxxxxxxxxx
To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/sumo-user
_______________________________________________
sumo-user mailing list
sumo-user@xxxxxxxxxxx
To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/sumo-user


--
Nguyen Tien Thanh
Department of Software Engineering
School of Information and Communication Technology (SoICT, http://www.fit.hut.edu.vn)
Hanoi University of Technology (HUT, http://www.hut.edu.vn)
1 DaiCoViet Road, Hanoi, Vietnam
Tel: +84-4-8682595/8683730 Fax +84-4-8692906
Mobile: +84987768886
           ntthanh@xxxxxxxxxxxxx
           thanhnt.fit@xxxxxxxxx
Website: www.fit.hut.edu.vn/~thanhnt
_______________________________________________
sumo-user mailing list
sumo-user@xxxxxxxxxxx
To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/sumo-user

_______________________________________________
sumo-user mailing list
sumo-user@xxxxxxxxxxx
To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/sumo-user
-- 
Dominik S. Buse M.Sc.
PhD Candidate at Data Communications and Networking Group (TKN), TU Berlin, Germany
Researcher at Software Innovation Campus Paderborn, Paderborn University, Germany
http://www.tkn.tu-berlin.de/team/buse/
_______________________________________________
sumo-user mailing list
sumo-user@xxxxxxxxxxx
To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/sumo-user


--
Nguyen Tien Thanh
Department of Software Engineering
School of Information and Communication Technology (SoICT, http://www.fit.hut.edu.vn)
Hanoi University of Technology (HUT, http://www.hut.edu.vn)
1 DaiCoViet Road, Hanoi, Vietnam
Tel: +84-4-8682595/8683730 Fax +84-4-8692906
Mobile: +84987768886
E-mail: thanhnt@xxxxxxxxxxxxxxxx  
           ntthanh@xxxxxxxxxxxxx
           thanhnt.fit@xxxxxxxxx
Website: www.fit.hut.edu.vn/~thanhnt
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// 
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Lesser General Public License for more details.
// 
// You should have received a copy of the GNU Lesser General Public License
// along with this program.  If not, see http://www.gnu.org/licenses/.
// 

#include "VeinsInetPerson.h"

using namespace veins;
//namespace veins {



Register_Class(VeinsInetPerson);

VeinsInetPerson::VeinsInetPerson() {
    // TODO Auto-generated constructor stub

}

VeinsInetPerson::~VeinsInetPerson() {
    // TODO Auto-generated destructor stub
}

//} // namespace veins

Attachment: VeinsInetPerson.ned
Description: Binary data

//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// 
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Lesser General Public License for more details.
// 
// You should have received a copy of the GNU Lesser General Public License
// along with this program.  If not, see http://www.gnu.org/licenses/.
// 

#ifndef VEINS_INET_VEINSINETPERSON_H_
#define VEINS_INET_VEINSINETPERSON_H_


#pragma once

#include "veins_inet/veins_inet.h"

#include "veins_inet/VeinsInetApplicationBase.h"
using namespace omnetpp;

namespace veins {

class VeinsInetPerson {
protected:
    bool haveForwarded = false;

public:
    VeinsInetPerson();
    ~VeinsInetPerson();
};
}
#endif /* VEINS_INET_VEINSINETPERSON_H_ */

Back to the top